fix for wm that use borders with non-zero widths
[goodguy/history.git] / cinelerra-5.1 / guicast / bcwindowbase.C
index 2ab508f2438ed85a1b3dd327fec95a611a33b487..f9eb98f20b18ee5d22609326afcc0382f7283125 100644 (file)
@@ -3431,6 +3431,8 @@ BC_WindowBase::get_xinerama_info(int screen)
                return 0;
        }
        int top_x = get_x(), top_y = get_y();
+       if(  BC_DisplayInfo::left_border >= 0 ) top_x +=  BC_DisplayInfo::left_border;
+       if(  BC_DisplayInfo::top_border >= 0 ) top_y +=  BC_DisplayInfo::top_border;
        for( int i=0; i<xinerama_screens; ++i ) {
                int scr_y = top_y - xinerama_info[i].y_org;
                if( scr_y < 0 || scr_y >= xinerama_info[i].height ) continue;
@@ -3839,17 +3841,27 @@ int BC_WindowBase::match_window(Window win)
 
 int BC_WindowBase::get_cursor_over_window()
 {
-       if(top_level != this) return top_level->get_cursor_over_window();
-
        int abs_x, abs_y, win_x, win_y;
-       unsigned int temp_mask;
+       unsigned int mask_return;
        Window root_return, child_return;
 
-       int ret = XQueryPointer(display, win,
+       int ret = XQueryPointer(top_level->display, top_level->rootwin,
                &root_return, &child_return, &abs_x, &abs_y,
-               &win_x, &win_y, &temp_mask);
-       if( ret && child_return == None && win != root_return ) ret = 0;
-       if( ret && child_return != None ) ret = match_window(child_return);
+               &win_x, &win_y, &mask_return);
+       if( ret && child_return == None ) ret = 0;
+       if( ret && win != child_return )
+               ret = top_level->match_window(child_return);
+// query pointer can return a window manager window with this top_level as a child
+//  for kde this can be two levels deep
+       unsigned int nchildren_return = 0;
+       Window parent_return, *children_return = 0;
+       Window top_win = top_level->win;
+       while( !ret && top_win != top_level->rootwin && top_win != root_return &&
+               XQueryTree(top_level->display, top_win, &root_return,
+                       &parent_return, &children_return, &nchildren_return) ) {
+               if( children_return ) XFree(children_return);
+               if( (top_win=parent_return) == child_return ) ret = 1;
+       }
        return ret;
 }