Move application windows on desktop programmatically in Gnome or KDE

我们两清 提交于 2019-12-10 18:26:28

问题


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.


回答1:


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;
}


来源:https://stackoverflow.com/questions/12109766/move-application-windows-on-desktop-programmatically-in-gnome-or-kde

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!