Question

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.

Was it helpful?

Solution

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;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top