qt: is my window overlapped by other? - winapi

I know some solution in WINAPI with enum all visible window to check intersect with my window...
But I need crossplatform solution for Qt (3 or 4 - no metter), maybe someone can help me with it?
Thanks.

To simply check if your window is active/has the keyboard focus you can check whether the Qt::WindowState is Qt::WindowActive.
To check your window for overlappings/intersections with other windows (I think that was your question) I can only think of using a little work-around.
The QWidget class has a function QWidget::visibleRegion() which returns a QRegion. Basically this region is the space in which paint-events can occur, that means that this is the space not covered by anything else. You can check whether the size of this region roughly matches the size of your window to see if there is any space covered by something else.
I didn't test this, so I can't tell you if it works for all platforms you need it to work on.
Edit: According to your comment:
This is what I found in the qt 4.6 reference about visibleRegion():
Returns the unobscured region where
paint events can occur. For visible
widgets, this is an approximation of
the area not covered by other widgets.
So if the size of this unobscured region is approximately the size of your window, then your window isn't covered by anything.

Related

Fullscreen borderless window with 'owned' window on-top

I have two OpenGL windows: a main one and a smaller one that is set to be 'owned' by the main one (hWndParent is set in CreateWindowEx, but the WS_CHILD style is not set).
If I then convert my main window to be borderless and the same size as my desktop it will jump in front of the smaller window even though it's owned and that should not be possible (https://msdn.microsoft.com/en-us/library/windows/desktop/ms632599%28v=vs.85%29.aspx#owned_windows). This is true even if the smaller window is set to be always-on-top.
On it's own this isn't terrible, but the core issue is that I can still click-through my main window on where the smaller window is, and the smaller window will pop infront. I can go between the two windows endlessly like this by clicking on the main window, then clicking-through the main window.
If I make the main window size 1 pixel less than the full desktop size, none of these issues occur and the windows behave is as expected.
I can't find any documentation that describes this behavior. It is a feature to keep windows from going infront of content (such as a video playing back) that isn't documented, or am I just missing it?
I'll mention I'm not using layered or transparent window here, so I don't think click-through should even be possible?
Thanks
What you experience may very well be a OpenGL implementation bug that's triggered by the heuristic in which the driver switched between "windowed" and "fullscreen" rendering: You see, for OpenGL there's no special "exclusive fullscreen mode" as Direct3D has. Instead a borderless window covering the whole screen, which is not overlapped by foreign windows may trigger a "fullscreen" detection, which may the OpenGL implementation in question make switch to another code path (namely one, where all pixel ownership tests are disabled and the framebuffer flips go directly to the display scanout, bypassing the windowing compositor.
What you do there is so uncommon, that it likely may have slipped through all conformance tests. Having child windows to a OpenGL window is uncommon in the first place and them being floating is even rarer.
If you've got a minimal example showcase, you should probably report it as a bug to the driver vendor. In the meantime I propose a workaround: Make your OpenGL window a child-window to your top level window (will of course require resizing in the toplevel WM_SIZE) and make your floating window another child to the toplevel; the z-order between childs in a parent window is respected and kept. Being a child to a toplevel window should inhibit most heuristics and OpenGL drivers should not loop at the border and size of OpenGL parent windows.

Drag and Drop in Windows Phone 7.1

Windows Phone 7.1 (Mang), SL4, VS 2010/Expression Blend.
I have a UI element (an ellipse) that I've added the behavior MouseDragElementBehavior to so now I can drag my ellipse all over my other elements. Great. What I can't figure out is how to determine where (what other UI element, specifically in this case a canvas) it was dropped on. Imagine a game board where you click and drag a piece from one square to another.
How can I determine if it's been "dropped" on another element?
The VisualTreeHelper class contains a method FindElementsInHostCoordinates to which you can pass the Point or Rect location of your Ellipse and then get all the Controls that exist in that location and act accordingly.
You might find the remarks section in FindElementsInHostCoordinates useful.
I think you can use that method no problem in basic scenarios. I used it for a while in one of my application's then I decided to use a manual method where I just loop over the controls and checking whether an intersection (or Point containment) occurs. Then just get the first control that is hit.
Please tell me if you have reached a better solution because I'm looking for ideas better than what I have already done! Thanks.

How to create an invisible X11 window for GPGPU?

Is it possible to create an invisible X window? For initialization of an OpenGL ES 2.0 context, one has to create a X window manually, but I can't find a way to make it invisible. Since I'm only doing GPGPU I don't need an output window. In fact, it is rather annoying in my case.
I'm aware of a solution from an earlier question, where it has been pointed out to use InputOnly in XCreateWindow(). This, however, leads to the X error GLXBadDrawable. Probably because EGL requires the window to respond to graphics request. Is there another way? Maybe create it minimized? But I can't find anything on that either. Also setting the window's size really small doesn't help, since it always occupies the whole screen on my device (Nokia N9).
When you create an X window, it is created unmapped, so what about creating an InputOutput window and leaving it unmapped? Another option would be (if the window must stay mapped), to move it out of the screen.

Updating the region behind a resized window

We have a fairly complex GUI, so when certain windows are resized their Redraw() is set to false till the operation is completed. The problem with this is that if the OS "Show window content while dragging" setting is checked, when decreasing the window's size the windows behind it are not repainted. This means I have to force the repaint myself so the remains of the resized window are deleted. I have no problem getting the dimensions of the region that was uncovered. What I'm looking for is best way to cause all windows within that region to repaint their part.
Not being much of a GUI programmer, I can traverse the uncovered region and list the windows in it. Then, I can ask each one of them to repaint its part. But I'm quite certain there has to be a better way to do this...
It is worth mentioning the app is written in PowerBuilder. This means I can call whatever Win32 function I'd like, but have limited control over the GUI behavior and the message handling. If there's a better way to prevent the window's content resize from being visible, or there's a way to make a non-redrawn window clean after itself, I'd love to hear it (just have the limitations above in mind).
I'm curious what version of PowerBuilder you are working in? I do resizing all the time and never run into issues like you are describing.
Maybe you can lay out some more detail on why you need to set your redraws to false within the PowerBuilder environment.
Hope I can help.

Placement of Qt4 widget on windows

How can I place a Qt4 widget just above the system tray on windows.
Since exact coordinates may depend on resolution and even the size and placement of the task bar(top or bottom of the screen etc.)?
I think there is probably a method for getting the screen resolution, but is there any method for getting the size of the taskbar and placement?
No, there isn't.
You can get the screen size using QDesktopWidget - this will give you the number of screens, screen size etc. However, finding the location of the task bar, and then the system tray is platform specific.
Why do you want to do this? Are you trying to emulate a QSystemTrayIcon? Perhaps if you told us what you're trying to do we may be able to help you.
Answering my own question, but apparently with Qt 4.3 I can get the coordinates of the tray icon using QSystemTrayIcon.geometry() method. So I can place my window relatively. It would be even better if I could get the position of the task bar but I guess I can figure out something for it.
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qsystemtrayicon.html#geometry

Resources