raise works
[winnie] / src / sdl / mouse.cc
index f31c900..c5663f6 100644 (file)
@@ -34,22 +34,24 @@ void process_mouse_event()
        MouseMotionFuncType motion_callback = 0;
        MouseButtonFuncType button_callback = 0;
 
-       Window *top = wm->get_window_at_pos(pointer_x, pointer_y);
-
-       if(top) {
-               wm->set_focused_window(top);
-       }
-       else {
-               wm->set_focused_window(0);
+       Window *win;
+       if(!(win = wm->get_grab_window())) {
+               win = wm->get_window_at_pos(pointer_x, pointer_y);
+               if(win) {
+                       wm->set_focused_window(win);
+               }
+               else {
+                       wm->set_focused_window(0);
+               }
        }
 
        switch(sdl_event.type) {
        case SDL_MOUSEMOTION:
                pointer_x = sdl_event.motion.x;
                pointer_y = sdl_event.motion.y;
-               if(top && (motion_callback = top->get_mouse_motion_callback())) {
-                       Rect rect = top->get_absolute_rect();
-                       motion_callback(top, pointer_x - rect.x, pointer_y - rect.y);
+               if(win && (motion_callback = win->get_mouse_motion_callback())) {
+                       Rect rect = win->get_absolute_rect();
+                       motion_callback(win, pointer_x - rect.x, pointer_y - rect.y);
                }
                break;
 
@@ -62,9 +64,9 @@ void process_mouse_event()
                else {
                        bnstate &= ~(1 << bn);
                }
-               if(top && (button_callback = top->get_mouse_button_callback())) {
-                       Rect rect = top->get_absolute_rect();
-                       button_callback(top, bn, sdl_event.button.state, pointer_x - rect.x, pointer_y - rect.y);
+               if(win && (button_callback = win->get_mouse_button_callback())) {
+                       Rect rect = win->get_absolute_rect();
+                       button_callback(win, bn, sdl_event.button.state, pointer_x - rect.x, pointer_y - rect.y);
                }
        }
 }