|
@@ -39,7 +39,7 @@ void Mouse::setCursor( int cursor ) {
|
39
|
39
|
xcursor, CurrentTime );
|
40
|
40
|
}
|
41
|
41
|
|
42
|
|
-Mouse::Mouse(X11* x11, bool nodecorations, Window ignoreWindow ) {
|
|
42
|
+Mouse::Mouse(X11* x11, int nodecorations, Window ignoreWindow ) {
|
43
|
43
|
this->x11 = x11;
|
44
|
44
|
currentCursor = XC_cross;
|
45
|
45
|
xcursor = XCreateFontCursor( x11->display, XC_cross );
|
|
@@ -83,10 +83,10 @@ Window Mouse::findWindow( Window foo ) {
|
83
|
83
|
unsigned int nchildren;
|
84
|
84
|
Window selectedWindow;
|
85
|
85
|
XQueryTree( x11->display, foo, &root, &parent, &children, &nchildren );
|
86
|
|
- // The children are ordered, so we traverse backwards.
|
87
|
86
|
if ( !children || nchildren <= 0 ) {
|
88
|
87
|
return foo;
|
89
|
88
|
}
|
|
89
|
+ // The children are ordered, so we traverse backwards.
|
90
|
90
|
for( int i=nchildren-1;i>=0;i-- ) {
|
91
|
91
|
if ( children[i] == ignoreWindow ) {
|
92
|
92
|
continue;
|
|
@@ -103,12 +103,20 @@ Window Mouse::findWindow( Window foo ) {
|
103
|
103
|
if ( a <= rect.z && a >= 0 ) {
|
104
|
104
|
if ( b <= rect.w && b >= 0 ) {
|
105
|
105
|
selectedWindow = children[i];
|
106
|
|
- if ( !nodecorations ) {
|
107
|
|
- XFree(children);
|
108
|
|
- return selectedWindow;
|
109
|
|
- } else {
|
110
|
|
- XFree(children);
|
111
|
|
- return findWindow( selectedWindow );
|
|
106
|
+ switch( nodecorations ) {
|
|
107
|
+ case 0:
|
|
108
|
+ XFree(children);
|
|
109
|
+ return selectedWindow;
|
|
110
|
+ case 1:
|
|
111
|
+ XFree(children);
|
|
112
|
+ //return findWindow( selectedWindow );
|
|
113
|
+ XQueryTree( x11->display, selectedWindow, &root, &parent, &children, &nchildren );
|
|
114
|
+ if ( !children || nchildren <= 0 ) {
|
|
115
|
+ return selectedWindow;
|
|
116
|
+ }
|
|
117
|
+ return children[nchildren-1];
|
|
118
|
+ case 2:
|
|
119
|
+ return findWindow( selectedWindow );
|
112
|
120
|
}
|
113
|
121
|
}
|
114
|
122
|
}
|