]> Dogcows Code - chaz/openbox/commitdiff
show a popup notification when switching desktops (also make all the config options...
authorDana Jansens <danakj@orodu.net>
Sat, 4 Aug 2007 00:40:13 +0000 (20:40 -0400)
committerDana Jansens <danakj@orodu.net>
Sat, 4 Aug 2007 00:40:13 +0000 (20:40 -0400)
data/rc.xml
data/rc.xsd
openbox/actions/desktop.c
openbox/config.c
openbox/config.h
openbox/dock.c
openbox/event.c
openbox/screen.c
openbox/screen.h

index ff5830dc4dcb0bbc766be7877b8003f4aeae00a1..b28bf1a91dc00ca510052464b84088a635d62513 100644 (file)
     <name>desktop 2</name>
     -->
   </names>
+  <popupTime>500</popupTime>
+  <!-- The number of milliseconds to show the popup for when switching
+       desktops.  Set this to 0 to disable the popup. -->
 </desktops>
 
 <resize>
   <doubleClickTime>200</doubleClickTime>
   <!-- in milliseconds (1000 = 1 second) -->
   <screenEdgeWarpTime>400</screenEdgeWarpTime>
-  <!-- time before changing desktops when the pointer touches the edge of the
-       screen while moving a window, in milliseconds (1000 = 1 second),
-       0 disables warping -->
+  <!-- Time before changing desktops when the pointer touches the edge of the
+       screen while moving a window, in milliseconds (1000 = 1 second).
+       Set this to 0 to disable warping -->
 
   <context name="Frame">
     <mousebind button="A-Left" action="Press">
index 24a0f91f7e1272d5766d822ac22b0150b537af0d..adafc5f498b528bcdbd861e45d254b9a564a1e39 100644 (file)
@@ -89,6 +89,7 @@
                 <xsd:element maxOccurs="unbounded" name="name" type="xsd:string"/>
             </xsd:complexType>
         </xsd:element>
+        <xsd:element minOccurs="0" name="popupTime" type="xsd:integer"/>
     </xsd:complexType>
     <xsd:complexType name="resize">
         <xsd:element minOccurs="0" name="drawContents" type="ob:bool"/>
index d3a0d0c30edeaba16c5387053400328d1b8ca906..75949be2e5fc2d1c40622f07e87a75b676a2a461 100644 (file)
@@ -132,10 +132,8 @@ static gboolean run_func(ObActionsData *data, gpointer options)
         d = o->abs.desktop;
         break;
     case RELATIVE:
-        d = screen_cycle_desktop(o->rel.dir,
-                                 o->rel.wrap,
-                                 o->rel.linear,
-                                 FALSE, TRUE, FALSE);
+        d = screen_find_desktop(screen_desktop,
+                                o->rel.dir, o->rel.wrap, o->rel.linear);
         break;
     }
 
index 0d6efc9250e5d83ef790b94accd2a38c5988906b..c7d6db30b326ddef17af094760237f2eacb28c44 100644 (file)
@@ -57,6 +57,7 @@ RrFont *config_font_osd;
 gint    config_desktops_num;
 GSList *config_desktops_names;
 guint   config_screen_firstdesk;
+guint   config_desktop_popup_time;
 
 gboolean config_resize_redraw;
 gboolean config_resize_four_corners;
@@ -478,7 +479,7 @@ static void parse_focus(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
     if ((n = parse_find_node("followMouse", node)))
         config_focus_follow = parse_bool(doc, n);
     if ((n = parse_find_node("focusDelay", node)))
-        config_focus_delay = parse_int(doc, n) * 1000;
+        config_focus_delay = parse_int(doc, n);
     if ((n = parse_find_node("raiseOnFocus", node)))
         config_focus_raise = parse_bool(doc, n);
     if ((n = parse_find_node("focusLast", node)))
@@ -634,6 +635,8 @@ static void parse_desktops(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
             nname = parse_find_node("name", nname->next);
         }
     }
+    if ((n = parse_find_node("popupTime", node)))
+        config_desktop_popup_time = parse_int(doc, n);
 }
 
 static void parse_resize(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
@@ -724,9 +727,9 @@ static void parse_dock(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
     if ((n = parse_find_node("autoHide", node)))
         config_dock_hide = parse_bool(doc, n);
     if ((n = parse_find_node("hideDelay", node)))
-        config_dock_hide_delay = parse_int(doc, n) * 1000;
+        config_dock_hide_delay = parse_int(doc, n);
     if ((n = parse_find_node("showDelay", node)))
-        config_dock_show_delay = parse_int(doc, n) * 1000;
+        config_dock_show_delay = parse_int(doc, n);
     if ((n = parse_find_node("moveButton", node))) {
         gchar *str = parse_string(doc, n);
         guint b, s;
@@ -900,6 +903,7 @@ void config_startup(ObParseInst *i)
     config_desktops_num = 4;
     config_screen_firstdesk = 1;
     config_desktops_names = NULL;
+    config_desktop_popup_time = 500;
 
     parse_register(i, "desktops", parse_desktops, NULL);
 
index 42bf35346770964de08b3774ce3c75d36174ad2b..9d0602e28b13b62630c742a146cf949ff584f370 100644 (file)
@@ -64,7 +64,7 @@ struct _ObAppSettings
 extern gboolean config_focus_new;
 /*! Focus windows when the mouse enters them */
 extern gboolean config_focus_follow;
-/*! Timeout for focusing windows on focus follows mouse, in microseconds */
+/*! Timeout for focusing windows on focus follows mouse, in milliseconds */
 extern guint    config_focus_delay;
 /*! If windows should automatically be raised when they are focused in
  focus follows mouse */
@@ -109,9 +109,9 @@ extern gint config_dock_y;
 extern ObOrientation config_dock_orient;
 /*! Whether to auto-hide the dock when the pointer is not over it */
 extern gboolean config_dock_hide;
-/*! The number of microseconds to wait before hiding the dock */
+/*! The number of milliseconds to wait before hiding the dock */
 extern guint config_dock_hide_delay;
-/*! The number of microseconds to wait before showing the dock */
+/*! The number of milliseconds to wait before showing the dock */
 extern guint config_dock_show_delay;
 /*! The mouse button to be used to move dock apps */
 extern guint config_dock_app_move_button;
@@ -145,6 +145,8 @@ extern gint config_desktops_num;
 extern guint config_screen_firstdesk;
 /*! Names for the desktops */
 extern GSList *config_desktops_names;
+/*! Amount of time to show the desktop switch dialog */
+extern guint config_desktop_popup_time;
 
 /*! The keycode of the key combo which resets the keybaord chains */
 extern guint config_keyboard_reset_keycode;
@@ -165,11 +167,11 @@ extern gint config_resist_win;
 /*! Number of pixels to resist while crossing a screen's edge */
 extern gint config_resist_edge;
 
-/*! delay for hiding menu when opening */
+/*! Delay for hiding menu when opening in milliseconds */
 extern guint    config_menu_hide_delay;
 /*! Center menus vertically about the parent entry */
 extern gboolean config_menu_middle;
-/*! delay before opening a submenu */
+/*! Delay before opening a submenu in milliseconds */
 extern guint    config_submenu_show_delay;
 /*! show icons in client_list_menu */
 extern gboolean config_menu_client_list_icons;
index 36b08b06013560a1a92c618b3249e1077378c8e7..3b32758afc0d5fba131a0024d2628dd9cd5858b3 100644 (file)
@@ -628,15 +628,17 @@ void dock_hide(gboolean hide)
 {
     if (!hide) {
         if (dock->hidden && config_dock_hide) {
-            ob_main_loop_timeout_add(ob_main_loop, config_dock_show_delay,
-                                 show_timeout, NULL, g_direct_equal, NULL);
+            ob_main_loop_timeout_add(ob_main_loop,
+                                     config_dock_show_delay * 1000,
+                                     show_timeout, NULL, g_direct_equal, NULL);
         } else if (!dock->hidden && config_dock_hide) {
             ob_main_loop_timeout_remove(ob_main_loop, hide_timeout);
         }
     } else {
         if (!dock->hidden && config_dock_hide) {
-            ob_main_loop_timeout_add(ob_main_loop, config_dock_hide_delay,
-                                 hide_timeout, NULL, g_direct_equal, NULL);
+            ob_main_loop_timeout_add(ob_main_loop,
+                                     config_dock_hide_delay * 1000,
+                                     hide_timeout, NULL, g_direct_equal, NULL);
         } else if (dock->hidden && config_dock_hide) {
             ob_main_loop_timeout_remove(ob_main_loop, show_timeout);
         }
index 522305a821765728cbd8816c59f33032d4fc6898..d31b68c95c2d22cb818a3e7546171c4bf1009c89 100644 (file)
@@ -753,7 +753,7 @@ void event_enter_client(ObClient *client)
             data->time = event_curtime;
 
             ob_main_loop_timeout_add(ob_main_loop,
-                                     config_focus_delay,
+                                     config_focus_delay * 1000,
                                      focus_delay_func,
                                      data, focus_delay_cmp, focus_delay_dest);
         } else {
index 79008e75c2ecbe082f62c7cfb84682811ba050ef..7f608b3c86e2ece64e7698f64ba13ce9fd2b4cfb 100644 (file)
@@ -26,6 +26,7 @@
 #include "startupnotify.h"
 #include "moveresize.h"
 #include "config.h"
+#include "mainloop.h"
 #include "screen.h"
 #include "client.h"
 #include "session.h"
@@ -73,7 +74,7 @@ static GSList *struts_left = NULL;
 static GSList *struts_right = NULL;
 static GSList *struts_bottom = NULL;
 
-static ObPagerPopup *desktop_cycle_popup;
+static ObPagerPopup *desktop_popup;
 
 static gboolean replace_wm()
 {
@@ -342,12 +343,12 @@ void screen_startup(gboolean reconfig)
     guint32 d;
     gboolean namesexist = FALSE;
 
-    desktop_cycle_popup = pager_popup_new(FALSE);
-    pager_popup_height(desktop_cycle_popup, POPUP_HEIGHT);
+    desktop_popup = pager_popup_new(FALSE);
+    pager_popup_height(desktop_popup, POPUP_HEIGHT);
 
     if (reconfig) {
         /* update the pager popup's width */
-        pager_popup_text_width_to_strings(desktop_cycle_popup,
+        pager_popup_text_width_to_strings(desktop_popup,
                                           screen_desktop_names,
                                           screen_num_desktops);
         return;
@@ -430,7 +431,7 @@ void screen_startup(gboolean reconfig)
 
 void screen_shutdown(gboolean reconfig)
 {
-    pager_popup_free(desktop_cycle_popup);
+    pager_popup_free(desktop_popup);
 
     if (reconfig)
         return;
@@ -618,6 +619,9 @@ void screen_set_desktop(guint num, gboolean dofocus)
 
     if (event_curtime != CurrentTime)
         screen_desktop_user_time = event_curtime;
+
+    if (ob_state() == OB_STATE_RUNNING)
+        screen_show_desktop_popup(screen_desktop);
 }
 
 void screen_add_desktop(gboolean current)
@@ -804,25 +808,34 @@ static guint translate_row_col(guint r, guint c)
     return 0;
 }
 
-void screen_desktop_popup(guint d, gboolean show)
+static gboolean hide_desktop_popup_func(gpointer data)
+{
+    pager_popup_hide(desktop_popup);
+    return FALSE; /* don't repeat */
+}
+
+void screen_show_desktop_popup(guint d)
 {
     Rect *a;
 
-    if (!show) {
-        pager_popup_hide(desktop_cycle_popup);
-    } else {
-        a = screen_physical_area_active();
-        pager_popup_position(desktop_cycle_popup, CenterGravity,
-                             a->x + a->width / 2, a->y + a->height / 2);
-        pager_popup_icon_size_multiplier(desktop_cycle_popup,
-                                         (screen_desktop_layout.columns /
-                                          screen_desktop_layout.rows) / 2,
-                                         (screen_desktop_layout.rows/
-                                          screen_desktop_layout.columns) / 2);
-        pager_popup_max_width(desktop_cycle_popup,
-                              MAX(a->width/3, POPUP_WIDTH));
-        pager_popup_show(desktop_cycle_popup, screen_desktop_names[d], d);
-    }
+    /* 0 means don't show the popup */
+    if (!config_desktop_popup_time) return;
+
+    a = screen_physical_area_active();
+    pager_popup_position(desktop_popup, CenterGravity,
+                         a->x + a->width / 2, a->y + a->height / 2);
+    pager_popup_icon_size_multiplier(desktop_popup,
+                                     (screen_desktop_layout.columns /
+                                      screen_desktop_layout.rows) / 2,
+                                     (screen_desktop_layout.rows/
+                                      screen_desktop_layout.columns) / 2);
+    pager_popup_max_width(desktop_popup,
+                          MAX(a->width/3, POPUP_WIDTH));
+    pager_popup_show(desktop_popup, screen_desktop_names[d], d);
+
+    ob_main_loop_timeout_remove(ob_main_loop, hide_desktop_popup_func);
+    ob_main_loop_timeout_add(ob_main_loop, config_desktop_popup_time * 1000,
+                             hide_desktop_popup_func, NULL, NULL, NULL);
 }
 
 guint screen_find_desktop(guint from, ObDirection dir,
@@ -931,30 +944,6 @@ guint screen_find_desktop(guint from, ObDirection dir,
     return d;
 }
 
-guint screen_cycle_desktop(ObDirection dir, gboolean wrap, gboolean linear,
-                           gboolean dialog, gboolean done, gboolean cancel)
-{
-    static guint d = (guint)-1;
-    guint ret;
-
-    if (d == (guint)-1)
-        d = screen_desktop;
-
-    if ((!cancel && !done) || !dialog)
-        d = screen_find_desktop(d, dir, wrap, linear);
-
-    if (dialog && !cancel && !done)
-        screen_desktop_popup(d, TRUE);
-    else
-        screen_desktop_popup(0, FALSE);
-    ret = d;
-
-    if (!dialog || cancel || done)
-        d = (guint)-1;
-
-    return ret;
-}
-
 static gboolean screen_validate_layout(ObDesktopLayout *l)
 {
     if (l->columns == 0 && l->rows == 0) /* both 0's is bad data.. */
@@ -1081,7 +1070,7 @@ void screen_update_desktop_names()
     }
 
     /* resize the pager for these names */
-    pager_popup_text_width_to_strings(desktop_cycle_popup,
+    pager_popup_text_width_to_strings(desktop_popup,
                                       screen_desktop_names,
                                       screen_num_desktops);
 }
index c2c57f09a8a2e1f00e752f2cb460c9adbd6223c2..68a132517b8ac45e1c134b41c4a35b49f4453683 100644 (file)
@@ -72,15 +72,11 @@ void screen_add_desktop(gboolean current);
 /*! Remove a desktop, either at the end or the current desktop */
 void screen_remove_desktop(gboolean current);
 
-/*! Interactively change desktops */
-guint screen_cycle_desktop(ObDirection dir, gboolean wrap, gboolean linear,
-                           gboolean dialog, gboolean done, gboolean cancel);
-
 guint screen_find_desktop(guint from, ObDirection dir,
                           gboolean wrap, gboolean linear);
 
-/*! Show/hide the desktop popup (pager) for the given desktop */
-void screen_desktop_popup(guint d, gboolean show);
+/*! Show the desktop popup/notification */
+void screen_show_desktop_popup(guint d);
 
 /*! Shows and focuses the desktop and hides all the client windows, or
   returns to the normal state, showing client windows.
This page took 0.041684 seconds and 4 git commands to generate.