Bladeren bron

Merge pull request #43 from kidanger/focus

Configuration du comportement de focus
Martin Duquesnoy 12 jaren geleden
bovenliggende
commit
ef855ae533
3 gewijzigde bestanden met toevoegingen van 19 en 1 verwijderingen
  1. 10 0
      src/config.c
  2. 6 1
      src/event.c
  3. 3 0
      src/wmfs.h

+ 10 - 0
src/config.c

@@ -235,9 +235,19 @@ config_client(void)
      sec = fetch_section_first(NULL, "client");
 
      W->client_mod = modkey_keysym(fetch_opt_first(sec, "Super", "key_modifier").str);
+
+     /* Get theme */
      tmp = fetch_opt_first(sec, "default", "theme").str;
      W->ctheme = name_to_theme(tmp);
 
+     /* Get focus configuration */
+     W->cfocus = 0;
+     tmp = fetch_opt_first(sec, "enter", "focus").str;
+     if(strstr(tmp, "enter"))
+          W->cfocus |= CFOCUS_ENTER;
+     if(strstr(tmp, "click"))
+          W->cfocus |= CFOCUS_CLICK;
+
      /* [mouse] */
      /* for client frame AND titlebar */
      if((mb = fetch_section(sec, "mouse")))

+ 6 - 1
src/event.c

@@ -27,6 +27,7 @@ event_buttonpress(XEvent *e)
      XButtonEvent *ev = &e->xbutton;
      struct mousebind *m;
      struct barwin *b;
+     struct client *c;
 
      screen_update_sel();
      status_flush_surface();
@@ -44,6 +45,9 @@ event_buttonpress(XEvent *e)
 
                break;
           }
+     if((c = client_gb_win(ev->window)) && c != W->client
+         && ev->button == 1 && W->cfocus & CFOCUS_CLICK)
+          client_focus(c);
 }
 
 static void
@@ -67,7 +71,8 @@ event_enternotify(XEvent *e)
                c->flags ^= CLIENT_IGNORE_ENTER;
           else if(c->tag->flags & TAG_IGNORE_ENTER)
                c->tag->flags ^= TAG_IGNORE_ENTER;
-          else if(c != W->client && !(c->flags & CLIENT_TABBED))
+          else if(c != W->client && !(c->flags & CLIENT_TABBED)
+                  && W->cfocus & CFOCUS_ENTER)
                client_focus(c);
      }
 }

+ 3 - 0
src/wmfs.h

@@ -349,6 +349,9 @@ struct wmfs
      char *confpath;
      struct barwin *last_clicked_barwin;
      struct theme *ctheme;
+#define CFOCUS_ENTER 0x01
+#define CFOCUS_CLICK 0x02
+     Flags cfocus; /* Focus configuration, can be set to 0, CFOCUS_ENTER or CFOCUS_CLICK*/
 
      /* Log file */
      FILE *log;