[openbox] sloppy focus?

corey at streamreel.net corey at streamreel.net
Sun Nov 16 11:30:54 EST 2003


On Mon, Nov 17, 2003 at 12:30:30AM -0500, Ben Jansens wrote:
> Progress is generally not achieved by duplicating other efforts. 
>

  Progress is achieved by keeping (duplicating) the good, and ditching the 
  bad - while trying not to make things worse in the process.

 
> I was trying to make FFM better. 
>

  Cool - I'm all for innovation as well... and you're obviously a skilled
  programmer; it shows in obenbox, which is why ob2 & 3 have been my favorite
  wm's. But are you still trying to make FFM better, or do you believe your 
  current implementation is a success? I think it could use a just little more
  fine-tuning.


> I think its a horrid hack in the first place
> designed by engineers, not "user-interface aware" people of any kind. :)
> 

  I'm simply an enduser, with engineer tendencies, who very much likes the 
  current standard ffm model that all other wm's seem to be using without
  issue.


> The idea is that you don't want windows to raise right away because you want
> the window you are going to to be raised, and not the windows in between.
> This way the stacking order is preserved even though you flicked your mouse
> across them.
> 

  Agreed - thus was born the simple and effective "autoRaiseDelay" concept.


> I applied this same logic to the focus order, which was not even present
> when FFM was first applied to WMs. You want to the window you are going to
> be using to be moved to the front of the focus order, not all the windows in
> between.
> 

  Again, our friendly neighborhood "autoRaiseDelay" is here for us. 

  We're still on the same page at this point.


> When you are using auto-raise, I think in the general case it is safe to
> assume you are meaning for the window to raise for you to use it, you are
> not intending to use the window without raising it, like in plain old FFM.
>

  This is quite a leap of an assumption. In essence, you're telling ob3 
  endusers that this is how they should operate. I agree that _generally_,
  yes, what you say is most often likely the case - but not always, and
  not enough to altogether disable that ability for those instances.

  In fact


> So in this spirit, I grouped the two delays together, meaning it became
> instead of a raise delay, more of a "use the window under the mouse" delay
> to let to flick across windows without messing things up.
> 

  In practice, really, what you did was implement a "focus delay". Which obviously
  seems to be a useful and preferred feature/model for at least a couple people - 
  including yourself I take it. 

  That's great, but can't we likewise make available the "raise delay" behavior
  as well?

  If this is how you feel it should work, then may I at least suggest labeling 
  and describing it something more suggestive of its actual effect? Perhaps
  call it "focus_under_mouse", or "focus_on_raise". If nothing else, accurate 
  semantics may foster clearer understanding of the behavior.

  ... Ok - I just figured the hell with it; attached is another patch. 

  How about this:

  We introduce the concept of a "lazy focus" and a "sloppy focus". Lazy focus
  operates in the current manner, and sloppy focus operates in the manner that 
  all the other wm's conform to. 
  
  The ObConf "Behavior" tab might then look something this:


===================================================================

Focusing Windows

  |__| Focus windows when the mouse pointer moves over them

         Delay before focusing windows ("Lazy Focus"): |___|

         |__| Focus strictly follows mouse ("Sloppy Focus")
                Delay before raising windows: |___|

         |__| Raise windows when the mouse pointer moves over them

  |__| Focus new windows when they appear

===================================================================


  You can only use one of two models ( while one is selected, the other will
  grey out ), the default can be Lazy Focus.

  The 'focus' container element in the rc.xml will recieve two new properties:
  "lazyFocus" and "sloppyFocus". Also, we'll add a "raiseDelay" - just to keep
  things descriptive, so their labels actualy represent their functions. 

  Here's a snippet:

<focus>
  <focusNew>yes</focusNew>
  <followMouse>yes</followMouse>
  <raiseOnFocus>yes</raiseOnFocus>
  <sloppyFocus>yes</sloppyFocus>
  <focusDelay>450</focusDelay>
  <!-- <lazyFocus>yes</lazyFocus>   -->
  <!-- <raiseDelay>450</raiseDelay> -->
</focus>


  Will this work?  Please look at the patch and try it out. I deserve at least
  that much, eh?


> I would ask you to try a little experiment for me :) Try shortening the
> delay so that it is just longer than the amount of time you use to flick the
> mouse across the screen, no extra time to dawdle :) See if shortening this
> time does not let you use the new approach. It may mean adjusting to it a
> little bit, but moving from a bad interface to a good one usually will.
> 

  I already did try this method, and a couple others, for a few weeks now. I
  finaly got tired of it and asked whether the behavior I'm used to was
  actualy available. The answer was "no, hack the code or mod your habits".
  So I spent the time to review the codebase, considered what I thought was
  a decent approach, hacked around, tested, and submitted what turned out to
  be a very small patch. [edit: and now I've just submitted a new one...]

  Have you tried ob3's ffm model on a laptop, with a touchpad, with a very
  high resolution screen, and small fonts? Trust me, a decent delay is 
  required, as sometimes ( but not always ) it takes a few extra moments to
  navigate - especialy when interacting with multiple small windows and
  whatnot. No, I don't think I should just use a lower res and/or a larger font...


> Maybe I am wrong of course and it will just suck horribly, but I'd
> appreciate it if you gave it a try for a bit and see if it can't turn out or
> not. Also, maybe you will come to know and love Alt-Tab cycling which
> suddenly becomes feasible for you to use :)
> 

  I like Alt-Tab, I use it often but not always.


<snip>
> Anyhow enough typing and more playing warcraft :)
> 

  (c8=


G'night,

Corey

-------------- next part --------------
*** openbox-3.0/openbox/config.h	Wed Oct 15 03:57:31 2003
--- ob3-sandbox/openbox/config.h	Sun Nov 16 14:41:15 2003
***************
*** 31,38 ****
  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 */
! extern guint    config_focus_delay;
  /*! If windows should automatically be raised when they are focused in
   focus follows mouse */
  extern guint    config_focus_raise;
--- 31,43 ----
  extern gboolean config_focus_new;
  /*! Focus windows when the mouse enters them */
  extern gboolean config_focus_follow;
! /*! Window focus after delay ("lazy focus") */
! extern gboolean config_lazy_focus;
! /*! Window focus strictly follows mouse ("sloppy focus") */
! extern gboolean config_sloppy_focus;
! /*! Timeout for focusing (lazy focus) or raising (sloppy focus) windows on 
!  focus follows mouse, in microseconds */
! extern guint    config_delay_timer;
  /*! If windows should automatically be raised when they are focused in
   focus follows mouse */
  extern guint    config_focus_raise;
--- openbox-3.0/openbox/config.c	2003-10-25 19:37:58.000000000 +0000
+++ ob3-sandbox/openbox/config.c	2003-11-16 14:49:42.958649776 +0000
@@ -26,7 +26,9 @@
 
 gboolean config_focus_new;
 gboolean config_focus_follow;
-guint    config_focus_delay;
+gboolean config_lazy_focus;
+gboolean config_sloppy_focus;
+guint    config_delay_timer;
 guint    config_focus_raise;
 
 ObPlacePolicy config_place_policy;
@@ -200,8 +202,14 @@
         config_focus_new = parse_bool(doc, n);
     if ((n = parse_find_node("followMouse", node)))
         config_focus_follow = parse_bool(doc, n);
+    if ((n = parse_find_node("lazyFocus", node)))
+        config_lazy_focus = parse_bool(doc, n);
     if ((n = parse_find_node("focusDelay", node)))
-        config_focus_delay = parse_int(doc, n) * 1000;
+        config_delay_timer = parse_int(doc, n) * 1000;
+    if ((n = parse_find_node("sloppyFocus", node)))
+        config_sloppy_focus = parse_bool(doc, n);
+    if ((n = parse_find_node("raiseDelay", node)))
+        config_delay_timer = parse_int(doc, n) * 1000;
     if ((n = parse_find_node("raiseOnFocus", node)))
         config_focus_raise = parse_bool(doc, n);
 }
@@ -486,7 +494,9 @@
 {
     config_focus_new = TRUE;
     config_focus_follow = FALSE;
-    config_focus_delay = 0;
+    config_lazy_focus = FALSE;
+    config_sloppy_focus = FALSE;
+    config_delay_timer = 0;
     config_focus_raise = FALSE;
 
     parse_register(i, "focus", parse_focus, NULL);
*** openbox-3.0/openbox/config.h	Wed Oct 15 03:57:31 2003
--- ob3-sandbox/openbox/config.h	Sun Nov 16 14:41:15 2003
***************
*** 31,38 ****
  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 */
! extern guint    config_focus_delay;
  /*! If windows should automatically be raised when they are focused in
   focus follows mouse */
  extern guint    config_focus_raise;
--- 31,43 ----
  extern gboolean config_focus_new;
  /*! Focus windows when the mouse enters them */
  extern gboolean config_focus_follow;
! /*! Focus when raised */
! extern gboolean config_lazy_focus;
! /*! Window focus strictly follows mouse */
! extern gboolean config_sloppy_focus;
! /*! Timeout for focusing (lazy focus) or raising (sloppy focus) windows on 
!  focus follows mouse, in microseconds */
! extern guint    config_delay_timer;
  /*! If windows should automatically be raised when they are focused in
   focus follows mouse */
  extern guint    config_focus_raise;
*** openbox-3.0/openbox/config.c	Sat Oct 25 19:37:58 2003
--- ob3-sandbox/openbox/config.c	Sun Nov 16 14:49:42 2003
***************
*** 26,32 ****
  
  gboolean config_focus_new;
  gboolean config_focus_follow;
! guint    config_focus_delay;
  guint    config_focus_raise;
  
  ObPlacePolicy config_place_policy;
--- 26,34 ----
  
  gboolean config_focus_new;
  gboolean config_focus_follow;
! gboolean config_lazy_focus;
! gboolean config_sloppy_focus;
! guint    config_delay_timer;
  guint    config_focus_raise;
  
  ObPlacePolicy config_place_policy;
***************
*** 200,207 ****
          config_focus_new = parse_bool(doc, n);
      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;
      if ((n = parse_find_node("raiseOnFocus", node)))
          config_focus_raise = parse_bool(doc, n);
  }
