]> Dogcows Code - chaz/openbox/blobdiff - openbox/screen.c
consistant glib type usage
[chaz/openbox] / openbox / screen.c
index 7f0c70c96ddc2e915f75dd932c46bca814a45f13..b0fc5c20a7f0bfb1fb5339c29baed835b21d81ed 100644 (file)
@@ -54,7 +54,7 @@ guint    screen_last_desktop;
 Size     screen_physical_size;
 gboolean screen_showing_desktop;
 DesktopLayout screen_desktop_layout;
-char   **screen_desktop_names;
+gchar  **screen_desktop_names;
 Window   screen_support_win;
 
 static Rect  **area; /* array of desktop holding array of xinerama areas */
@@ -64,7 +64,7 @@ static ObPagerPopup *desktop_cycle_popup;
 
 static gboolean replace_wm()
 {
-    char *wm_sn;
+    gchar *wm_sn;
     Atom wm_sn_atom;
     Window current_wm_sn_owner;
     Time timestamp;
@@ -74,6 +74,8 @@ static gboolean replace_wm()
     g_free(wm_sn);
 
     current_wm_sn_owner = XGetSelectionOwner(ob_display, wm_sn_atom);
+    if (current_wm_sn_owner == screen_support_win)
+        current_wm_sn_owner = None;
     if (current_wm_sn_owner) {
         if (!ob_replace_wm) {
             g_warning("A window manager is already running on screen %d",
@@ -279,7 +281,7 @@ void screen_startup(gboolean reconfig)
         screen_resize();
 
     /* set the names */
-    screen_desktop_names = g_new(char*,
+    screen_desktop_names = g_new(gchar*,
                                  g_slist_length(config_desktops_names) + 1);
     for (i = 0, it = config_desktops_names; it; ++i, it = it->next)
         screen_desktop_names[i] = it->data; /* dont strdup */
@@ -334,8 +336,8 @@ void screen_shutdown(gboolean reconfig)
 
 void screen_resize()
 {
-    static int oldw = 0, oldh = 0;
-    int w, h;
+    static gint oldw = 0, oldh = 0;
+    gint w, h;
     GList *it;
     guint32 geometry[2];
 
@@ -438,16 +440,16 @@ void screen_set_desktop(guint num)
     /* show windows before hiding the rest to lessen the enter/leave events */
 
     /* show windows from top to bottom */
-    for (it = stacking_list; it != NULL; it = it->next) {
+    for (it = stacking_list; it; it = g_list_next(it)) {
         if (WINDOW_IS_CLIENT(it->data)) {
             ObClient *c = it->data;
-            if (!c->frame->visible && client_should_show(c))
+            if (client_should_show(c))
                 frame_show(c->frame);
         }
     }
 
     /* hide windows from bottom to top */
-    for (it = g_list_last(stacking_list); it != NULL; it = it->prev) {
+    for (it = g_list_last(stacking_list); it; it = g_list_previous(it)) {
         if (WINDOW_IS_CLIENT(it->data)) {
             ObClient *c = it->data;
             if (c->frame->visible && !client_should_show(c))
@@ -457,7 +459,18 @@ void screen_set_desktop(guint num)
 
     event_ignore_queued_enters();
 
-    focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS);
+    focus_hilite = focus_fallback_target(OB_FOCUS_FALLBACK_NOFOCUS);
+    if (focus_hilite) {
+        frame_adjust_focus(focus_hilite->frame, TRUE);
+
+        /*!
+          When this focus_client check is not used, you can end up with races,
+          as demonstrated with gnome-panel, sometmies the window you click on
+          another desktop ends up losing focus cuz of the focus change here.
+        */
+        /*if (!focus_client)*/
+        client_focus(focus_hilite);
+    }
 }
 
 static void get_row_col(guint d, guint *r, guint *c)
@@ -633,49 +646,81 @@ guint screen_cycle_desktop(ObDirection dir, gboolean wrap, gboolean linear,
         case OB_DIRECTION_EAST:
             ++c;
             if (c >= screen_desktop_layout.columns) {
-                if (!wrap) return d = screen_desktop;
-                c = 0;
+                if (wrap) {
+                    c = 0;
+                } else {
+                    d = screen_desktop;
+                    goto show_cycle_dialog;
+                }
             }
             d = translate_row_col(r, c);
             if (d >= screen_num_desktops) {
-                if (!wrap) return d = screen_desktop;
-                ++c;
+                if (wrap) {
+                    ++c;
+                } else {
+                    d = screen_desktop;
+                    goto show_cycle_dialog;
+                }
             }
             break;
         case OB_DIRECTION_WEST:
             --c;
             if (c >= screen_desktop_layout.columns) {
-                if (!wrap) return d = screen_desktop;
-                c = screen_desktop_layout.columns - 1;
+                if (wrap) {
+                    c = screen_desktop_layout.columns - 1;
+                } else {
+                    d = screen_desktop;
+                    goto show_cycle_dialog;
+                }
             }
             d = translate_row_col(r, c);
             if (d >= screen_num_desktops) {
-                if (!wrap) return d = screen_desktop;
-                --c;
+                if (wrap) {
+                    --c;
+                } else {
+                    d = screen_desktop;
+                    goto show_cycle_dialog;
+                }
             }
             break;
         case OB_DIRECTION_SOUTH:
             ++r;
             if (r >= screen_desktop_layout.rows) {
-                if (!wrap) return d = screen_desktop;
-                r = 0;
+                if (wrap) {
+                    r = 0;
+                } else {
+                    d = screen_desktop;
+                    goto show_cycle_dialog;
+                }
             }
             d = translate_row_col(r, c);
             if (d >= screen_num_desktops) {
-                if (!wrap) return d = screen_desktop;
-                ++r;
+                if (wrap) {
+                    ++r;
+                } else {
+                    d = screen_desktop;
+                    goto show_cycle_dialog;
+                }
             }
             break;
         case OB_DIRECTION_NORTH:
             --r;
             if (r >= screen_desktop_layout.rows) {
-                if (!wrap) return d = screen_desktop;
-                r = screen_desktop_layout.rows - 1;
+                if (wrap) {
+                    r = screen_desktop_layout.rows - 1;
+                } else {
+                    d = screen_desktop;
+                    goto show_cycle_dialog;
+                }
             }
             d = translate_row_col(r, c);
             if (d >= screen_num_desktops) {
-                if (!wrap) return d = screen_desktop;
-                --r;
+                if (wrap) {
+                    --r;
+                } else {
+                    d = screen_desktop;
+                    goto show_cycle_dialog;
+                }
             }
             break;
         default:
@@ -686,6 +731,7 @@ guint screen_cycle_desktop(ObDirection dir, gboolean wrap, gboolean linear,
         d = translate_row_col(r, c);
     }
 
+show_cycle_dialog:
     if (dialog) {
         screen_desktop_popup(d, TRUE);
         return d;
@@ -804,7 +850,7 @@ void screen_update_desktop_names()
     else
         i = 0;
     if (i <= screen_num_desktops) {
-        screen_desktop_names = g_renew(char*, screen_desktop_names,
+        screen_desktop_names = g_renew(gchar*, screen_desktop_names,
                                        screen_num_desktops + 1);
         screen_desktop_names[screen_num_desktops] = NULL;
         for (; i < screen_num_desktops; ++i)
@@ -821,23 +867,23 @@ void screen_show_desktop(gboolean show)
     screen_showing_desktop = show;
 
     if (show) {
-       /* bottom to top */
-       for (it = g_list_last(stacking_list); it != NULL; it = it->prev) {
+        /* bottom to top */
+        for (it = g_list_last(stacking_list); it != NULL; it = it->prev) {
             if (WINDOW_IS_CLIENT(it->data)) {
                 ObClient *client = it->data;
                 if (client->frame->visible && !client_should_show(client))
                     frame_hide(client->frame);
             }
-       }
+        }
     } else {
         /* top to bottom */
-       for (it = stacking_list; it != NULL; it = it->next) {
+        for (it = stacking_list; it != NULL; it = it->next) {
             if (WINDOW_IS_CLIENT(it->data)) {
                 ObClient *client = it->data;
                 if (!client->frame->visible && client_should_show(client))
                     frame_show(client->frame);
             }
-       }
+        }
     }
 
     if (show) {
@@ -860,10 +906,10 @@ void screen_install_colormap(ObClient *client, gboolean install)
     XWindowAttributes wa;
 
     if (client == NULL) {
-       if (install)
-           XInstallColormap(RrDisplay(ob_rr_inst), RrColormap(ob_rr_inst));
-       else
-           XUninstallColormap(RrDisplay(ob_rr_inst), RrColormap(ob_rr_inst));
+        if (install)
+            XInstallColormap(RrDisplay(ob_rr_inst), RrColormap(ob_rr_inst));
+        else
+            XUninstallColormap(RrDisplay(ob_rr_inst), RrColormap(ob_rr_inst));
     } else {
         if (XGetWindowAttributes(ob_display, client->window, &wa) &&
             wa.colormap != None) {
@@ -1144,10 +1190,10 @@ void screen_set_root_cursor()
                       ob_cursor(OB_CURSOR_POINTER));
 }
 
-gboolean screen_pointer_pos(int *x, int *y)
+gboolean screen_pointer_pos(gint *x, gint *y)
 {
     Window w;
-    int i;
+    gint i;
     guint u;
 
     return !!XQueryPointer(ob_display, RootWindow(ob_display, ob_screen),
This page took 0.032638 seconds and 4 git commands to generate.