2012-08-24 103 views
2

我想使用C++程序在桌面上重新定位应用程序窗口。 我应该如何去做,我需要两种情况下的解决方案。在Gnome或KDE中以编程方式移动应用程序窗口

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

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

+0

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

+0

是,其他应用程序。 – rajat

回答

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

什么是窗口类?我如何找到我想要移动的应用程序的窗口类? – rajat

+0

@rajat我认为它应该与进程名称相同。您不必使用这些类,查看'xdotool search'信息。 –

+0

Ohk酷,让它工作!现在,如何使用C++做到这一点? – rajat

相关问题