1#! /usr/bin/perl -w 2 3#END { 4# sleep 10; 5#} 6 7sub 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 14my $separate_session; 15BEGIN { # 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 26use strict; 27use Test::More tests => 232; 28use OS2::Process; 29 30sub SWP_flags ($) { 31 my @nkpos = WindowPos shift; 32 $nkpos[2]; 33} 34 35my $interactive_wait = @ARGV && $ARGV[0] eq 'wait'; 36 37my @l = OS2::Process::process_entry(); 38ok(@l == 11, 'all the fields of the process_entry() are there'); 39 40# 1: FS 2: Window-VIO 41ok( ($l[9] == 1 or $l[9] == 2), 'we are FS or Windowed-VIO'); 42 43#print "# $_\n" for @l; 44 45eval <<'EOE' or die; 46#use OS2::Process qw(WM_SYSCOMMAND WM_DBCSLAST FID_CLIENT HWND_DESKTOP); 47use OS2::Process qw(WM_SYSCOMMAND WM_DBCSLAST HWND_DESKTOP); 48 49ok( WM_SYSCOMMAND == 0x0021, 'correct WM_SYSCOMMAND' ); 50ok( WM_DBCSLAST == 0x00cf, 'correct WM_DBCSLAST' ); 51#ok( FID_CLIENT == 0x8008 ); 52ok( HWND_DESKTOP == 0x0001, 'correct HWND_DESKTOP' ); 531; 54EOE 55 56my $t = Title; 57my $wint = winTitle; 58 59ok($t, 'got session title'); 60ok($wint, 'got titlebar text'); 61 62my $newt = "test OS2::Process $$"; 63ok(Title_set($newt), 'successfully set Title'); 64is(Title, $newt, 'correctly set Title'); 65my $wt = winTitle or warn "winTitle: $!, $^E"; 66is(winTitle, $newt, 'winTitle changed its value too'); 67ok(Title_set $t, 'successfully set Title back'); 68is(Title, $t, 'correctly set Title back'); 69is(winTitle, $wint, 'winTitle restored its value too'); 70 71$newt = "test OS2::Process both-$$"; 72ok(bothTitle_set($newt), 'successfully set both titles via Win* API'); 73is(Title, $newt, 'session title correctly set'); 74is(winTitle, $newt, 'winTitle correctly set'); 75ok(bothTitle_set($t), 'successfully reset both titles via Win* API'); 76is(Title, $t, 'session title correctly reset'); 77is(winTitle, $wint, 'winTitle correctly reset'); 78 79$newt = "test OS2::Process win-$$"; 80ok(winTitle_set($newt), 'successfully set titlebar title via Win* API'); 81is(Title, $t, 'session title remained the same'); 82is(winTitle, $newt, 'winTitle changed value'); 83ok(winTitle_set($wint), 'successfully reset titlebar title via Win* API'); 84is(Title, $t, 'session title remained the same'); 85is(winTitle, $wint, 'winTitle restored value'); 86 87$newt = "test OS2::Process sw-$$"; 88ok(swTitle_set($newt), 'successfully set session title via Win* API'); 89is(Title, $newt, 'session title correctly set'); 90is(winTitle, $wint, 'winTitle has unchanged value'); 91ok(swTitle_set($t), 'successfully reset session title via Win* API'); 92is(Title, $t, 'session title correctly set'); 93is(winTitle, $wint, 'winTitle has unchanged value'); 94 95$newt = "test OS2::Process again-$$"; 96ok(Title_set($newt), 'successfully set Title again'); 97is(Title, $newt, 'correctly set Title again'); 98is(winTitle, $newt, 'winTitle changed its value too again'); 99ok(Title_set($t), 'successfully set Title back'); 100is(Title, $t, 'correctly set Title back'); 101is(winTitle, $wint, 'winTitle restored its value too again'); 102 103my $hwnd = process_hwnd; 104ok($hwnd, 'found session owner hwnd'); 105my $c_subhwnd = WindowFromId $hwnd, 0x8008; # FID_CLIENT; 106ok($c_subhwnd, 'found client hwnd'); 107my $a_subhwnd = ActiveWindow $hwnd; # or $^E and warn $^E; 108ok((not $a_subhwnd and not $^E), 'No active subwindow in a VIO frame'); 109 110my $ahwnd = ActiveWindow; 111ok($ahwnd, 'found active window'); 112my $fhwnd = FocusWindow; 113ok($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} 126my $dtop = DesktopWindow; 127ok($dtop, 'found the desktop window'); 128 129#OS2::Process::ResetWinError; # XXXX Should not be needed! 130$ahwnd = ActiveWindow or $^E and warn $^E; 131ok( (not $ahwnd and not $^E), 'desktop is not active'); 132$fhwnd = FocusWindow; 133ok($fhwnd, 'there is a focus window'); 134is($fhwnd, $dtop, 'which is the desktop'); 135 136# XXXX Well, no need to skip it now... 137SKIP: { 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; 161ok( (not $ahwnd and not $^E), 'desktop is not active again'); 162$fhwnd = FocusWindow; 163ok($fhwnd, 'there is a focus window'); 164is($fhwnd, $dtop, 'which is the desktop'); 165 166# XXXX Well, no need to skip it now... 167SKIP: { 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... 180SKIP: { 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: 189my $skid_title = "temporary s-kid ppid=$$"; 190my $spid = system P_SESSION, $^X, '-wle', "END {sleep 25} use OS2::Process; eval {Title_set '$skid_title'} or warn \$@; \$SIG{TERM} = sub {exit 0}"; 191ok ($spid, 'start the new VIO session with unique title'); 192sleep 1; 193my @sw = grep $_->{title} eq $skid_title, process_hentries; 194sleep 1000 unless @sw; 195is(scalar @sw, 1, 'exactly one session with this title'); 196my $sw = $sw[0]; 197ok $sw, 'have the data about the session'; 198is($sw->{owner_pid}, $spid, 'session has a correct pid'); 199my $k_hwnd = $sw->{owner_hwnd}; 200ok $k_hwnd, 'found the session window handle'; 201is 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; 210ok $ahwnd, 'there is an active window'; 211is $ahwnd, $k_hwnd, 'after focusing the active window is the owner_hwnd'; 212$fhwnd = FocusWindow; 213ok $fhwnd, 'there is a focus window'; 214my $c_sub_ahwnd = WindowFromId $ahwnd, 0x8008; # FID_CLIENT; 215ok $c_sub_ahwnd, 'the active window has a FID_CLIENT'; 216is($fhwnd, $ahwnd, 'the focus window = the active window'); 217 218ok hWindowPos_set({behind => 3}, $k_hwnd), # HWND_TOP 219 'put kid to the front'; 220 221is((hWindowPos $k_hwnd)->{behind}, 3, 'kis is at front'); 222 223my ($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} 232is ($first_zorder, $k_hwnd, 'kid is the first in z-order enumeration'); 233 234ok 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 240my (@list, $next, @list1); 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 @list1 = ChildWindows; 247 ok 1, 'embedded ChildWindows()'; 248 ok EndEnumWindows($enum_handle), 'end enumeration'; 249 250 is_deeply \@list, \@list1, 'Manual list same as by ChildWindows()'; 251 # Apparently, the 'Desktop' window is still behind us; 252 # Note that this window is *not* what is returned by DesktopWindow 253 pop @list if WindowText($list[-1]) eq 'Desktop'; 254} 255is ($list[-1], $k_hwnd, 'kid is the last in z-order enumeration'); 256# print "# kid=$k_hwnd in @list\n"; 257@list = ChildWindows; 258is_deeply \@list, \@list1, 'Other ChildWindows(), same result'; 259ok scalar @list, 'ChildWindows works'; 260is $list[-2], $k_hwnd, 'kid is the last but one in ChildWindows'; 261 262ok hWindowPos_set({behind => 3}, $k_hwnd), # HWND_TOP 263 'put kid to the front again'; 264 265is((hWindowPos $k_hwnd)->{behind}, 3, 'kis is at front again'); 266sleep 5 if $interactive_wait; 267 268ok IsWindow($k_hwnd), 'IsWindow works'; 269#print "# win=$k_hwnd => err=$^E\n"; 270my $c_sub_khwnd = WindowFromId $k_hwnd, 0x8008; # FID_CLIENT 271ok $c_sub_khwnd, 'have kids client window'; 272ok IsWindow($c_sub_khwnd), 'IsWindow works on the client'; 273#print "# win=$c_sub_khwnd => IsWindow err=$^E\n"; 274my ($pkid,$tkid) = WindowProcess $c_sub_khwnd; 275my ($pkid1,$tkid1) = WindowProcess $hwnd; 276ok($pkid1 > 0, 'our window has a governing process'); 277ok($tkid1 > 0, 'our window has a governing thread'); 278is($pkid, $pkid1, 'kid\'s window is governed by the same process as our (PMSHELL:1)'); 279is($tkid, $tkid1, 'likewise for threads'); 280is $pkid, ppidOf($spid), 'the governer is the parent of the kid session'; 281 282my $my_pos = hWindowPos($hwnd); 283ok $my_pos, 'got my position'; 284{ my $force_PM = OS2::localMorphPM->new(0); 285 ok $force_PM, 'morphed to PM locally again'; 286 my @pos = WindowPos $hwnd; 287 my @ppos = WindowPos $k_hwnd; 288 # ok hWindowPos_set({%$my_pos, behind => $hwnd}, $k_hwnd), 'hide the kid behind us'; 289 # Hide it completely behind our window 290 ok hWindowPos_set({x => $my_pos->{x}, y => $my_pos->{y}, behind => $hwnd, 291 width => $my_pos->{width}, height => $my_pos->{height}}, 292 $k_hwnd), 'hide the kid behind us'; 293 # ok WindowPos_set($k_hwnd, $pos[0], $pos[1]), 'hide the kid behind us'; 294 my @kpos = WindowPos $k_hwnd; 295 # print "# kidpos=@ppos\n"; 296 # print "# mypos=@pos\n"; 297 # print "# kidpos=@kpos\n"; 298# kidpos=252 630 4111 808 478 3 66518088 502482793 299# mypos=276 78 4111 491 149 2147484137 66518060 502532977 300# kidpos=276 78 4111 491 149 2147484255 1392374582 213000 301 print "# Before window position\n" if $interactive_wait; 302 sleep 5 if $interactive_wait; 303 304 my $w_at = WindowFromPoint($kpos[0] + 5, $kpos[0] + 5, 1, 0); # HWND_DESKTOP, no grandchildren 305 ok $w_at, 'got window near LL corner of the kid'; 306 print "# we=$hwnd, our client=$c_subhwnd, kid=$k_hwnd, kid's client=$c_sub_khwnd\n"; 307 #is $w_at, $c_sub_khwnd, 'it is the kids client'; 308 #is $w_at, $k_hwnd, 'it is the kids frame'; 309 # Apparently, this result is accidental only... 310# is $w_at, $hwnd, 'it is our frame - is on top, but no focus'; 311 #is $w_at, $c_subhwnd, 'it is our client'; 312 print "# text: `", WindowText $w_at, "'.\n"; 313 $w_at = WindowFromPoint($kpos[0] + 5, $kpos[0] + 5); # HWND_DESKTOP, grandchildren too 314 ok $w_at, 'got grandkid window near LL corner of the kid'; 315 # Apparently, this result is accidental only... 316# is $w_at, $c_subhwnd, 'it is our client'; 317 print "# text: `", WindowText $w_at, "'.\n"; 318 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; 319 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; 320 ok IsWindowShowing $hwnd, 'we are showing'; 321 ok ((not IsWindowShowing $k_hwnd), 'kid is not showing'); 322 ok ((not eval { IsWindowShowing 12; 1 }), 'wrong kid causes errors'); 323 is $^E+0, 0x1001, 'error is 0x1001'; 324 like $@, qr/\Q[Win]IsWindowShowing/, 'error message shows function'; 325 like $@, qr/SYS4097\b/, 'error message shows error number'; 326 like $@, qr/\b0x1001\b/, 'error message shows error number in hex'; 327 328 ok WindowPos_set($k_hwnd, @ppos[0..5]), 'restore the kid position'; 329 my @nkpos = WindowPos $k_hwnd; 330 my $fl = $nkpos[2]; 331 is_deeply([@ppos[0..5]], [@nkpos[0..5]], 'position restored'); 332 ok IsWindowShowing $k_hwnd, 'kid is showing'; 333 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; 334 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; 335 sleep 5 if $interactive_wait; 336 ok EnableWindow($k_hwnd, 0), 'disable 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 not enabled'; 340 ok EnableWindow($k_hwnd), 'enable the kid'; 341 ok IsWindowShowing $k_hwnd, 'kid is showing'; 342 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; 343 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; 344 ok ShowWindow($k_hwnd, 0), 'hide the kid'; 345 ok !IsWindowShowing $k_hwnd, 'kid is not showing'; 346 ok !IsWindowVisible $k_hwnd, 'kid is flaged as not visible'; 347 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; 348 ok ShowWindow($k_hwnd), 'show 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 enabled'; 352 ok( ($fl & 0x1800), 'window is maximized or restored'); # SWP_MAXIMIZE SWP_RESTORE 353 ok( ($fl & 0x1800) != 0x1800, 'window is not maximized AND restored'); # SWP_MAXIMIZE SWP_RESTORE 354 355 ok PostMsg( $k_hwnd, 0x21, # WM_SYSCOMMAND, SC_MINIMIZE 356 OS2::Process::MPFROMSHORT 0x8002), 'post minimize message'; 357 sleep 1; 358 ok !IsWindowShowing $k_hwnd, 'kid is not showing'; 359 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; 360 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; 361 is 0x1c00 & SWP_flags $k_hwnd, 0x400, 'kid is minimized'; # SWP_MINIMIZE 362 363 ok PostMsg($k_hwnd, 0x21, # WM_SYSCOMMAND, SC_RESTORE 364 OS2::Process::MPFROMSHORT 0x8008), 'post restore message'; 365 sleep 1; 366 ok IsWindowShowing $k_hwnd, 'kid is showing'; 367 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; 368 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; 369 is 0x1c00 & SWP_flags $k_hwnd, 0x1000, 'kid is restored'; # SWP_RESTORE 370 371 ok PostMsg($k_hwnd, 0x21, # WM_SYSCOMMAND, SC_MAXIMIZE 372 OS2::Process::MPFROMSHORT 0x8003), 'post maximize message'; 373 sleep 1; 374 ok IsWindowShowing $k_hwnd, 'kid is showing'; 375 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; 376 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; 377 is 0x1c00 & SWP_flags $k_hwnd, 0x800, 'kid is maximized'; # SWP_MAXIMIZE 378 379 ok PostMsg( $k_hwnd, 0x21, # WM_SYSCOMMAND, SC_MINIMIZE 380 OS2::Process::MPFROMSHORT 0x8002), 'post minimize message again'; 381 sleep 1; 382 ok !IsWindowShowing $k_hwnd, 'kid is not showing'; 383 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; 384 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; 385 is 0x1c00 & SWP_flags $k_hwnd, 0x400, 'kid is minimized'; # SWP_MINIMIZE 386 387 ok PostMsg($k_hwnd, 0x21, # WM_SYSCOMMAND, SC_RESTORE 388 OS2::Process::MPFROMSHORT 0x8008), 'post restore message again'; 389 sleep 1; 390 ok IsWindowShowing $k_hwnd, 'kid is showing'; 391 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; 392 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; 393 is 0x1c00 & SWP_flags $k_hwnd, 0x1000, 'kid is restored'; # SWP_RESTORE 394 395 ok PostMsg( $k_hwnd, 0x21, # WM_SYSCOMMAND, SC_MINIMIZE 396 OS2::Process::MPFROMSHORT 0x8002), 'post minimize message again'; 397 sleep 1; 398 ok !IsWindowShowing $k_hwnd, 'kid is not showing'; 399 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; 400 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; 401 is 0x1c00 & SWP_flags $k_hwnd, 0x400, 'kid is minimized'; # SWP_MINIMIZE 402 403 ok PostMsg($k_hwnd, 0x21, # WM_SYSCOMMAND, SC_RESTORE 404 OS2::Process::MPFROMSHORT (($fl & 0x800) ? 0x8003 : 0x8008)), # SWP_MAXIMIZE 405 'return back to the initial MAXIMIZE/RESTORE state'; 406 sleep 1; 407 ok IsWindowShowing $k_hwnd, 'kid is showing'; 408 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; 409 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; 410 SKIP: { 411 skip 'if defaultVIO=MAXIMIZED, new windows are shifted, but maximize to UL corner', 1 unless $fl & 0x800; 412 ok hWindowPos_set({x => $ppos[0], y => $ppos[1]}, $k_hwnd), 'x,y-restore for de-minimization of MAXIMIZED'; 413 } 414 @nkpos = WindowPos $k_hwnd; 415 is_deeply([@ppos[0..5]], [@nkpos[0..5]], 'position restored'); 416 417 418 # Now the other way 419 ok hWindowPos_set( {flags => 0x400}, $k_hwnd), 'set to minimized'; 420 ok !IsWindowShowing $k_hwnd, 'kid is not showing'; 421 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; 422 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; 423 is 0x1c00 & SWP_flags $k_hwnd, 0x400, 'kid is minimized'; # SWP_MINIMIZE 424 425 ok hWindowPos_set( {flags => 0x1000}, $k_hwnd), 'set to restore'; 426 ok IsWindowShowing $k_hwnd, 'kid is showing'; 427 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; 428 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; 429 is 0x1c00 & SWP_flags $k_hwnd, 0x1000, 'kid is restored'; # SWP_RESTORE 430 431 ok hWindowPos_set( {flags => 0x800}, $k_hwnd), 'set to maximized'; 432 ok IsWindowShowing $k_hwnd, 'kid is 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, 0x800, 'kid is maximized'; # SWP_MAXIMIZE 436 437 ok hWindowPos_set( {flags => 0x400}, $k_hwnd), 'set to minimized again'; 438 ok !IsWindowShowing $k_hwnd, 'kid is not 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, 0x400, 'kid is minimized'; # SWP_MINIMIZE 442 443 ok hWindowPos_set( {flags => 0x1000}, $k_hwnd), 'set to restore again'; 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, 0x1000, 'kid is restored'; # SWP_RESTORE 448 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 454 455 ok hWindowPos_set( {flags => ($fl & 0x1800)}, $k_hwnd), 456 'set back to the initial MAXIMIZE/RESTORE state'; 457 ok IsWindowShowing $k_hwnd, 'kid is showing'; 458 ok IsWindowVisible $k_hwnd, 'kid is flaged as visible'; 459 ok IsWindowEnabled $k_hwnd, 'kid is flaged as enabled'; 460 SKIP: { 461 skip 'if defaultVIO=MAXIMIZED, new windows are shifted, but maximize to UL corner', 1 unless $fl & 0x800; 462 ok hWindowPos_set({x => $ppos[0], y => $ppos[1]}, $k_hwnd), 'x,y-restore for de-minimization of MAXIMIZED'; 463 } 464 @nkpos = WindowPos $k_hwnd; 465 is_deeply([@ppos[0..5]], [@nkpos[0..5]], 'position restored'); 466 467} 468 469# XXXX Well, no need to skip it now... 470SKIP: { 471 skip 'We already have focus', 4 if $hwnd == $ahwnd; 472 my $force_PM = OS2::localMorphPM->new(0); 473 ok($force_PM, 'morphed to catch focus again'); 474 ok FocusWindow_set($c_subhwnd), 'set focus to the client of the session owner'; 475 # If we do not morph, then when the focus is in another VIO frame, 476 # we get two VIO frames with activated titlebars. 477 # The only (?) way to take the activated state from another frame 478 # is to switch to it via the switch list 479 $ahwnd = ActiveWindow; 480 ok($ahwnd, 'there is an active window'); 481 $fhwnd = FocusWindow; 482 ok($fhwnd, 'there is a focus window'); 483 is($hwnd, $ahwnd, 'the active window is the session owner'); 484 is($fhwnd, $c_subhwnd, 'the focus window is the client of the session owner'); 485} 486 487SKIP: { 488 skip 'Potentially destructive session modifications, done in a separate session only', 489 12, unless $separate_session; 490 # Manipulate process' hentry 491 my $he = process_hentry; 492 ok($he, 'got process hentry'); 493 ok($he->{visible}, 'session switch is visible');# 4? Assume nobody manipulated it... 494 495 ok change_entryh($he), 'can change it (without modifications)'; 496 my $nhe = process_hentry; 497 ok $nhe, 'could refetch the process hentry'; 498 is_deeply($nhe, $he, 'it did not change'); 499 500 sleep 5 if $interactive_wait; 501 # Try removing the process entry from the switch list 502 $nhe->{visible} = 0; 503 ok change_entryh($nhe), 'can change it to be invisible'; 504 my $nnhe = process_hentry; 505 ok($nnhe, 'could refetch the process hentry'); 506 is_deeply($nnhe, $nhe, 'it is modified as expected'); 507 is($nnhe->{visible}, 0, 'it is not visible'); 508 509 sleep 5 if $interactive_wait; 510 511 $nhe->{visible} = 1; 512 ok change_entryh ($nhe), 'can change it to be visible'; 513 $nnhe = process_hentry; 514 ok($nnhe, 'could refetch the process hentry'); 515 ok($nnhe->{visible}, 'it is visible'); 516 sleep 5 if $interactive_wait; 517} 518