Skip to content
Advertisement

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?

Advertisement

Answer

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?

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement