Browse Source

Добавлено подменю для выбора разрешений экрана

master
Mike Khiretskiy 7 years ago
parent
commit
40d91066ce
  1. 117
      dia_resolution.inc
  2. 1
      dia_video.inc
  3. 60
      dia_videomodes.inc
  4. 7
      xmenu.inc

117
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

1
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.

60
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

7
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

Loading…
Cancel
Save