2012-08-24 38 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

相關問題