Linux can move windows

Move Window Linux C

i’d like to make a function that can move a window in Linux in C++ by its PID. So I’ve tryed in under Windows. But I have trouble to compile it for Linux. Is there any mean to do it with Qt ? Since I haven’t found one, I’ve tryed to compile for Linux. I’m using the MoveWindow function, which is part of the Windows API. Is there any Linux equivalent ?

1 Answer 1

You don’t have to do that by hand if you don’t really want to as there already are lots of tools out there, that can perform such tasks as moving, resizing, maximizing and whatever windows.

One tool you might want to take a closer look upon goes by the name of wmctrl even if you don’t intend to use maybe you’ll find some interesting tricks by taking a look into the sources.

The task of moving a window only known by the pid of the client that created the window might not be the easiest tasks of all for a couple of reasons.

  • First of all you really shouldn’t try to do this as in the X Windows philosophy it is the job of the window manager to arrange the windows on the screen. As well ICCCM (see: http://de.wikipedia.org/wiki/Inter-Client_Communication_Conventions_Manual) as the EWM spec (see: http://standards.freedesktop.org/wm-spec/wm-spec-latest.html) strongly discourage any client from trying to move resize or whatever on its own. Most probably moving windows «owned» by another client might be considered even bigger evil.
  • The second problem you might face is, that the X 11 protocol doesn’t have any notion of pid. As it was designed to be used over a network you never can’t be really sure the program runs on the same machine as the one you are currently sitting in front of. As such there isn’t much sense in something like a pid as by chance there might be any number of clients with identical pids displaying windows on the same X Server if they ran on different machines.

Fortunately enough it is not all that bad, as the EWMH spec encourages any client to set the _NET_WM_PID property on its top level window the the pid of the client that created the window.

Читайте также:  Astra linux перезапуск сетевого интерфейса

Again adhering to the EWMH spec isn’t enforced by the X Server in any way so that while practically propably almost all clients will set it there’s still no guarantee you’ll find the window belonging to a specific pid.

Possibilities

While the whole points mentioned until here might seem rather limiting in fact most probably rather the opposite is true. Even because practically it is relatively easy to totally mess up any other client running in an X session the whole set of rules about how to be a good citizen in the X word were introduced.

As the X11 protocol itself is a network protocol (well not 100% true as locally running clients most probably will be communicating with the X Server via a UNIX domain socket) there isn’t any specific library required to talk to the X Server.

Talking about C as mentioned in your question the Xlib has long been the one and only one implementation in wide use but there’s also another binding called xcb. With a slightly changed API in comparison to the Xlib.

Xlib

Speaking Xlib I’ve never ever used any xcb until now, so I can’t tell you too much about it might be the following methods that might be of use.

  • XOpenDisplay — open connection to the X server
  • XQueryTree — aquire the tree of windows currently alive on the server
  • XInternAtom — no fear it isn’t dangerous. Just read about it in the manuals as you’ll need it the get the «atom» mapping to _NET_WM_PID mentioned above
  • XListProperties — search for the _NET_WM_PID property with the value you are looking for
  • XConfigureWindow, XMoveWindow, XResizeWindow, . — to finally perform whatever you wish to do.

All functions mentioned above should be documented in the manual pages. Just use man XOpenDisplay for example.

Oh, and be sure to learn about all the other tools at your disposal to further investigate about the X Window world. Run xlsatoms , check what xwininfo reports an take a list at the output of xprop for one single (!) window alone. Try to set some yourself to see what happens xprop will even do that for you if you ask politely.

Читайте также:  Увеличить размер шрифта линукс

Источник

How to move a window to another workspace in Xfce?

The shortcut for «move windows to another workspace» in Xfce should be Ctrl + Alt + Shift + ← / → / ↑ / ↓ . But it doesn’t work, there’re no such shortcuts. Why, am I missing anything?

OP never returned since 2016 to this date, but I just found an older screenshot as proof that Xfce had no such *shortcuts from before. See updated answer at below.

4 Answers 4

There isn’t any. By default, the action «Move window to left/right/up/down workspace» has no shortcuts set and that has not changed since Xfce 4.6 to this date. So the shortcuts might have been deprecated earlier or not adopted at all.

But there should be

Those ‘old’ shortcuts were originally found in GNOME; the original author of this answer was aware of this, because they had been using GNOME 2 before switching to Xfce. The oldest known proof is shown by the screenshot with additional highlight as follows.

xfwm4 fill operation with additional highlight on unset move window shortcuts

Source: Xfce 4.6 tour, screenshots by Jannis Pohlmann. The original screenshot was used to describe «fill operation» for xfwm4, which luckily showing the unset window shortcuts.

Revive them anyway

To define shortcuts for the action «Move window to left/right/up/down workspace», user can configure in xfwm4-settings or navigate from Settings Manager in Xfce.

  1. Go to Settings Manager > Window Manager — Keyboard
  2. In the tab, scroll down until «Toggle fullscreen» entry and the relevant actions «Move window to. » are listed below it with empty column on the right
  3. For the corresponding action «Move window to upper workspace», do either double-click the empty column, or select the row and click Edit
  4. A small popup window will appear, then press the shortcut keys of choice to be assigned for previously selected action: Ctrl + Alt + Shift + ↑ for «Move window to upper workspace» and then the popup window will be closed
  5. Repeat step 3 and 4 for other actions, and finally click Close to finish.

Additional notes

To this date, Wikipedia still note the ‘old’ shortcuts in the article of Table of keyboard shortcuts under «Window Management». That has changed since the introduction of GNOME 3, with most of the shortcuts have been redefined and favours combination of Super key.

Источник

Moving windows from the keyboard

Is it possible to move windows from the keyboard itself without touching the mouse? I know I can do a Alt + Left Click and drag the window, however I am hoping there is something I can use to move it from the keyboard without the mouse.

Читайте также:  Нужно ли чистить линукс

4 Answers 4

You can move a window by pressing

  • Alt + F7 , then moving it around with the arrow keys, and finish by hitting Return .
  • The same goes for resizing, using Alt + F8

You can also press Esc to cancel

You can also bring up the application’s window menu with Alt + space :

alt text

If you want to change those shortcuts, you can go to System → Preferences → Keyboard Shortcuts and find them under Window Management:

alt text

Very handy when adding a display monitor and the window is cut off at the top (making drag and drop hard). Also found I needed to add Fn key, sometimes from my laptop (e.g.: Alt + Fn + F7 )

Here is a list of shortcuts:

  • Ctrl + Alt + Num 1 = moves the window to the bottom left corner
  • Ctrl + Alt + Num 2 = moves the window to the bottom half of the screen
  • Ctrl + Alt + Num 3 = moves the window to the bottom right corner
  • Ctrl + Alt + Num 4 = moves the window to the left half of the screen
  • Ctrl + Alt + Num 5 = maximizes the window
  • Ctrl + Alt + Num 6 = moves the window to the right half of the screen
  • Ctrl + Alt + Num 7 = moves the window to the right left corner
  • Ctrl + Alt + Num 8 = moves the window to the top half of the screen
  • Ctrl + Alt + Num 9 = moves the window to the right right coner

Well, this used to work till Ubuntu 17.04, using ubuntu 17.10 ATM and this doesn’t work. I wish it would work though.

@Mat : Go into the dconf editor and go to the path /org/gnome/desktop/wm/keybindings/. You will find find all the settings that start with «move-to».

Instead of moving windows around by keyboard as if you’re moving a mouse, you might just as well use a tiling window manager like awesome or xmonad, where everything is done by keyboard, anyway. In these window managers, windows only exchange places with other windows, and together they cover the whole screen.

There is now an application that performs these functions called Window Shuffler Control. I installed it through the Ubuntu Budgie extras.

Источник

Оцените статью
Adblock
detector