From: Dana Jansens Date: Sat, 4 Aug 2007 00:40:13 +0000 (-0400) Subject: show a popup notification when switching desktops (also make all the config options... X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=3b4b52921adba74472904b37ec13d9c8d8686a10;p=chaz%2Fopenbox show a popup notification when switching desktops (also make all the config options export time in milliseconds not half milli half micro) --- diff --git a/data/rc.xml b/data/rc.xml index ff5830dc..b28bf1a9 100644 --- a/data/rc.xml +++ b/data/rc.xml @@ -116,6 +116,9 @@ desktop 2 --> + 500 + @@ -261,9 +264,9 @@ 200 400 - + diff --git a/data/rc.xsd b/data/rc.xsd index 24a0f91f..adafc5f4 100644 --- a/data/rc.xsd +++ b/data/rc.xsd @@ -89,6 +89,7 @@ + diff --git a/openbox/actions/desktop.c b/openbox/actions/desktop.c index d3a0d0c3..75949be2 100644 --- a/openbox/actions/desktop.c +++ b/openbox/actions/desktop.c @@ -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; } diff --git a/openbox/config.c b/openbox/config.c index 0d6efc92..c7d6db30 100644 --- a/openbox/config.c +++ b/openbox/config.c @@ -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); diff --git a/openbox/config.h b/openbox/config.h index 42bf3534..9d0602e2 100644 --- a/openbox/config.h +++ b/openbox/config.h @@ -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; diff --git a/openbox/dock.c b/openbox/dock.c index 36b08b06..3b32758a 100644 --- a/openbox/dock.c +++ b/openbox/dock.c @@ -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); } diff --git a/openbox/event.c b/openbox/event.c index 522305a8..d31b68c9 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -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 { diff --git a/openbox/screen.c b/openbox/screen.c index 79008e75..7f608b3c 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -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); } diff --git a/openbox/screen.h b/openbox/screen.h index c2c57f09..68a13251 100644 --- a/openbox/screen.h +++ b/openbox/screen.h @@ -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.