How to detect fullscreen? - linux

Currently, I check if the window manager supports _NET_WM_STATE_FULLSCREEN. If it does then I use XGetWindowProperty to get array of atom's of _NET_WM_STATE. If it is the atom of _NET_WM_STATE_FULLSCREEN is found then i know it is fullscreen.
However on many windows, like the Desktop WM_NAME window, it doesn't have this atom. In fact doing doing _NET_WM_STATE fetch wit XGetWindowProperty fails, this i think is because the _NET_WM_STATE is removed when the window doesn't have focus? THe docs say its removed when window is unmapped.
I did test Desktops width and height using XGetWindowRect and I compared it to the screen width and height by using macros of WidthOfScreen and HeightOfScreen and desktop does match full screen width and height. What's up with the atom missing? Any sure fire way to detect full screen?
Thanks

Related

How to snap a window to top/bottom half of screen

One of my favorite features in Windows is the ability to snap windows. [1]
With Windows 10 they can now be snapped to quarter-screen, as well as the left- and right-half screen available in previous Windows releases.
Is it possible to snap a window to top and bottom half?
In other words, snap a window to span the width of the monitor, but only half the height? It could be snapped to either the top or bottom of the screen.
https://support.microsoft.com/en-us/help/4027324/windows-10-snap-your-windows
Unfortunately no, not natively. See e.g.: https://answers.microsoft.com/en-us/windows/forum/windows_10-desktop-winpc/snap-assist-to-top-and-bottom-in-portrait-mode/3ecdd25e-8886-4ef1-a7db-0d2e168ce381.
There are third-party solutions, such as https://www.displayfusion.com/Discussions/View/portrait-mode-and-windows-snapping/?ID=8e0ff0b8-5988-43d9-bd54-4567d7869f48 and https://www.nurgo-software.com/products/aquasnap
This is now natively supported in Windows 11. Press Windows+Z, then you can select where you want your window to be. There are several other portrait-only layouts too (the spot that is dark blue is the one my mouse is hovering over):
Not in the way that you snap windows to the left and right; if you try to snap a window to the top by dragging it to the top of your screen it will just maximize that window...and dragging to the bottom won't work at all.
One way that I can think of that will work is minimize 2 windows that you want to split and resize them both so that they span the width of the screen and approximately half the height of the screen. Then drag each window to the desired portion of the screen. To make things easier, you might want to have the window that you want on the bottom of the screen open over the one that you want on top of the screen before you start minimizing windows.

How to move window offscreen with wmctrl

I am trying to programmatically move a window so that it is partially on screen. For instance, clicking the VLC title bar and dragging it so that only half the window is visible works just fine.
When I output the results of wmctrl -lG this works just fine:
0x04a00011 0 -293 138 600 420 HEVM002 VLC media player
However, when I then move it back on screen and try and replicate its position, it doesn't work and clips the window to the far side:
wmctrl -r "VLC media player" -e 0,-200,0,800,600
I have tested on a couple of window managers, and it seems to work fine on xfwm but NOT on compiz. Is there a flag or something like that I can set to enable moving windows off-screen?
When running under a window manager, this is entirely up to the window manager. Whether there is a flag to force partial off-screen positions depends on which window manager it is.
The only window manager agnostic way of achieving this is making the window an override_redirect window. But, of course, this means the window is no longer managed. Making it a normal window again will cause the window manager to manage it again which likely, again depending on the window manager, means forcing it to be in-bounds again.
That said, looking at wmctrl's source code, it uses _NET_MOVERESIZE_WINDOW if supported by the window manager and falls back to XMoveResizeWindow (or similar) otherwise. However, in the first case it casts the position values to unsigned long first which effectively means any negative values will be lost anyway. In the second case, negative values seem to signal "don't move", so no luck there either.
You could try using xdotool windowmove instead which will deal with negative values correctly. Maybe also consider filing a bug against wmctrl?

Missing pixels from upper left of window placed at origin

I have an application that uses a non-decorated window (no title bar and so on, it's eventually intended to be a full-screen application). It also has one-pixel-wide line images around the outside to form a natural border with the outside world.
When I run this application and the Window gets its default position (i.e., not at the (0,0) origin), the borders are clearly visible.
However, when I perform a this.Move(0, 0) in the constructor of the main window to make sure the window is positioned correctly, the upper-right pixels seem to disappear thus:
Ignore the Act text in that capture, it's actually the Activities menu under Gnome desktop. The actual upper-left pixel of the window is where those two red lines would meet.
Does anyone know what could be causing this issue? Is it possibly something to do with the Gnome Shell extensions taking control of that area?
The missing pixels are an artifact of the way gnome-shell does rounded rectangles for its windows.
If you really want to change it, you can edit the file /usr/share/gnome-shell/theme/gnome-shell.css. Look for the CSS selector .panel-corner and set -panel-corner-radius to 0px. This will cause the windows to have square corners rather than rounded ones. You will probably need to restart gnome-shell after making the change by pressing Alt-F2 and enter the r command.
Whether that edit will survive a gnome-shell (or even a theme) update is unsure, you may have to put into place something that keeps it at the value you want (or install an extension to do that for you).
That is how gnome-shell renders the top corners of the main monitor, it's a rounded corner, just not very visible with black on black. Changing this rendering is not something an application should do.
If your application is supposed to be full screen instead of just positioned at the corner, you could request gnome-shell to do that with Window.fullscreen(). Do not rely on always being full screen though: the window manager can decide otherwise.

X11: frameless resizeable windows

Can I have a frameless but resizeable window in X?
Setting just MWM_DECOR_RESIZEH without the other flags doesn't make it resizeable.
I can resize it myself manually but then I need to scrape for themed mouse cursors which are non-standardized and are also different for each corner and side.
There are exactly two ways to resize windows:
Leave it to the window manager and be happy. This is recommended way for X. If someone don't like it, he can install another WM that will make it better.
Make it by yourself - draw border around window, track the mouse cursor and when the user drags the edges - resize the window in a way you like. In this case you must set the override-redirect flag of the window and WM will not mess with it.

Desktop effects (compiz) turned on: How to capture the image of a window WITH border/frame/title bar?

I would like to get the image of an X server Window (toplevel window, parent is the root Window) with its border/frame/title bar. I have already tried several libraries (Xlib, XRender, gdk, cairo) but none of them works. The captured image has the same geometry as the window but the frame is missing.
The problem is that the child window which should hold the frame image is InputOnly. The reason might be for this that the frame is rendered by the window decorator on the fly the same time as the Window itself.
I cannot capture the image from the RootWindow as the Window might be partially or entirely covered.
Redecorating the captured Window image could be an alternative.
Any suggestions? Thanks.
PS. When compiz is not running everything works as expected.
I use shutter for screen shots on linux, it's super easy to capture whatever portion of the screen you want. As a bonus, there are tools to add arrows or highlight sections.
http://shutter-project.org/preview/screenshots/

Resources