【发布时间】:2012-08-20 00:56:54
【问题描述】:
我想使用 c++ 程序在桌面上重新定位应用程序窗口。 我应该怎么做,我需要两种情况的解决方案。
当我有想要移动的应用程序源时。
通过编写外部程序移动其他应用程序的窗口。
【问题讨论】:
-
你是指其他应用程序的窗口?我怀疑有一个标准的方法。相关规范(EWMH、ICCCM、NET)控制客户端如何与窗口管理器通信,但不控制它如何影响其他客户端。
我想使用 c++ 程序在桌面上重新定位应用程序窗口。 我应该怎么做,我需要两种情况的解决方案。
当我有想要移动的应用程序源时。
通过编写外部程序移动其他应用程序的窗口。
【问题讨论】:
外部 Bash 脚本:
xdotool search --onlyvisible --class dolphin windowmove 13 37
# ^ ^ ^
# window class X & Y coordinates
有关这方面的更多信息,请使用xdotool search、xdotool windowmove 和man 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;
}
【讨论】:
xdotool search信息。