8 my $inc = $ENV{PERL5LIB};
9 $inc = $ENV{PERLLIB} unless defined $inc;
10 $inc = '' unless defined $inc;
11 $ENV{PERL5LIB} = join ';', @INC, split /;/, $inc;
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);
22 open $fh[$_], "$how[$_]&=$fn[$_]"
23 or warn "Cannot reopen $fh[$_], $how[$_]&=$fn[$_]: $!" for 0..1;
27 use Test::More tests => 235;
31 my @nkpos = WindowPos shift;
35 my $interactive_wait = @ARGV && $ARGV[0] eq 'wait';
37 my @l = OS2::Process::process_entry();
38 ok(@l == 11, 'all the fields of the process_entry() are there');
41 ok( ($l[9] == 1 or $l[9] == 2), 'we are FS or Windowed-VIO');
43 #print "# $_\n" for @l;
46 #use OS2::Process qw(WM_SYSCOMMAND WM_DBCSLAST FID_CLIENT HWND_DESKTOP);
47 use OS2::Process qw(WM_SYSCOMMAND WM_DBCSLAST HWND_DESKTOP);
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' );
59 ok($t, 'got session title');
60 ok($wint, 'got titlebar text');
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');
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');
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');
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');
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');
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');
110 my $ahwnd = ActiveWindow;
111 ok($ahwnd, 'found active window');
112 my $fhwnd = FocusWindow;
113 ok($fhwnd, 'found focus window');
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!)
118 # Interestingly, Desktop is active on the switch list, but the
119 # switch list is not acting on keyboard events.
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
126 my $dtop = DesktopWindow;
127 ok($dtop, 'found the desktop window');
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');
136 # XXXX Well, no need to skip it now...
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');
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
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');
166 # XXXX Well, no need to skip it now...
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');
179 # XXXX Well, no need to skip it now...
181 skip 'Tests assume we have focus', 1 unless $hwnd == $ahwnd;
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');
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');
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');
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';
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';
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');
218 ok hWindowPos_set({behind => 3}, $k_hwnd), # HWND_TOP
219 'put kid to the front';
221 # After Alt-Tab a WS_TOPMOST, WS_DISABLED window of class 'AltTabWindow' exists
222 my $top = (hWindowPos $k_hwnd)->{behind};
223 ok(($top == 3 or WindowStyle($top) & 0x200000), # HWND_TOP, WS_TOPMOST
225 # is((hWindowPos $k_hwnd)->{behind}, 3, 'kid is at front');
227 my ($enum_handle, $first_zorder, $first_non_TOPMOST);
228 { my $force_PM = OS2::localMorphPM->new(0);
229 ok $force_PM, 'morphed to PM locally again';
230 $enum_handle = BeginEnumWindows 1; # HWND_DESKTOP
231 ok $enum_handle, 'start enumeration';
232 $first_non_TOPMOST = $first_zorder = GetNextWindow $enum_handle;
233 ok $first_zorder, 'GetNextWindow works';
234 my $f = WindowStyle $first_non_TOPMOST;
235 ok $f, 'WindowStyle works';
236 $f = WindowStyle($first_non_TOPMOST = GetNextWindow $enum_handle)
237 while $f & 0x200000; # WS_TOPMOST
238 ok($first_non_TOPMOST, 'There is non-TOPMOST window');
239 ok(!(WindowStyle($first_non_TOPMOST) & 0x200000), 'Indeed non-TOPMOST');
240 ok EndEnumWindows($enum_handle), 'end enumeration';
242 is ($first_non_TOPMOST, $k_hwnd, 'kid is the first in z-order enumeration');
244 ok hWindowPos_set({behind => 4}, $k_hwnd), # HWND_BOTTOM
245 'put kid to the back';
247 # This does not work, the result is the handle of "Window List"
248 # is((hWindowPos $k_hwnd)->{behind}, 4, 'kis is at back');
250 my (@list, $next, @list1);
251 { my $force_PM = OS2::localMorphPM->new(0);
252 ok $force_PM, 'morphed to PM locally again';
253 $enum_handle = BeginEnumWindows 1; # HWND_DESKTOP
254 ok $enum_handle, 'start enumeration';
255 push @list, $next while $next = GetNextWindow $enum_handle;
256 @list1 = ChildWindows;
257 ok 1, 'embedded ChildWindows()';
258 ok EndEnumWindows($enum_handle), 'end enumeration';
260 is_deeply \@list, \@list1, 'Manual list same as by ChildWindows()';
261 # Apparently, the 'Desktop' window is still behind us;
262 # Note that this window is *not* what is returned by DesktopWindow
263 pop @list if WindowText($list[-1]) eq 'Desktop';
265 is ($list[-1], $k_hwnd, 'kid is the last in z-order enumeration');
266 # print "# kid=$k_hwnd in @list\n";
267 @list = ChildWindows;
268 is_deeply \@list, \@list1, 'Other ChildWindows(), same result';
269 ok scalar @list, 'ChildWindows works';
270 is $list[-2], $k_hwnd, 'kid is the last but one in ChildWindows';
272 ok hWindowPos_set({behind => 3}, $k_hwnd), # HWND_TOP
273 'put kid to the front again';
275 $top = (hWindowPos $k_hwnd)->{behind};
276 ok(($top == 3 or WindowStyle($top) & 0x200000), # WS_TOPMOST
277 'kid is at front again');
278 sleep 5 if $interactive_wait;
280 ok IsWindow($k_hwnd), 'IsWindow works';
281 #print "# win=$k_hwnd => err=$^E\n";
282 my $c_sub_khwnd = WindowFromId $k_hwnd, 0x8008; # FID_CLIENT
283 ok $c_sub_khwnd, 'have kids client window';
284 ok IsWindow($c_sub_khwnd), 'IsWindow works on the client';
285 #print "# win=$c_sub_khwnd => IsWindow err=$^E\n";
286 my ($pkid,$tkid) = WindowProcess $c_sub_khwnd;
287 my ($pkid1,$tkid1) = WindowProcess $hwnd;
288 ok($pkid1 > 0, 'our window has a governing process');
289 ok($tkid1 > 0, 'our window has a governing thread');
290 is($pkid, $pkid1, 'kid\'s window is governed by the same process as our (PMSHELL:1)');
291 is($tkid, $tkid1, 'likewise for threads');
292 is $pkid, ppidOf($spid), 'the governer is the parent of the kid session';
294 my $my_pos = hWindowPos($hwnd);
295 ok $my_pos, 'got my position';
296 { my $force_PM = OS2::localMorphPM->new(0);
297 ok $force_PM, 'morphed to PM locally again';
298 my @pos = WindowPos $hwnd;
299 my @ppos = WindowPos $k_hwnd;
300 # ok hWindowPos_set({%$my_pos, behind => $hwnd}, $k_hwnd), 'hide the kid behind us';
301 # Hide it completely behind our window
302 ok hWindowPos_set({x => $my_pos->{x}, y => $my_pos->{y}, behind => $hwnd,
303 width => $my_pos->{width}, height => $my_pos->{height}},
304 $k_hwnd), 'hide the kid behind us';
305 # ok WindowPos_set($k_hwnd, $pos[0], $pos[1]), 'hide the kid behind us';
306 my @kpos = WindowPos $k_hwnd;
307 # print "# kidpos=@ppos\n";
308 # print "# mypos=@pos\n";
309 # print "# kidpos=@kpos\n";
310 # kidpos=252 630 4111 808 478 3 66518088 502482793
311 # mypos=276 78 4111 491 149 2147484137 66518060 502532977
312 # kidpos=276 78 4111 491 149 2147484255 1392374582 213000
313 print "# Before window position\n" if $interactive_wait;
314 sleep 5 if $interactive_wait;
316 my $w_at = WindowFromPoint($kpos[0] + 5, $kpos[0] + 5, 1, 0); # HWND_DESKTOP, no grandchildren
317 ok $w_at, 'got window near LL corner of the kid';
318 print "# we=$hwnd, our client=$c_subhwnd, kid=$k_hwnd, kid's client=$c_sub_khwnd\n";
319 #is $w_at, $c_sub_khwnd, 'it is the kids client';
320 #is $w_at, $k_hwnd, 'it is the kids frame';
321 # Apparently, this result is accidental only...
322 # is $w_at, $hwnd, 'it is our frame - is on top, but no focus';
323 #is $w_at, $c_subhwnd, 'it is our client';
324 print "# text: `", WindowText $w_at, "'.\n";
325 $w_at = WindowFromPoint($kpos[0] + 5, $kpos[0] + 5); # HWND_DESKTOP, grandchildren too
326 ok $w_at, 'got grandkid window near LL corner of the kid';
327 # Apparently, this result is accidental only...
328 # is $w_at, $c_subhwnd, 'it is our client';
329 print "# text: `", WindowText $w_at, "'.\n";
330 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible';
331 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled';
332 ok IsWindowShowing $hwnd, 'we are showing';
333 ok ((not IsWindowShowing $k_hwnd), 'kid is not showing');
334 ok ((not eval { IsWindowShowing 12; 1 }), 'wrong kid causes errors');
335 is $^E+0, 0x1001, 'error is 0x1001';
336 like $@, qr/\Q[Win]IsWindowShowing/, 'error message shows function';
337 like $@, qr/SYS4097\b/, 'error message shows error number';
338 like $@, qr/\b0x1001\b/, 'error message shows error number in hex';
340 ok WindowPos_set($k_hwnd, @ppos[0..5]), 'restore the kid position';
341 my @nkpos = WindowPos $k_hwnd;
343 is_deeply([@ppos[0..5]], [@nkpos[0..5]], 'position restored');
344 ok IsWindowShowing $k_hwnd, 'kid is showing';
345 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible';
346 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled';
347 sleep 5 if $interactive_wait;
348 ok EnableWindow($k_hwnd, 0), 'disable the kid';
349 ok IsWindowShowing $k_hwnd, 'kid is showing';
350 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible';
351 ok !IsWindowEnabled $k_hwnd, 'kid is flaged as not enabled';
352 ok EnableWindow($k_hwnd), 'enable the kid';
353 ok IsWindowShowing $k_hwnd, 'kid is showing';
354 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible';
355 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled';
356 ok ShowWindow($k_hwnd, 0), 'hide the kid';
357 ok !IsWindowShowing $k_hwnd, 'kid is not showing';
358 ok !IsWindowVisible $k_hwnd, 'kid is flaged as not visible';
359 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled';
360 ok ShowWindow($k_hwnd), 'show the kid';
361 ok IsWindowShowing $k_hwnd, 'kid is showing';
362 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible';
363 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled';
364 ok( ($fl & 0x1800), 'window is maximized or restored'); # SWP_MAXIMIZE SWP_RESTORE
365 ok( ($fl & 0x1800) != 0x1800, 'window is not maximized AND restored'); # SWP_MAXIMIZE SWP_RESTORE
367 ok PostMsg( $k_hwnd, 0x21, # WM_SYSCOMMAND, SC_MINIMIZE
368 OS2::Process::MPFROMSHORT 0x8002), 'post minimize message';
370 ok !IsWindowShowing $k_hwnd, 'kid is not 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, 0x400, 'kid is minimized'; # SWP_MINIMIZE
375 ok PostMsg($k_hwnd, 0x21, # WM_SYSCOMMAND, SC_RESTORE
376 OS2::Process::MPFROMSHORT 0x8008), 'post restore message';
378 ok IsWindowShowing $k_hwnd, 'kid is 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, 0x1000, 'kid is restored'; # SWP_RESTORE
383 ok PostMsg($k_hwnd, 0x21, # WM_SYSCOMMAND, SC_MAXIMIZE
384 OS2::Process::MPFROMSHORT 0x8003), 'post maximize message';
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, 0x800, 'kid is maximized'; # SWP_MAXIMIZE
391 ok PostMsg( $k_hwnd, 0x21, # WM_SYSCOMMAND, SC_MINIMIZE
392 OS2::Process::MPFROMSHORT 0x8002), 'post minimize message again';
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
399 ok PostMsg($k_hwnd, 0x21, # WM_SYSCOMMAND, SC_RESTORE
400 OS2::Process::MPFROMSHORT 0x8008), 'post restore message again';
402 ok IsWindowShowing $k_hwnd, 'kid is showing';
403 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible';
404 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled';
405 is 0x1c00 & SWP_flags $k_hwnd, 0x1000, 'kid is restored'; # SWP_RESTORE
407 ok PostMsg( $k_hwnd, 0x21, # WM_SYSCOMMAND, SC_MINIMIZE
408 OS2::Process::MPFROMSHORT 0x8002), 'post minimize message again';
410 ok !IsWindowShowing $k_hwnd, 'kid is not showing';
411 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible';
412 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled';
413 is 0x1c00 & SWP_flags $k_hwnd, 0x400, 'kid is minimized'; # SWP_MINIMIZE
415 ok PostMsg($k_hwnd, 0x21, # WM_SYSCOMMAND, SC_RESTORE
416 OS2::Process::MPFROMSHORT (($fl & 0x800) ? 0x8003 : 0x8008)), # SWP_MAXIMIZE
417 'return back to the initial MAXIMIZE/RESTORE state';
419 ok IsWindowShowing $k_hwnd, 'kid is showing';
420 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible';
421 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled';
423 skip 'if defaultVIO=MAXIMIZED, new windows are shifted, but maximize to UL corner', 1 unless $fl & 0x800;
424 ok hWindowPos_set({x => $ppos[0], y => $ppos[1]}, $k_hwnd), 'x,y-restore for de-minimization of MAXIMIZED';
426 @nkpos = WindowPos $k_hwnd;
427 is_deeply([@ppos[0..5]], [@nkpos[0..5]], 'position restored');
431 ok hWindowPos_set( {flags => 0x400}, $k_hwnd), 'set to minimized';
432 ok !IsWindowShowing $k_hwnd, 'kid is not showing';
433 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible';
434 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled';
435 is 0x1c00 & SWP_flags $k_hwnd, 0x400, 'kid is minimized'; # SWP_MINIMIZE
437 ok hWindowPos_set( {flags => 0x1000}, $k_hwnd), 'set to restore';
438 ok IsWindowShowing $k_hwnd, 'kid is showing';
439 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible';
440 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled';
441 is 0x1c00 & SWP_flags $k_hwnd, 0x1000, 'kid is restored'; # SWP_RESTORE
443 ok hWindowPos_set( {flags => 0x800}, $k_hwnd), 'set to maximized';
444 ok IsWindowShowing $k_hwnd, 'kid is showing';
445 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible';
446 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled';
447 is 0x1c00 & SWP_flags $k_hwnd, 0x800, 'kid is maximized'; # SWP_MAXIMIZE
449 ok hWindowPos_set( {flags => 0x400}, $k_hwnd), 'set to minimized again';
450 ok !IsWindowShowing $k_hwnd, 'kid is not showing';
451 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible';
452 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled';
453 is 0x1c00 & SWP_flags $k_hwnd, 0x400, 'kid is minimized'; # SWP_MINIMIZE
455 ok hWindowPos_set( {flags => 0x1000}, $k_hwnd), 'set to restore again';
456 ok IsWindowShowing $k_hwnd, 'kid is showing';
457 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible';
458 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled';
459 is 0x1c00 & SWP_flags $k_hwnd, 0x1000, 'kid is restored'; # SWP_RESTORE
461 ok hWindowPos_set( {flags => 0x400}, $k_hwnd), 'set to minimized again';
462 ok !IsWindowShowing $k_hwnd, 'kid is not showing';
463 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible';
464 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled';
465 is 0x1c00 & SWP_flags $k_hwnd, 0x400, 'kid is minimized'; # SWP_MINIMIZE
467 ok hWindowPos_set( {flags => ($fl & 0x1800)}, $k_hwnd),
468 'set back to the initial MAXIMIZE/RESTORE state';
469 ok IsWindowShowing $k_hwnd, 'kid is showing';
470 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible';
471 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled';
473 skip 'if defaultVIO=MAXIMIZED, new windows are shifted, but maximize to UL corner', 1 unless $fl & 0x800;
474 ok hWindowPos_set({x => $ppos[0], y => $ppos[1]}, $k_hwnd), 'x,y-restore for de-minimization of MAXIMIZED';
476 @nkpos = WindowPos $k_hwnd;
477 is_deeply([@ppos[0..5]], [@nkpos[0..5]], 'position restored');
481 # XXXX Well, no need to skip it now...
483 skip 'We already have focus', 4 if $hwnd == $ahwnd;
484 my $force_PM = OS2::localMorphPM->new(0);
485 ok($force_PM, 'morphed to catch focus again');
486 ok FocusWindow_set($c_subhwnd), 'set focus to the client of the session owner';
487 # If we do not morph, then when the focus is in another VIO frame,
488 # we get two VIO frames with activated titlebars.
489 # The only (?) way to take the activated state from another frame
490 # is to switch to it via the switch list
491 $ahwnd = ActiveWindow;
492 ok($ahwnd, 'there is an active window');
493 $fhwnd = FocusWindow;
494 ok($fhwnd, 'there is a focus window');
495 is($hwnd, $ahwnd, 'the active window is the session owner');
496 is($fhwnd, $c_subhwnd, 'the focus window is the client of the session owner');
500 skip 'Potentially destructive session modifications, done in a separate session only',
501 12, unless $separate_session;
502 # Manipulate process' hentry
503 my $he = process_hentry;
504 ok($he, 'got process hentry');
505 ok($he->{visible}, 'session switch is visible');# 4? Assume nobody manipulated it...
507 ok change_entryh($he), 'can change it (without modifications)';
508 my $nhe = process_hentry;
509 ok $nhe, 'could refetch the process hentry';
510 is_deeply($nhe, $he, 'it did not change');
512 sleep 5 if $interactive_wait;
513 # Try removing the process entry from the switch list
515 ok change_entryh($nhe), 'can change it to be invisible';
516 my $nnhe = process_hentry;
517 ok($nnhe, 'could refetch the process hentry');
518 is_deeply($nnhe, $nhe, 'it is modified as expected');
519 is($nnhe->{visible}, 0, 'it is not visible');
521 sleep 5 if $interactive_wait;
524 ok change_entryh ($nhe), 'can change it to be visible';
525 $nnhe = process_hentry;
526 ok($nnhe, 'could refetch the process hentry');
527 ok($nnhe->{visible}, 'it is visible');
528 sleep 5 if $interactive_wait;