Commit | Line | Data |
30500b05 |
1 | #! /usr/bin/perl -w |
2 | |
3 | #END { |
4 | # sleep 10; |
5 | #} |
6 | |
7 | sub propagate_INC { |
8 | my $inc = $ENV{PERL5LIB}; |
9 | $inc = $ENV{PERLLIB} unless defined $inc; |
10 | $inc = '' unless defined $inc; |
11 | $ENV{PERL5LIB} = join ';', @INC, split /;/, $inc; |
12 | } |
13 | |
14 | my $separate_session; |
15 | BEGIN { # Remap I/O to the parent's window |
16 | $separate_session = $ENV{OS2_PROCESS_TEST_SEPARATE_SESSION}; |
17 | propagate_INC, return unless $separate_session; # done by the parent |
18 | my @fn = split " ", $ENV{NEW_FD}; |
19 | my @fh = (*STDOUT, *STDERR); |
20 | my @how = qw( > > ); |
21 | # warn $_ for @fn; |
22 | open $fh[$_], "$how[$_]&=$fn[$_]" |
23 | or warn "Cannot reopen $fh[$_], $how[$_]&=$fn[$_]: $!" for 0..1; |
24 | } |
25 | |
26 | use strict; |
27 | use Test::More tests => 227; |
28 | use OS2::Process; |
29 | |
30 | sub SWP_flags ($) { |
31 | my @nkpos = WindowPos shift; |
32 | $nkpos[2]; |
33 | } |
34 | |
35 | my $interactive_wait = @ARGV && $ARGV[0] eq 'wait'; |
36 | |
37 | my @l = OS2::Process::process_entry(); |
38 | ok(@l == 11, 'all the fields of the process_entry() are there'); |
39 | |
40 | # 1: FS 2: Window-VIO |
41 | ok( ($l[9] == 1 or $l[9] == 2), 'we are FS or Windowed-VIO'); |
42 | |
43 | #print "# $_\n" for @l; |
44 | |
45 | eval <<'EOE' or die; |
46 | #use OS2::Process qw(WM_SYSCOMMAND WM_DBCSLAST FID_CLIENT HWND_DESKTOP); |
47 | use OS2::Process qw(WM_SYSCOMMAND WM_DBCSLAST HWND_DESKTOP); |
48 | |
49 | ok( WM_SYSCOMMAND == 0x0021, 'correct WM_SYSCOMMAND' ); |
50 | ok( WM_DBCSLAST == 0x00cf, 'correct WM_DBCSLAST' ); |
51 | #ok( FID_CLIENT == 0x8008 ); |
52 | ok( HWND_DESKTOP == 0x0001, 'correct HWND_DESKTOP' ); |
53 | 1; |
54 | EOE |
55 | |
56 | my $t = Title; |
57 | my $wint = winTitle; |
58 | |
59 | ok($t, 'got session title'); |
60 | ok($wint, 'got titlebar text'); |
61 | |
62 | my $newt = "test OS2::Process $$"; |
63 | ok(Title_set($newt), 'successfully set Title'); |
64 | is(Title, $newt, 'correctly set Title'); |
65 | my $wt = winTitle or warn "winTitle: $!, $^E"; |
66 | is(winTitle, $newt, 'winTitle changed its value too'); |
67 | ok(Title_set $t, 'successfully set Title back'); |
68 | is(Title, $t, 'correctly set Title back'); |
69 | is(winTitle, $wint, 'winTitle restored its value too'); |
70 | |
71 | $newt = "test OS2::Process both-$$"; |
72 | ok(bothTitle_set($newt), 'successfully set both titles via Win* API'); |
73 | is(Title, $newt, 'session title correctly set'); |
74 | is(winTitle, $newt, 'winTitle correctly set'); |
75 | ok(bothTitle_set($t), 'successfully reset both titles via Win* API'); |
76 | is(Title, $t, 'session title correctly reset'); |
77 | is(winTitle, $wint, 'winTitle correctly reset'); |
78 | |
79 | $newt = "test OS2::Process win-$$"; |
80 | ok(winTitle_set($newt), 'successfully set titlebar title via Win* API'); |
81 | is(Title, $t, 'session title remained the same'); |
82 | is(winTitle, $newt, 'winTitle changed value'); |
83 | ok(winTitle_set($wint), 'successfully reset titlebar title via Win* API'); |
84 | is(Title, $t, 'session title remained the same'); |
85 | is(winTitle, $wint, 'winTitle restored value'); |
86 | |
87 | $newt = "test OS2::Process sw-$$"; |
88 | ok(swTitle_set($newt), 'successfully set session title via Win* API'); |
89 | is(Title, $newt, 'session title correctly set'); |
90 | is(winTitle, $wint, 'winTitle has unchanged value'); |
91 | ok(swTitle_set($t), 'successfully reset session title via Win* API'); |
92 | is(Title, $t, 'session title correctly set'); |
93 | is(winTitle, $wint, 'winTitle has unchanged value'); |
94 | |
95 | $newt = "test OS2::Process again-$$"; |
96 | ok(Title_set($newt), 'successfully set Title again'); |
97 | is(Title, $newt, 'correctly set Title again'); |
98 | is(winTitle, $newt, 'winTitle changed its value too again'); |
99 | ok(Title_set($t), 'successfully set Title back'); |
100 | is(Title, $t, 'correctly set Title back'); |
101 | is(winTitle, $wint, 'winTitle restored its value too again'); |
102 | |
103 | my $hwnd = process_hwnd; |
104 | ok($hwnd, 'found session owner hwnd'); |
105 | my $c_subhwnd = WindowFromId $hwnd, 0x8008; # FID_CLIENT; |
106 | ok($c_subhwnd, 'found client hwnd'); |
107 | my $a_subhwnd = ActiveWindow $hwnd; # or $^E and warn $^E; |
108 | ok((not $a_subhwnd and not $^E), 'No active subwindow in a VIO frame'); |
109 | |
110 | my $ahwnd = ActiveWindow; |
111 | ok($ahwnd, 'found active window'); |
112 | my $fhwnd = FocusWindow; |
113 | ok($fhwnd, 'found focus window'); |
114 | |
115 | # This call without morphing results in VIO window with active highlight, but |
116 | # no keyboard focus (even after Alt-Tabbing to it; you cannot Alt-Tab off it!) |
117 | |
118 | # Interestingly, Desktop is active on the switch list, but the |
119 | # switch list is not acting on keyboard events. |
120 | |
121 | # Give up focus |
122 | { my $force_PM = OS2::localMorphPM->new(0); |
123 | ok $force_PM, 'morphed to PM locally'; |
124 | ok FocusWindow_set(1), 'set focus to DESKTOP'; # HWND_DESKTOP |
125 | } |
126 | my $dtop = DesktopWindow; |
127 | ok($dtop, 'found the desktop window'); |
128 | |
129 | #OS2::Process::ResetWinError; # XXXX Should not be needed! |
130 | $ahwnd = ActiveWindow or $^E and warn $^E; |
131 | ok( (not $ahwnd and not $^E), 'desktop is not active'); |
132 | $fhwnd = FocusWindow; |
133 | ok($fhwnd, 'there is a focus window'); |
134 | is($fhwnd, $dtop, 'which is the desktop'); |
135 | |
136 | # XXXX Well, no need to skip it now... |
137 | SKIP: { |
138 | skip 'We already have focus', 4 if $hwnd == $ahwnd; |
139 | my $force_PM = OS2::localMorphPM->new(0); |
140 | ok $force_PM, 'morphed to PM locally again'; |
141 | ok FocusWindow_set($c_subhwnd), 'set focus to the client of the session owner'; |
142 | # If we do not morph, then when the focus is in another VIO frame, |
143 | # we get two VIO frames with activated titlebars. |
144 | # The only (?) way to take the activated state from another frame |
145 | # is to switch to it via the switch list |
146 | $ahwnd = ActiveWindow; |
147 | ok($ahwnd, 'there is an active window'); |
148 | $fhwnd = FocusWindow; |
149 | ok($fhwnd, 'there is a focus window'); |
150 | is($hwnd, $ahwnd, 'the active window is the session owner'); |
151 | is($fhwnd, $c_subhwnd, 'the focus window is the client of the session owner'); |
152 | } |
153 | |
154 | # Give up focus again |
155 | { my $force_PM = OS2::localMorphPM->new(0); |
156 | ok $force_PM, 'morphed to PM locally again'; |
157 | ok FocusWindow_set(1), 'set focus to DESKTOP again'; # HWND_DESKTOP |
158 | } |
159 | |
160 | $ahwnd = ActiveWindow or $^E and warn $^E; |
161 | ok( (not $ahwnd and not $^E), 'desktop is not active again'); |
162 | $fhwnd = FocusWindow; |
163 | ok($fhwnd, 'there is a focus window'); |
164 | is($fhwnd, $dtop, 'which is the desktop'); |
165 | |
166 | # XXXX Well, no need to skip it now... |
167 | SKIP: { |
168 | skip 'We already have focus', 4 if $hwnd == $ahwnd; |
169 | my $force_PM = OS2::localMorphPM->new(0); |
170 | ok $force_PM, 'morphed to PM locally again'; |
171 | ok ActiveWindow_set($hwnd), 'activate the session owner'; |
172 | $ahwnd = ActiveWindow; |
173 | ok($ahwnd, 'there is an active window'); |
174 | $fhwnd = FocusWindow; |
175 | ok($fhwnd, 'there is a focus window'); |
176 | is($hwnd, $ahwnd, 'the active window is the session owner'); |
177 | } |
178 | |
179 | # XXXX Well, no need to skip it now... |
180 | SKIP: { |
181 | skip 'Tests assume we have focus', 1 unless $hwnd == $ahwnd; |
182 | # We have focus |
183 | # is($fhwnd, $ahwnd); |
184 | # is($a_subhwnd, $c_subhwnd); |
185 | is($fhwnd, $c_subhwnd, 'the focus window is the client of the session owner'); |
186 | } |
187 | |
188 | # Check enumeration of switch entries: |
189 | my $skid_title = "temporary s-kid ppid=$$"; |
190 | my $spid = system P_SESSION, $^X, '-wle', "END {sleep 25} use OS2::Process; eval {Title_set '$skid_title'} or warn \$@; \$SIG{TERM} = sub {exit 0}"; |
191 | ok ($spid, 'start the new VIO session with unique title'); |
192 | sleep 1; |
193 | my @sw = grep $_->{title} eq $skid_title, process_hentries; |
194 | sleep 1000 unless @sw; |
195 | is(scalar @sw, 1, 'exactly one session with this title'); |
196 | my $sw = $sw[0]; |
197 | ok $sw, 'have the data about the session'; |
198 | is($sw->{owner_pid}, $spid, 'session has a correct pid'); |
199 | my $k_hwnd = $sw->{owner_hwnd}; |
200 | ok $k_hwnd, 'found the session window handle'; |
201 | is sidOf($spid), $sw->{owner_sid}, 'we know sid of the session'; |
202 | |
203 | # Give up focus again |
204 | { my $force_PM = OS2::localMorphPM->new(0); |
205 | ok $force_PM, 'morphed to PM locally again'; |
206 | ok FocusWindow_set($k_hwnd), 'set focus to kid session window'; |
207 | } |
208 | |
209 | $ahwnd = ActiveWindow; |
210 | ok $ahwnd, 'there is an active window'; |
211 | is $ahwnd, $k_hwnd, 'after focusing the active window is the owner_hwnd'; |
212 | $fhwnd = FocusWindow; |
213 | ok $fhwnd, 'there is a focus window'; |
214 | my $c_sub_ahwnd = WindowFromId $ahwnd, 0x8008; # FID_CLIENT; |
215 | ok $c_sub_ahwnd, 'the active window has a FID_CLIENT'; |
216 | is($fhwnd, $ahwnd, 'the focus window = the active window'); |
217 | |
218 | ok hWindowPos_set({behind => 3}, $k_hwnd), # HWND_TOP |
219 | 'put kid to the front'; |
220 | |
221 | is((hWindowPos $k_hwnd)->{behind}, 3, 'kis is at front'); |
222 | |
223 | my ($enum_handle, $first_zorder); |
224 | { my $force_PM = OS2::localMorphPM->new(0); |
225 | ok $force_PM, 'morphed to PM locally again'; |
226 | $enum_handle = BeginEnumWindows 1; # HWND_DESKTOP |
227 | ok $enum_handle, 'start enumeration'; |
228 | $first_zorder = GetNextWindow $enum_handle; |
229 | ok $first_zorder, 'GetNextWindow works'; |
230 | ok EndEnumWindows($enum_handle), 'end enumeration'; |
231 | } |
232 | is ($first_zorder, $k_hwnd, 'kid is the first in z-order enumeration'); |
233 | |
234 | ok hWindowPos_set({behind => 4}, $k_hwnd), # HWND_BOTTOM |
235 | 'put kid to the back'; |
236 | |
237 | # This does not work, the result is the handle of "Window List" |
238 | # is((hWindowPos $k_hwnd)->{behind}, 4, 'kis is at back'); |
239 | |
240 | my (@list, $next); |
241 | { my $force_PM = OS2::localMorphPM->new(0); |
242 | ok $force_PM, 'morphed to PM locally again'; |
243 | $enum_handle = BeginEnumWindows 1; # HWND_DESKTOP |
244 | ok $enum_handle, 'start enumeration'; |
245 | push @list, $next while $next = GetNextWindow $enum_handle; |
246 | ok EndEnumWindows($enum_handle), 'end enumeration'; |
247 | |
248 | # Apparently, the 'Desktop' window is still behind us; |
249 | # Note that this window is *not* what is returned by DesktopWindow |
250 | pop @list if WindowText($list[-1]) eq 'Desktop'; |
251 | } |
252 | is ($list[-1], $k_hwnd, 'kid is the last in z-order enumeration'); |
253 | # print "# kid=$k_hwnd in @list\n"; |
254 | @list = ChildWindows; # HWND_DESKTOP |
255 | ok scalar @list, 'ChildWindows works'; |
256 | is $list[-2], $k_hwnd, 'kid is the last but one in ChildWindows'; |
257 | |
258 | ok hWindowPos_set({behind => 3}, $k_hwnd), # HWND_TOP |
259 | 'put kid to the front again'; |
260 | |
261 | is((hWindowPos $k_hwnd)->{behind}, 3, 'kis is at front again'); |
262 | sleep 5 if $interactive_wait; |
263 | |
264 | ok IsWindow($k_hwnd), 'IsWindow works'; |
265 | #print "# win=$k_hwnd => err=$^E\n"; |
266 | my $c_sub_khwnd = WindowFromId $k_hwnd, 0x8008; # FID_CLIENT |
267 | ok $c_sub_khwnd, 'have kids client window'; |
268 | ok IsWindow($c_sub_khwnd), 'IsWindow works on the client'; |
269 | #print "# win=$c_sub_khwnd => IsWindow err=$^E\n"; |
270 | my ($pkid,$tkid) = WindowProcess $c_sub_khwnd; |
271 | my ($pkid1,$tkid1) = WindowProcess $hwnd; |
272 | ok($pkid1 > 0, 'our window has a governing process'); |
273 | ok($tkid1 > 0, 'our window has a governing thread'); |
274 | is($pkid, $pkid1, 'kid\'s window is governed by the same process as our (PMSHELL:1)'); |
275 | is($tkid, $tkid1, 'likewise for threads'); |
276 | is $pkid, ppidOf($spid), 'the governer is the parent of the kid session'; |
277 | |
278 | my $my_pos = hWindowPos($hwnd); |
279 | ok $my_pos, 'got my position'; |
280 | { my $force_PM = OS2::localMorphPM->new(0); |
281 | ok $force_PM, 'morphed to PM locally again'; |
282 | my @pos = WindowPos $hwnd; |
283 | my @ppos = WindowPos $k_hwnd; |
284 | # ok hWindowPos_set({%$my_pos, behind => $hwnd}, $k_hwnd), 'hide the kid behind us'; |
285 | # Hide it completely behind our window |
286 | ok hWindowPos_set({x => $my_pos->{x}, y => $my_pos->{y}, behind => $hwnd, |
287 | width => $my_pos->{width}, height => $my_pos->{height}}, |
288 | $k_hwnd), 'hide the kid behind us'; |
289 | # ok WindowPos_set($k_hwnd, $pos[0], $pos[1]), 'hide the kid behind us'; |
290 | my @kpos = WindowPos $k_hwnd; |
291 | # print "# kidpos=@ppos\n"; |
292 | # print "# mypos=@pos\n"; |
293 | # print "# kidpos=@kpos\n"; |
294 | # kidpos=252 630 4111 808 478 3 66518088 502482793 |
295 | # mypos=276 78 4111 491 149 2147484137 66518060 502532977 |
296 | # kidpos=276 78 4111 491 149 2147484255 1392374582 213000 |
297 | print "# Before window position\n" if $interactive_wait; |
298 | sleep 5 if $interactive_wait; |
299 | |
300 | my $w_at = WindowFromPoint($kpos[0] + 5, $kpos[0] + 5, 1, 0); # HWND_DESKTOP, no grandchildren |
301 | ok $w_at, 'got window near LL corner of the kid'; |
302 | print "# we=$hwnd, our client=$c_subhwnd, kid=$k_hwnd, kid's client=$c_sub_khwnd\n"; |
303 | #is $w_at, $c_sub_khwnd, 'it is the kids client'; |
304 | #is $w_at, $k_hwnd, 'it is the kids frame'; |
305 | # Apparently, this result is accidental only... |
306 | # is $w_at, $hwnd, 'it is our frame - is on top, but no focus'; |
307 | #is $w_at, $c_subhwnd, 'it is our client'; |
308 | print "# text: `", WindowText $w_at, "'.\n"; |
309 | $w_at = WindowFromPoint($kpos[0] + 5, $kpos[0] + 5); # HWND_DESKTOP, grandchildren too |
310 | ok $w_at, 'got grandkid window near LL corner of the kid'; |
311 | # Apparently, this result is accidental only... |
312 | # is $w_at, $c_subhwnd, 'it is our client'; |
313 | print "# text: `", WindowText $w_at, "'.\n"; |
314 | ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; |
315 | ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; |
316 | ok IsWindowShowing $hwnd, 'we are showing'; |
317 | ok ((not IsWindowShowing $k_hwnd), 'kid is not showing'); |
318 | ok ((not eval { IsWindowShowing 12; 1 }), 'wrong kid causes errors'); |
319 | is $^E+0, 0x1001, 'error is 0x1001'; |
320 | like $@, qr/\Q[Win]IsWindowShowing/, 'error message shows function'; |
321 | like $@, qr/SYS4097\b/, 'error message shows error number'; |
322 | like $@, qr/\b0x1001\b/, 'error message shows error number in hex'; |
323 | |
324 | ok WindowPos_set($k_hwnd, @ppos[0..5]), 'restore the kid position'; |
325 | my @nkpos = WindowPos $k_hwnd; |
326 | my $fl = $nkpos[2]; |
327 | is_deeply([@ppos[0..5]], [@nkpos[0..5]], 'position restored'); |
328 | ok IsWindowShowing $k_hwnd, 'kid is showing'; |
329 | ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; |
330 | ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; |
331 | sleep 5 if $interactive_wait; |
332 | ok EnableWindow($k_hwnd, 0), 'disable the kid'; |
333 | ok IsWindowShowing $k_hwnd, 'kid is showing'; |
334 | ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; |
335 | ok !IsWindowEnabled $k_hwnd, 'kid is flaged as not enabled'; |
336 | ok EnableWindow($k_hwnd), 'enable the kid'; |
337 | ok IsWindowShowing $k_hwnd, 'kid is showing'; |
338 | ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; |
339 | ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; |
340 | ok ShowWindow($k_hwnd, 0), 'hide the kid'; |
341 | ok !IsWindowShowing $k_hwnd, 'kid is not showing'; |
342 | ok !IsWindowVisible $k_hwnd, 'kid is flaged as not visible'; |
343 | ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; |
344 | ok ShowWindow($k_hwnd), 'show the kid'; |
345 | ok IsWindowShowing $k_hwnd, 'kid is showing'; |
346 | ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; |
347 | ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; |
348 | ok( ($fl & 0x1800), 'window is maximized or restored'); # SWP_MAXIMIZE SWP_RESTORE |
349 | ok( ($fl & 0x1800) != 0x1800, 'window is not maximized AND restored'); # SWP_MAXIMIZE SWP_RESTORE |
350 | |
351 | ok PostMsg( $k_hwnd, 0x21, # WM_SYSCOMMAND, SC_MINIMIZE |
352 | OS2::Process::MPFROMSHORT 0x8002), 'post minimize message'; |
353 | sleep 1; |
354 | ok !IsWindowShowing $k_hwnd, 'kid is not showing'; |
355 | ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; |
356 | ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; |
357 | is 0x1c00 & SWP_flags $k_hwnd, 0x400, 'kid is minimized'; # SWP_MINIMIZE |
358 | |
359 | ok PostMsg($k_hwnd, 0x21, # WM_SYSCOMMAND, SC_RESTORE |
360 | OS2::Process::MPFROMSHORT 0x8008), 'post restore message'; |
361 | sleep 1; |
362 | ok IsWindowShowing $k_hwnd, 'kid is showing'; |
363 | ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; |
364 | ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; |
365 | is 0x1c00 & SWP_flags $k_hwnd, 0x1000, 'kid is restored'; # SWP_RESTORE |
366 | |
367 | ok PostMsg($k_hwnd, 0x21, # WM_SYSCOMMAND, SC_MAXIMIZE |
368 | OS2::Process::MPFROMSHORT 0x8003), 'post maximize message'; |
369 | sleep 1; |
370 | ok IsWindowShowing $k_hwnd, 'kid is showing'; |
371 | ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; |
372 | ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; |
373 | is 0x1c00 & SWP_flags $k_hwnd, 0x800, 'kid is maximized'; # SWP_MAXIMIZE |
374 | |
375 | ok PostMsg( $k_hwnd, 0x21, # WM_SYSCOMMAND, SC_MINIMIZE |
376 | OS2::Process::MPFROMSHORT 0x8002), 'post minimize message again'; |
377 | sleep 1; |
378 | ok !IsWindowShowing $k_hwnd, 'kid is not showing'; |
379 | ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; |
380 | ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; |
381 | is 0x1c00 & SWP_flags $k_hwnd, 0x400, 'kid is minimized'; # SWP_MINIMIZE |
382 | |
383 | ok PostMsg($k_hwnd, 0x21, # WM_SYSCOMMAND, SC_RESTORE |
384 | OS2::Process::MPFROMSHORT 0x8008), 'post restore message again'; |
385 | sleep 1; |
386 | ok IsWindowShowing $k_hwnd, 'kid is showing'; |
387 | ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; |
388 | ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; |
389 | is 0x1c00 & SWP_flags $k_hwnd, 0x1000, 'kid is restored'; # SWP_RESTORE |
390 | |
391 | ok PostMsg( $k_hwnd, 0x21, # WM_SYSCOMMAND, SC_MINIMIZE |
392 | OS2::Process::MPFROMSHORT 0x8002), 'post minimize message again'; |
393 | sleep 1; |
394 | ok !IsWindowShowing $k_hwnd, 'kid is not showing'; |
395 | ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; |
396 | ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; |
397 | is 0x1c00 & SWP_flags $k_hwnd, 0x400, 'kid is minimized'; # SWP_MINIMIZE |
398 | |
399 | ok PostMsg($k_hwnd, 0x21, # WM_SYSCOMMAND, SC_RESTORE |
400 | OS2::Process::MPFROMSHORT (($fl & 0x800) ? 0x8003 : 0x8008)), # SWP_MAXIMIZE |
401 | 'return back to the initial MAXIMIZE/RESTORE state'; |
402 | sleep 1; |
403 | ok IsWindowShowing $k_hwnd, 'kid is showing'; |
404 | ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; |
405 | ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; |
406 | @nkpos = WindowPos $k_hwnd; |
407 | is_deeply([@ppos[0..5]], [@nkpos[0..5]], 'position restored'); |
408 | |
409 | # Now the other way |
410 | ok hWindowPos_set( {flags => 0x400}, $k_hwnd), 'set to minimized'; |
411 | ok !IsWindowShowing $k_hwnd, 'kid is not showing'; |
412 | ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; |
413 | ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; |
414 | is 0x1c00 & SWP_flags $k_hwnd, 0x400, 'kid is minimized'; # SWP_MINIMIZE |
415 | |
416 | ok hWindowPos_set( {flags => 0x1000}, $k_hwnd), 'set to restore'; |
417 | ok IsWindowShowing $k_hwnd, 'kid is showing'; |
418 | ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; |
419 | ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; |
420 | is 0x1c00 & SWP_flags $k_hwnd, 0x1000, 'kid is restored'; # SWP_RESTORE |
421 | |
422 | ok hWindowPos_set( {flags => 0x800}, $k_hwnd), 'set to maximized'; |
423 | ok IsWindowShowing $k_hwnd, 'kid is showing'; |
424 | ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; |
425 | ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; |
426 | is 0x1c00 & SWP_flags $k_hwnd, 0x800, 'kid is maximized'; # SWP_MAXIMIZE |
427 | |
428 | ok hWindowPos_set( {flags => 0x400}, $k_hwnd), 'set to minimized again'; |
429 | ok !IsWindowShowing $k_hwnd, 'kid is not showing'; |
430 | ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; |
431 | ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; |
432 | is 0x1c00 & SWP_flags $k_hwnd, 0x400, 'kid is minimized'; # SWP_MINIMIZE |
433 | |
434 | ok hWindowPos_set( {flags => 0x1000}, $k_hwnd), 'set to restore again'; |
435 | ok IsWindowShowing $k_hwnd, 'kid is showing'; |
436 | ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; |
437 | ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; |
438 | is 0x1c00 & SWP_flags $k_hwnd, 0x1000, 'kid is restored'; # SWP_RESTORE |
439 | |
440 | ok hWindowPos_set( {flags => 0x400}, $k_hwnd), 'set to minimized again'; |
441 | ok !IsWindowShowing $k_hwnd, 'kid is not showing'; |
442 | ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; |
443 | ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; |
444 | is 0x1c00 & SWP_flags $k_hwnd, 0x400, 'kid is minimized'; # SWP_MINIMIZE |
445 | |
446 | ok hWindowPos_set( {flags => ($fl & 0x1800)}, $k_hwnd), |
447 | 'set back to the initial MAXIMIZE/RESTORE state'; |
448 | ok IsWindowShowing $k_hwnd, 'kid is showing'; |
449 | ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; |
450 | ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; |
451 | @nkpos = WindowPos $k_hwnd; |
452 | is_deeply([@ppos[0..5]], [@nkpos[0..5]], 'position restored'); |
453 | |
454 | } |
455 | |
456 | # XXXX Well, no need to skip it now... |
457 | SKIP: { |
458 | skip 'We already have focus', 4 if $hwnd == $ahwnd; |
459 | my $force_PM = OS2::localMorphPM->new(0); |
460 | ok($force_PM, 'morphed to catch focus again'); |
461 | ok FocusWindow_set($c_subhwnd), 'set focus to the client of the session owner'; |
462 | # If we do not morph, then when the focus is in another VIO frame, |
463 | # we get two VIO frames with activated titlebars. |
464 | # The only (?) way to take the activated state from another frame |
465 | # is to switch to it via the switch list |
466 | $ahwnd = ActiveWindow; |
467 | ok($ahwnd, 'there is an active window'); |
468 | $fhwnd = FocusWindow; |
469 | ok($fhwnd, 'there is a focus window'); |
470 | is($hwnd, $ahwnd, 'the active window is the session owner'); |
471 | is($fhwnd, $c_subhwnd, 'the focus window is the client of the session owner'); |
472 | } |
473 | |
474 | SKIP: { |
475 | skip 'Potentially destructive session modifications, done in a separate session only', |
476 | 12, unless $separate_session; |
477 | # Manipulate process' hentry |
478 | my $he = process_hentry; |
479 | ok($he, 'got process hentry'); |
480 | ok($he->{visible}, 'session switch is visible');# 4? Assume nobody manipulated it... |
481 | |
482 | ok change_entryh($he), 'can change it (without modifications)'; |
483 | my $nhe = process_hentry; |
484 | ok $nhe, 'could refetch the process hentry'; |
485 | is_deeply($nhe, $he, 'it did not change'); |
486 | |
487 | sleep 5 if $interactive_wait; |
488 | # Try removing the process entry from the switch list |
489 | $nhe->{visible} = 0; |
490 | ok change_entryh($nhe), 'can change it to be invisible'; |
491 | my $nnhe = process_hentry; |
492 | ok($nnhe, 'could refetch the process hentry'); |
493 | is_deeply($nnhe, $nhe, 'it is modified as expected'); |
494 | is($nnhe->{visible}, 0, 'it is not visible'); |
495 | |
496 | sleep 5 if $interactive_wait; |
497 | |
498 | $nhe->{visible} = 1; |
499 | ok change_entryh ($nhe), 'can change it to be visible'; |
500 | $nnhe = process_hentry; |
501 | ok($nnhe, 'could refetch the process hentry'); |
502 | ok($nnhe->{visible}, 'it is visible'); |
503 | sleep 5 if $interactive_wait; |
504 | } |