[metacity] focus windows when changin workspace



Here is a small patch to metacity, which gives the focus to the window
under the cursor after changing the workspace through the keyboard.
Of course, nothing is done if the focus should be given only on mouse
clicks.

regards,
Emmanuel,   GtkAda team

*** ../keybindings.c    Wed Feb  5 12:35:19 2003
--- src/keybindings.c   Wed Feb  5 12:37:14 2003
***************
*** 2915,2920 ****
--- 2915,2957 ----
         
        /* only after selecting proper space */
        meta_ui_tab_popup_set_showing (screen->tab_popup, TRUE);
+
+       /* put the focus on the window under the cursor if needed */
+       switch (meta_prefs_get_focus_mode ())
+       {
+       case META_FOCUS_MODE_SLOPPY:
+       case META_FOCUS_MODE_MOUSE:
+
+         {
+           GList *windows =
+             meta_workspace_list_windows (screen->active_workspace);
+           GList *tmp     = windows;
+
+           while (tmp != NULL)
+             {
+               MetaWindow* window = tmp->data;
+               MetaRectangle window_rect;
+
+               meta_window_get_outer_rect (window, &window_rect);
+
+               if (window_rect.x <= event->xkey.x
+                   && window_rect.y <= event->xkey.y
+                   && event->xkey.x <= window_rect.x +
window_rect.width
+                   && event->xkey.y <= window_rect.y +
window_rect.height)
+                 {
+                   meta_window_activate (window, event->xkey.time);
+                   g_list_free (windows);
+               return;
+                 }
+
+               tmp = tmp->next;
+             }
+           g_list_free (windows);
+         }
+
+       case META_FOCUS_MODE_CLICK:
+         break;
+       }
      }
  }




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]