Gambas India Forum

Forum breadcrumbs - You are here:ForumRepository: Source CodesWindow method

Window method

Do you like this program?

There's still a problem on 'overlapping' windows when trying to select a window. Below is shown a bit of my original post about it and your response:

IMO a window should be selectable even if it is overlapped by another window provided that the overlap area is not clicked on: does that coding achieve that? I've been wondering if the Shaded property of the Desktop window object has anything to do with a window which is overlapped.

If Mouse.ScreenX > hWindow.X - 20 And Mouse.ScreenX < hWindow.X + hWindow.Width And Mouse.ScreenY > hWindow.Y - 20 And Mouse.ScreenY < hWindow.Y + hWindow.Height Then
Shell "wmctrl -a " & hWindow.Name
The first line detects if the hWindow is in the area that was 'Clicked' on. The 2nd line uses 'wmctrl' to 'Raise' the window. In Terminal type man wmctrl for more help.

When I run the stripped down app, with 2 Nautilus windows having an overlapping area with the second being 'on top' of the first one (see attached screenshot), the app [highlight=]always[/highlight] selects the first as shown by the console's output:

DesktopWindow: Name=Gambas VisibleName=Gambas Hex(i)=3800007 .Id=58720263 Left=32 Top=10 Width=936 Height=596 DesktopWindow: Name=Temporary VisibleName=Temporary Hex(i)=380E68B .Id=58779275 Left=70 Top=338 Width=861 Height=596 DesktopWindow: Name=FSelectWindow.class - SelectWindow-CO-JR 0.0.31 - Gambas 3 VisibleName=FSelect Window.class - SelectWindow-CO-JR 0.0.31 - Gambas 3 Hex(i)=420000E .Id=69206030 Left=950 Top=114 Width=944 Height=864 Selected Window: Name=Gambas, VisibleName=Gambas Geometry=32, 10, 936, 596

Obviously I've miscommunicated what I want. I want, when the user selects an overlapping area, the app to select the window which is 'on top'. The above coding you quoted selects the first window found by the app's Find Window method. This is why I wondered if the Shaded property could be used. Running wmctrl (in Terminal) doesn't explain the Shaded property. Even if the Shaded property determines if a window is partially overlapped, the app would still have to determine if the user clicked inside the overlapping area or in the window not on top! It looks like each window will have to be examined against the other windows to see if there is an overlap which the user has clicked on. More complexity!

So ACTIVE might be useful though Shaded perhaps is not. My gut feeling is that wmctrl usage is a red herring and I will have to make the Gambas coding more complex as I indicated earlier.

A minor point. Your If statement above is very long. I dislike long coding lines and prefer to split them over multiple lines. In VB it used to be possible to split a coding command over 2 lines by use of the _ character (a space or more) at the end of a line. I've tried this in Gambas but the compiler rejects it. I've looked in the Gambas books you referred to previously as well as the Gambas wiki and haven't found any mention of it. Do you know how to split a coding line (n this case, apart from having another If to replace the And)?

BTW what is the significance of 20 pixels in your coding (e.g. is it the height of the Title bar of a window)?


Overlapping Area Screenshot.png