简体   繁体   English

在Gnome或KDE中以编程方式在桌面上移动应用程序窗口

[英]Move application windows on desktop programmatically in Gnome or KDE

I want to reposition a application window on the desktop using a c++ program . 我想使用c ++程序在桌面上重新定位应用程序窗口。 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: 外部Bash脚本:

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 . 有关此内容的更多信息,请使用xdotool searchxdotool windowmoveman xdotool

C++ example: C ++示例:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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