blob: 31bea24eb8dad84b6f5f303fab85937d7982e793 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%
% Video mode selection dialog.
%
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Some global vars.
%
% video mode array fields (as returned by getvideomode)
/.vm_mode 0 def
/.vm_width 1 def
/.vm_height 2 def
/.vm_ok 3 def % monitor supports it
% We have kernel splash images for at least these sizes.
/video.splashsizes [
640 480
800 600
1024 768
1280 1024
] def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Create sort key for video modes.
%
% ( vm_index ) ==> ( sort_index )
%
/vmsortindex {
video.modes.list exch get
dup
.vm_width get 16 shl
exch .vm_height get add
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Swap video mode entries.
% (Helper for video mode sorting.)
%
% ( vm_index_1 vm_index_2 ) ==> ( )
%
/vmsortexch {
over video.modes.list exch get
over video.modes.list exch get
video.modes.list
5 -1 roll rot put
video.modes.list 3 1 roll put
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Check if we have a splash in that resolution.
%
% ( video_mode_list_entry ) ==> ( true|false )
%
/video.havesplash {
false exch
0 2 video.splashsizes length 1 sub {
over over over
.vm_height get rot .vm_width get rot video.splashsizes exch get eq
rot 1 add video.splashsizes exch get rot eq and
{ exch pop true exch exit } if
} for
pop
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Build video mode list.
%
% ( ) ==> ( )
%
/video.init {
/xmenu.video .xm_size array def
/xmenu xmenu.video def
videomodes 1 add dup array /video.modes.text exch def array /video.modes.list exch def
xmenu .xm_list video.modes.text put
% add text mode entry
% [ mode width height supported ]
video.modes.list 0 [ 0 0 0 1 ] put
videomodes 0 gt {
0 1 videomodes 1 sub {
video.modes.list exch [ over getvideomode ] exch 1 add exch put
} for
} if
% always accept 800x600
video.modes.list {
dup .vm_width get 800 eq
over .vm_height get 600 eq
and { .vm_ok 1 put } { pop } ifelse
} forall
% sort video.modes.list
video.modes.list length 1 gt {
0 1 video.modes.list length 2 sub {
dup 1 add 1 video.modes.list length 1 sub {
over vmsortindex over vmsortindex gt {
over over vmsortexch
} if
pop
} for
pop
} for
} if
% create mode strings
0 1 video.modes.list length 1 sub {
video.modes.text exch
dup video.modes.list exch get
dup .vm_width get 0 eq {
pop "Text Mode" put
} {
dup .vm_width get 640 eq
over .vm_height get 480 eq
and {
pop "VESA" put
} {
32 string dup rot
dup .vm_height get exch .vm_width get
"%d x %d" 4 -1 roll sprintf
put
} ifelse
} ifelse
} for
% select first mode
xmenu .xm_current 0 put
% select largest mode the monitor supports
0 1 video.modes.list length 1 sub {
video.modes.list over get
dup .vm_ok get 0 gt exch video.havesplash and {
xmenu .xm_current rot put
} {
pop
} ifelse
} for
pmenu.init
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Update video mode.
%
% ( ) ==> ( )
%
/video.update {
/xmenu xmenu.video def
/window.action actRedrawPanel def
pmenu.update
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Show video menu.
%
% ( ) => ( )
%
/panel.video {
"videomode" help.setcontext
window.xmenu
dup .xmenu xmenu.video put
dup .xmenu.update /video.update put
dup window.init
window.show
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Return width of video entry.
%
% ( ) => ( width )
%
/panel.video.width {
/xmenu xmenu.video def
pmenu.width
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Redraw panel entry.
%
% ( panel ) => ( )
%
/panel.video.update {
/xmenu xmenu.video def
pmenu.panel.update
} def
|