--- 202,215 ----
          config_focus_new = parse_bool(doc, n);
      if ((n = parse_find_node("followMouse", node)))
          config_focus_follow = parse_bool(doc, n);
+     if ((n = parse_find_node("lazyFocus", node)))
+         config_lazy_focus = parse_bool(doc, n);
      if ((n = parse_find_node("focusDelay", node)))
!         config_delay_timer = parse_int(doc, n) * 1000;
!     if ((n = parse_find_node("sloppyFocus", node)))
!         config_sloppy_focus = parse_bool(doc, n);
!     if ((n = parse_find_node("raiseDelay", node)))
!         config_delay_timer = parse_int(doc, n) * 1000;
      if ((n = parse_find_node("raiseOnFocus", node)))
          config_focus_raise = parse_bool(doc, n);
  }
***************
*** 486,492 ****
  {
      config_focus_new = TRUE;
      config_focus_follow = FALSE;
!     config_focus_delay = 0;
      config_focus_raise = FALSE;
  
      parse_register(i, "focus", parse_focus, NULL);
--- 494,502 ----
  {
      config_focus_new = TRUE;
      config_focus_follow = FALSE;
!     config_lazy_focus = FALSE;
!     config_sloppy_focus = FALSE;
!     config_delay_timer = 0;
      config_focus_raise = FALSE;
  
      parse_register(i, "focus", parse_focus, NULL);
*** openbox-3.0/openbox/event.c	Sat Oct 18 21:41:15 2003
--- ob3-sandbox/openbox/event.c	Sun Nov 16 14:33:17 2003
***************
*** 551,564 ****
      g_assert(config_focus_follow);
  
      if (client_normal(client) && client_can_focus(client)) {
!         if (config_focus_delay) {
!             ob_main_loop_timeout_remove(ob_main_loop, focus_delay_func);
!             ob_main_loop_timeout_add(ob_main_loop,
!                                      config_focus_delay,
!                                      focus_delay_func,
!                                      client, NULL);
!         } else
!             focus_delay_func(client);
      }
  }
  
--- 551,570 ----
      g_assert(config_focus_follow);
  
      if (client_normal(client) && client_can_focus(client)) {
! 
!         if (focus_client != client) {
! 	    if (config_sloppy_focus)
!                 client_focus(client);
! 
!            if (config_delay_timer) {
!                ob_main_loop_timeout_remove(ob_main_loop, focus_delay_func);
!                ob_main_loop_timeout_add(ob_main_loop,
!                                         config_delay_timer,
!                                         focus_delay_func,
!                                         client, NULL);
!            } else
! 	      focus_delay_func(client);
! 	}
      }
  }
  
***************
*** 652,658 ****
              frame_adjust_state(client->frame);
              break;
          case OB_FRAME_CONTEXT_FRAME:
!             if (config_focus_follow && config_focus_delay)
                  ob_main_loop_timeout_remove_data(ob_main_loop,
                                                   focus_delay_func,
                                                   client);
--- 658,664 ----
              frame_adjust_state(client->frame);
              break;
          case OB_FRAME_CONTEXT_FRAME:
!             if (config_focus_follow && config_delay_timer)
                  ob_main_loop_timeout_remove_data(ob_main_loop,
                                                   focus_delay_func,
                                                   client);
***************
*** 1205,1215 ****
  {
      ObClient *c = data;
  
!     if (focus_client != c) {
!         client_focus(c);
!         if (config_focus_raise)
!             client_raise(c);
!     }
      return FALSE; /* no repeat */
  }
  
--- 1211,1221 ----
  {
      ObClient *c = data;
  
!     if (config_focus_raise)
!         if (config_lazy_focus)
! 	    client_focus(c);
!         client_raise(c);
!     
      return FALSE; /* no repeat */
  }
  


More information about the openbox mailing list