From 40d91066ce248cdc41ff1c133e472dba1dd3c650 Mon Sep 17 00:00:00 2001 From: Mike Khiretskiy Date: Thu, 19 Mar 2015 13:55:34 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=BF=D0=BE=D0=B4=D0=BC=D0=B5=D0=BD=D1=8E=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=B2=D1=8B=D0=B1=D0=BE=D1=80=D0=B0=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B7=D1=80=D0=B5=D1=88=D0=B5=D0=BD=D0=B8=D0=B9=20?= =?UTF-8?q?=D1=8D=D0=BA=D1=80=D0=B0=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dia_resolution.inc | 117 +++++++++++++++++++++++++++++++++++++++++++++ dia_video.inc | 1 + dia_videomodes.inc | 60 +++++++++++++---------- xmenu.inc | 7 +-- 4 files changed, 156 insertions(+), 29 deletions(-) create mode 100644 dia_resolution.inc diff --git a/dia_resolution.inc b/dia_resolution.inc new file mode 100644 index 0000000..caeb72e --- /dev/null +++ b/dia_resolution.inc @@ -0,0 +1,117 @@ +% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +% +% Resolution mode selector. +% +% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +/resolution.option .undef def + +% Custom kernel options. Feel free to extend as needed. Keep this in sync +% with MenuInitj + +/resolution.auto 0 def + +/resolution.alltexts [ + "Auto" "640x480" "800x480" "800x600" "1024x576" + "1024x600" "1024x768" "1200x800" "1280x720" + "1280x768" "1280x800" "1280x1024" "1360x768" + "1366x768" "1368x768" "1400x1050" "1440x900" + "1600x768" "1600x900" "1600x1200" "1680x945" + "1680x1050" "1920x1080" "1920x1200" "2048x1152" + "2560x1440" "2560x1600" +] def + +% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +% Initialise resolutionibility menu. +% +% ( ) ==> ( ) +% +/resolution.init { + /xmenu.resolution .xm_size array def + /xmenu xmenu.resolution def + + xmenu .xm_current resolution.auto put + + xmenu .xm_list [ + resolution.alltexts { + exec + } forall + ] put + + xmenu .xm_title /txt_resolution put + xmenu .xm_current resolution.auto put + + pmenu.init +} def + + +% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +% Update accessibility status. +% +% ( ) ==> ( ) +% +/resolution.update { + /xmenu xmenu.resolution def + + /window.action actRedrawPanel def + + pmenu.update +} def + + +% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +% Show window. +% +% ( ) => ( ) +% +/panel.resolution { + "resolution" help.setcontext + + window.xmenu + dup .xmenu xmenu.resolution put + dup .xmenu.update /resolution.update put + dup window.init + window.show +} def + + +% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +% Return width of panel entry. +% +% ( ) => ( width ) +% +/panel.resolution.width { + /xmenu xmenu.resolution def + + pmenu.width +} def + + +% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +% Redraw panel entry. +% +% ( panel ) => ( ) +% +/panel.resolution.update { + /xmenu xmenu.resolution def + + pmenu.panel.update +} def + +% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +% Recalculate panel entry. +% +% ( panel ) => ( ) +/panel.resolution.recalculate { + /xmenu xmenu.resolution def + + panel.text.moveto + xmenu.sizes + xmenu .xm_panel_x currentpoint pop xmenu.hspace sub put + % try to ensure that the menu doesn't overflow the screen + xmenu .xm_x + xmenu .xm_panel_x get + screen.size pop xmenu.columns xmenu.widthupto 10 add sub + min put +} def diff --git a/dia_video.inc b/dia_video.inc index d2f6cff..a834035 100644 --- a/dia_video.inc +++ b/dia_video.inc @@ -14,6 +14,7 @@ /.vm_height 2 def /.vm_depth 3 def +%% include dia_resolution.inc % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % Create sort key for video modes. diff --git a/dia_videomodes.inc b/dia_videomodes.inc index d620f76..7497dd1 100644 --- a/dia_videomodes.inc +++ b/dia_videomodes.inc @@ -7,6 +7,7 @@ /video_modes.selected.append .undef def /video_modes.selected.replace .undef def +/video_modes.submenu.idx 0 def % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -32,10 +33,10 @@ video_modes.gfxconfig { 0 get /video_modes.tmp.key exch def video_modes.tmp.key 6 strndup dup "label " eq exch free { - video_modes.tmp.key 6 add dup length 8 add string /video_modes.tmp.str exch def - "append %s" video_modes.tmp.str sprintf - video_modes.tmp.str getgfxconfig - video_modes.tmp.str free + video_modes.tmp.key 6 add dup length 8 add string /video_modes.tmp.str exch def + "append %s" video_modes.tmp.str sprintf + video_modes.tmp.str getgfxconfig + video_modes.tmp.str free } if } forall .undef @@ -44,10 +45,10 @@ video_modes.gfxconfig { 0 get /video_modes.tmp.key exch def video_modes.tmp.key 6 strndup dup "label " eq exch free { - video_modes.tmp.key 6 add dup length 9 add string /video_modes.tmp.str exch def - "replace %s" video_modes.tmp.str sprintf - video_modes.tmp.str getgfxconfig - video_modes.tmp.str free + video_modes.tmp.key 6 add dup length 9 add string /video_modes.tmp.str exch def + "replace %s" video_modes.tmp.str sprintf + video_modes.tmp.str getgfxconfig + video_modes.tmp.str free } if } forall .undef @@ -56,10 +57,10 @@ video_modes.gfxconfig { 0 get /video_modes.tmp.key exch def video_modes.tmp.key 6 strndup dup "label " eq exch free { - video_modes.tmp.key 6 add dup length 9 add string /video_modes.tmp.str exch def - "applies %s" video_modes.tmp.str sprintf - video_modes.tmp.str getgfxconfig - video_modes.tmp.str free + video_modes.tmp.key 6 add dup length 9 add string /video_modes.tmp.str exch def + "applies %s" video_modes.tmp.str sprintf + video_modes.tmp.str getgfxconfig + video_modes.tmp.str free } if } forall .undef @@ -76,6 +77,8 @@ menu.entry video_modes.filter xmenu .xm_title /txt_videodrv put + resolution.init + } def @@ -92,14 +95,18 @@ % /video_modes.update { /xmenu xmenu.video_modes def + xmenu .xm_current get video_modes.submenu.idx eq { + xmenu 0 xmenu.oldentry put + panel.resolution + } { + video_modes.map xmenu .xm_current get get + video_modes.append over get /video_modes.selected.append exch def + video_modes.replace over get /video_modes.selected.replace exch def - video_modes.map xmenu .xm_current get get - video_modes.append over get /video_modes.selected.append exch def - video_modes.replace over get /video_modes.selected.replace exch def - - /window.action actRedrawPanel def + /window.action actRedrawPanel def - pmenu.update + pmenu.update + } ifelse } def @@ -129,12 +136,12 @@ /video_modes.map [ 0 1 video_modes.rawlabels length 1 sub { video_modes.applies over get dup .undef ne { - dup length 3 add string /video_modes.tmp.applies exch def - " %s " video_modes.tmp.applies sprintf - video_modes.tmp.applies video_modes.tmp.label strstr 0 eq { pop } if - video_modes.tmp.applies free + dup length 3 add string /video_modes.tmp.applies exch def + " %s " video_modes.tmp.applies sprintf + video_modes.tmp.applies video_modes.tmp.label strstr 0 eq { pop } if + video_modes.tmp.applies free } { - pop + pop } ifelse } for ] def @@ -155,6 +162,9 @@ } ifelse } for + xmenu .xm_list get length 1 sub + /video_modes.submenu.idx exch def + pmenu.init /xmenu exch def % restore @@ -196,5 +206,7 @@ /panel.video_modes.update { /xmenu xmenu.video_modes def - pmenu.panel.update + dup pmenu.panel.update + + panel.resolution.recalculate } def diff --git a/xmenu.inc b/xmenu.inc index f18be96..00877dd 100644 --- a/xmenu.inc +++ b/xmenu.inc @@ -100,11 +100,8 @@ small_layout { xmenu .xm_check get { xmenu .xm_allselected get xmenu .xm_current get over over get not put xmenu .xm_current get xmenu.viewentry - window.current .xmenu.change get dup .undef ne { - exec - } { - pop window.current .xmenu.update get exec - } ifelse + window.current .xmenu.change get exec + dup .undef ne { exec } { pop } ifelse } if pop 0 } if