【问题标题】:Move application windows on desktop programmatically in Gnome or KDE在 Gnome 或 KDE 中以编程方式在桌面上移动应用程序窗口
【发布时间】:2012-08-20 00:56:54
【问题描述】:

我想使用 c++ 程序在桌面上重新定位应用程序窗口。 我应该怎么做,我需要两种情况的解决方案。

  1. 当我有想要移动的应用程序源时。

  2. 通过编写外部程序移动其他应用程序的窗口。

【问题讨论】:

  • 你是指其他应用程序的窗口?我怀疑有一个标准的方法。相关规范(EWMH、ICCCM、NET)控制客户端如何与窗口管理器通信,但不控制它如何影响其他客户端。

标签: c++ gnome kde


【解决方案1】:

外部 Bash 脚本:

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

有关这方面的更多信息,请使用xdotool searchxdotool windowmoveman xdotool

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

还有最简单的例子:

#include <stdlib.h>

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

【讨论】:

  • 什么是窗口类?我如何找到要移动的应用程序的窗口类?
  • @rajat 我认为它应该与进程名称相同。不用这些类,看xdotool search信息。
  • @rajat 我刚刚将其添加到答案中。
  • 非常感谢! ,很快!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-16
  • 1970-01-01
  • 2010-09-12
  • 1970-01-01
  • 2012-07-30
  • 1970-01-01
相关资源
最近更新 更多