From b3764dd433f8e8511bf3045e4ea5e0e5df6b2a70 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sat, 5 Jan 2008 12:40:46 +0100 Subject: Don't record desktops for lastdesktop when switching away quickly again. When switching desktops, only record the previous desktop as the last desktop if the user stayed there for a while. This way you can scroll over a couple desktops quickly, then go back to the previous desktop you _used_, not the last you scrolled past. --- openbox/screen.c | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) (limited to 'openbox/screen.c') diff --git a/openbox/screen.c b/openbox/screen.c index a8da15c0..e81b9590 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -59,7 +59,9 @@ static void screen_fallback_focus(void); guint screen_num_desktops; guint screen_num_monitors; guint screen_desktop; -guint screen_last_desktop; +guint screen_last_desktop = 1; +guint screen_old_desktop; +gboolean screen_desktop_timeout = TRUE; Size screen_physical_size; gboolean screen_showing_desktop; ObDesktopLayout screen_desktop_layout; @@ -577,23 +579,61 @@ static void screen_fallback_focus(void) } } +static gboolean last_desktop_func(gpointer data) +{ + screen_desktop_timeout = TRUE; + return FALSE; +} + void screen_set_desktop(guint num, gboolean dofocus) { GList *it; - guint old; + guint previous; gulong ignore_start; g_assert(num < screen_num_desktops); - old = screen_desktop; + previous = screen_desktop; screen_desktop = num; - if (old == num) return; + if (previous == num) return; PROP_SET32(RootWindow(ob_display, ob_screen), net_current_desktop, cardinal, num); - screen_last_desktop = old; + if (screen_desktop_timeout) { + if (screen_desktop == screen_last_desktop) { + screen_last_desktop = previous; + screen_old_desktop = screen_desktop; + } else { + screen_old_desktop = screen_last_desktop; + screen_last_desktop = previous; + } + } else { + if (screen_desktop == screen_last_desktop) { + if (previous == screen_old_desktop) { + screen_last_desktop = screen_old_desktop; + } else if (screen_last_desktop == screen_old_desktop) { + screen_last_desktop = previous; + } else { + screen_last_desktop = screen_old_desktop; + } + } else { + if (screen_desktop == screen_old_desktop) { + /* do nothing */ + } else if (previous == screen_old_desktop) { + /* do nothing */ + } else if (screen_last_desktop == screen_old_desktop) { + screen_last_desktop = previous; + } else { + /* do nothing */ + } + } + } + screen_desktop_timeout = FALSE; + ob_main_loop_timeout_remove(ob_main_loop, last_desktop_func); + ob_main_loop_timeout_add(ob_main_loop, 500000, last_desktop_func, + NULL, NULL, NULL); ob_debug("Moving to desktop %d\n", num+1); -- cgit v1.2.3 From 8a2adbb0585dfc150c4809327a2c41265174b533 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 11 Jan 2008 16:49:55 -0500 Subject: make the time to remember last desktop a #define, and make it 750ms --- openbox/screen.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'openbox/screen.c') diff --git a/openbox/screen.c b/openbox/screen.c index e81b9590..5e0f67d4 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -79,6 +79,10 @@ static GSList *struts_bottom = NULL; static ObPagerPopup *desktop_popup; +/*! The number of microseconds that you need to be on a desktop before it will + replace the remembered "last desktop" */ +#define REMEMBER_LAST_DESKTOP_TIME 750000 + static gboolean replace_wm(void) { gchar *wm_sn; @@ -632,8 +636,8 @@ void screen_set_desktop(guint num, gboolean dofocus) } screen_desktop_timeout = FALSE; ob_main_loop_timeout_remove(ob_main_loop, last_desktop_func); - ob_main_loop_timeout_add(ob_main_loop, 500000, last_desktop_func, - NULL, NULL, NULL); + ob_main_loop_timeout_add(ob_main_loop, REMEMBER_LAST_DESKTOP_TIME, + last_desktop_func, NULL, NULL, NULL); ob_debug("Moving to desktop %d\n", num+1); -- cgit v1.2.3 From 6133bbd5f732622d8d5650d262413429c38af842 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 11 Jan 2008 17:24:13 -0500 Subject: try to comment the code for when to save the "last desktop" --- openbox/screen.c | 63 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 17 deletions(-) (limited to 'openbox/screen.c') diff --git a/openbox/screen.c b/openbox/screen.c index 5e0f67d4..379a12d8 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -605,32 +605,61 @@ void screen_set_desktop(guint num, gboolean dofocus) PROP_SET32(RootWindow(ob_display, ob_screen), net_current_desktop, cardinal, num); + /* This whole thing decides when/how to save the screen_last_desktop so + that it can be restored later if you want */ if (screen_desktop_timeout) { + /* If screen_desktop_timeout is true, then we've been on this desktop + long enough and we can save it as the last desktop. */ + + /* save the "last desktop" as the "old desktop" */ + screen_old_desktop = screen_last_desktop; + /* save the desktop we're coming from as the "last desktop" */ + screen_last_desktop = previous; + } + else { + /* If screen_desktop_timeout is false, then we just got to this desktop + and we are moving away again. */ + if (screen_desktop == screen_last_desktop) { - screen_last_desktop = previous; - screen_old_desktop = screen_desktop; - } else { - screen_old_desktop = screen_last_desktop; - screen_last_desktop = previous; - } - } else { - if (screen_desktop == screen_last_desktop) { + /* If we are moving to the "last desktop" .. */ if (previous == screen_old_desktop) { + /* .. from the "old desktop", change the last desktop to + be where we are coming from */ screen_last_desktop = screen_old_desktop; - } else if (screen_last_desktop == screen_old_desktop) { + } + else if (screen_last_desktop == screen_old_desktop) { + /* .. and also to the "old desktop", change the "last + desktop" to be where we are coming from */ screen_last_desktop = previous; - } else { + } + else { + /* .. from some other desktop, then set the "last desktop" to + be the saved "old desktop", i.e. where we were before the + "last desktop" */ screen_last_desktop = screen_old_desktop; } - } else { + } + else { + /* If we are moving to any desktop besides the "last desktop".. + (this is the normal case) */ if (screen_desktop == screen_old_desktop) { - /* do nothing */ - } else if (previous == screen_old_desktop) { - /* do nothing */ - } else if (screen_last_desktop == screen_old_desktop) { + /* If moving to the "old desktop", which is not the + "last desktop", don't save anything */ + } + else if (previous == screen_old_desktop) { + /* If moving from the "old desktop", and not to the + "last desktop", don't save anything */ + } + else if (screen_last_desktop == screen_old_desktop) { + /* If the "last desktop" is the same as "old desktop" and + you're not moving to the "last desktop" then save where + we're coming from as the "last desktop" */ screen_last_desktop = previous; - } else { - /* do nothing */ + } + else { + /* If the "last desktop" is different from the "old desktop" + and you're not moving to the "last desktop", then don't save + anything */ } } } -- cgit v1.2.3 From ba6dcc15f8893b1d72f185e838c3d34c62f335b4 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Wed, 16 Jan 2008 00:24:56 -0500 Subject: add the new pid and ping atoms to the NET_SUPPORTED list --- openbox/screen.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'openbox/screen.c') diff --git a/openbox/screen.c b/openbox/screen.c index 379a12d8..b88562fe 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -289,6 +289,8 @@ gboolean screen_annex(void) supported[i++] = prop_atoms.net_wm_sync_request; supported[i++] = prop_atoms.net_wm_sync_request_counter; #endif + supported[i++] = prop_atoms.net_wm_pid; + supported[i++] = prop_atoms.net_wm_ping; supported[i++] = prop_atoms.kde_wm_change_state; supported[i++] = prop_atoms.kde_net_wm_frame_strut; -- cgit v1.2.3 From 0be98fee4743c795b06aa23881b82eff5bab3ef6 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Wed, 16 Jan 2008 15:25:08 +0100 Subject: Various fixes for sparse warnings. Define void functions with (void), not (). Add missing includes. Some functions were declared static but defined non-static. Some variables that should be file static were file global but not used in any other file. prop.h defined a new prop_atoms in each file that included it instead of declaring it extern. --- openbox/screen.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'openbox/screen.c') diff --git a/openbox/screen.c b/openbox/screen.c index b88562fe..e008ffe5 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -60,15 +60,15 @@ guint screen_num_desktops; guint screen_num_monitors; guint screen_desktop; guint screen_last_desktop = 1; -guint screen_old_desktop; -gboolean screen_desktop_timeout = TRUE; -Size screen_physical_size; gboolean screen_showing_desktop; ObDesktopLayout screen_desktop_layout; gchar **screen_desktop_names; Window screen_support_win; Time screen_desktop_user_time = CurrentTime; +static Size screen_physical_size; +static guint screen_old_desktop; +static gboolean screen_desktop_timeout = TRUE; /*! An array of desktops, holding array of areas per monitor */ static Rect *monitor_area = NULL; /*! An array of desktops, holding an array of struts */ -- cgit v1.2.3