简体   繁体   中英

Move application windows on desktop programmatically in Gnome or KDE

I want to reposition a application window on the desktop using a c++ program . How should i go about doing that , i need solution for both situations .

  1. When i have the source of the application which want to move .

  2. Move windows of other application by Writing an external program.

External Bash script:

xdotool   search --onlyvisible --class dolphin   windowmove 13 37
#                                         ^                 ^   ^
#                                   window class            X & Y coordinates

For more information about this, use xdotool search , xdotool windowmove and man xdotool .

C++ example:

#include <cstdlib>
#include <string>
#include <sstream>

using namespace std;

int main()
{
    string cls="dolphin";
    int x=13, y=37;

    stringstream s;
    s<<"xdotool search --onlyvisible --class "<<cls<<" windowmove "<<x<<" "<<y;

    system(s.str().c_str());

    return 0;
}

And bare minimum example:

#include <stdlib.h>

int main()
{
    system("xdotool search --onlyvisible --class dolphin windowmove 13 37");
    return 0;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM