]> git.lizzy.rs Git - bspwm.git/commitdiff
Merge branch 'master' into focus-history
authorBastien Dejean <nihilhill@gmail.com>
Sat, 19 Jan 2013 20:45:05 +0000 (21:45 +0100)
committerBastien Dejean <nihilhill@gmail.com>
Sat, 19 Jan 2013 20:45:05 +0000 (21:45 +0100)
1  2 
messages.c
tree.c
tree.h
types.c
types.h
window.c
window.h

diff --cc messages.c
index ade3aa04d886b36d478826a3e1b2df61a44340ed,fab5fc9140238453d40d966a6631a5ad18e5203f..680ab2ba6a202dd386df80a23fc8c2f9868e0c79
@@@ -45,8 -54,8 +54,10 @@@ void process_message(char *msg, char *r
      } else if (strcmp(cmd, "list_windows") == 0) {
          list_windows(rsp);
          return;
 +    } else if (strcmp(cmd, "list_history") == 0) {
 +        list_history(mon->desk, rsp);
+     } else if (strcmp(cmd, "list_rules") == 0) {
+         list_rules(rsp);
          return;
      } else if (strcmp(cmd, "close") == 0) {
          window_close(mon->desk->focus);
          if (name != NULL) {
              rule_t *rule = make_rule();
              strncpy(rule->cause.name, name, sizeof(rule->cause.name));
-             char *arg = strtok(NULL, TOKEN_SEP);
+             char *arg = strtok(NULL, TOK_SEP);
              while (arg != NULL) {
-                 if (strcmp(arg, "floating") == 0)
+                 if (strcmp(arg, "floating") == 0) {
                      rule->effect.floating = true;
-                 arg = strtok(NULL, TOKEN_SEP);
+                 } else {
+                     desktop_location_t loc;
+                     if (locate_desktop(arg, &loc)) {
+                         rule->effect.monitor = loc.monitor;
+                         rule->effect.desktop = loc.desktop;
+                     }
+                 }
+                 arg = strtok(NULL, TOK_SEP);
              }
-             rule->next = rule_head;
-             rule_head = rule;
+             add_rule(rule);
          }
          return;
+     } else if (strcmp(cmd, "remove_rule") == 0) {
+         char *arg;
+         unsigned int uid;
+         while ((arg = strtok(NULL, TOK_SEP)) != NULL)
+             if (sscanf(arg, "%X", &uid) > 0)
+                 remove_rule_by_uid(uid);
+         return;
+     } else if (strcmp(cmd, "swap") == 0) {
+         swap_nodes(mon->desk->focus, mon->desk->last_focus);
      } else if (strcmp(cmd, "alternate") == 0) {
 -        focus_node(mon, mon->desk, mon->desk->last_focus, true);
 +        node_list_t *a = mon->desk->focus_history->head->prev;
 +        if (a != NULL)
 +            focus_node(mon, mon->desk, a->node, true);
+         return;
      } else if (strcmp(cmd, "alternate_desktop") == 0) {
          select_desktop(mon->last_desk);
      } else if (strcmp(cmd, "alternate_monitor") == 0) {
diff --cc tree.c
index 603a52b1f882191041cff626edf0b9a488108965,09957231c5cb830dc36a225b211c918aeef6c488..35239dc70897482ffbdb2342bd8eb0b2d05cd1e5
--- 1/tree.c
--- 2/tree.c
+++ b/tree.c
@@@ -166,121 -167,19 +167,28 @@@ void rotate_tree(node_t *n, rotate_t ro
      rotate_tree(n->second_child, rot);
  }
  
- void magnetise_tree(node_t *n, corner_t corner)
- {
-     if (n == NULL || is_leaf(n))
-         return;
-     PUTS("magnetise tree");
-     switch (n->split_type) {
-         case TYPE_HORIZONTAL:
-             if (corner == TOP_LEFT || corner == TOP_RIGHT)
-                 change_split_ratio(n, CHANGE_DECREASE);
-             else
-                 change_split_ratio(n, CHANGE_INCREASE);
-             break;
-         case TYPE_VERTICAL:
-             if (corner == TOP_LEFT || corner == BOTTOM_LEFT)
-                 change_split_ratio(n, CHANGE_DECREASE);
-             else
-                 change_split_ratio(n, CHANGE_INCREASE);
-             break;
-         default:
-             break;
-     }
-     magnetise_tree(n->first_child, corner);
-     magnetise_tree(n->second_child, corner);
- }
- void dump_tree(desktop_t *d, node_t *n, char *rsp, unsigned int depth)
- {
-     if (n == NULL)
-         return;
-     char line[MAXLEN];
-     for (unsigned int i = 0; i < depth; i++)
-         strncat(rsp, "  ", REMLEN(rsp));
-     if (is_leaf(n))
-         snprintf(line, sizeof(line), "%s %X %s%s%s%s%s", n->client->class_name, n->client->window, (n->client->floating ? "f" : "-"), (n->client->transient ? "t" : "-"), (n->client->fullscreen ? "F" : "-"), (n->client->urgent ? "u" : "-"), (n->client->locked ? "l" : "-"));
-     else
-         snprintf(line, sizeof(line), "%s %.2f", (n->split_type == TYPE_HORIZONTAL ? "H" : "V"), n->split_ratio);
-     strncat(rsp, line, REMLEN(rsp));
-     if (n == d->focus)
-         strncat(rsp, " *\n", REMLEN(rsp));
-     else
-         strncat(rsp, "\n", REMLEN(rsp));
-     dump_tree(d, n->first_child, rsp, depth + 1);
-     dump_tree(d, n->second_child, rsp, depth + 1);
- }
- void refresh_current(void) {
-     if (mon->desk->focus == NULL)
-         ewmh_update_active_window();
-     else
-         focus_node(mon, mon->desk, mon->desk->focus, true);
- }
- void list_monitors(list_option_t opt, char *rsp)
- {
-     monitor_t *m = mon_head;
-     while (m != NULL) {
-         strncat(rsp, m->name, REMLEN(rsp));
-         if (mon == m)
-             strncat(rsp, " #\n", REMLEN(rsp));
-         else
-             strncat(rsp, "\n", REMLEN(rsp));
-         if (opt == LIST_OPTION_VERBOSE)
-             list_desktops(m, opt, 1, rsp);
-         m = m->next;
-     }
- }
- void list_desktops(monitor_t *m, list_option_t opt, unsigned int depth, char *rsp)
- {
-     desktop_t *d = m->desk_head;
-     while (d != NULL) {
-         for (unsigned int i = 0; i < depth; i++)
-             strncat(rsp, "  ", REMLEN(rsp));
-         strncat(rsp, d->name, REMLEN(rsp));
-         if (m->desk == d)
-             strncat(rsp, " @\n", REMLEN(rsp));
-         else
-             strncat(rsp, "\n", REMLEN(rsp));
-         if (opt == LIST_OPTION_VERBOSE)
-             dump_tree(d, d->root, rsp, depth + 1);
-         d = d->next;
-     }
- }
  
 +void list_history(desktop_t *d, char *rsp)
 +{
 +    char line[MAXLEN];
 +    for (node_list_t *a = d->focus_history->head; a != NULL; a = a->prev) {
 +        snprintf(line, sizeof(line), "%s %X\n", a->node->client->class_name, a->node->client->window);
 +        strncat(rsp, line, REMLEN(rsp));
 +    }
 +}
 +
  void arrange(monitor_t *m, desktop_t *d)
  {
-     PRINTF("arrange %s:%s\n", m->name, d->name);
+     PRINTF("arrange %s%s%s\n", (num_monitors > 1 ? m->name : ""), (num_monitors > 1 ? " " : ""), d->name);
  
      xcb_rectangle_t rect = m->rectangle;
-     rect.x += left_padding + window_gap;
-     rect.y += top_padding + window_gap;
-     rect.width -= left_padding + right_padding + window_gap;
-     rect.height -= top_padding + bottom_padding + window_gap;
-     if (focus_follows_mouse)
-         get_pointer_position(&pointer_position);
+     int wg = (gapless_monocle && d->layout == LAYOUT_MONOCLE ? 0 : window_gap);
+     rect.x += m->left_padding + wg;
+     rect.y += m->top_padding + wg;
+     rect.width -= m->left_padding + m->right_padding + wg;
+     rect.height -= m->top_padding + m->bottom_padding + wg;
+     if (focus_follows_pointer)
+         save_pointer_position(&last_pointer_position);
      apply_layout(m, d, d->root, rect, rect);
  }
  
@@@ -464,12 -370,29 +379,29 @@@ void focus_node(monitor_t *m, desktop_
          xcb_set_input_focus(dpy, XCB_INPUT_FOCUS_POINTER_ROOT, n->client->window, XCB_CURRENT_TIME);
      }
  
-     if (!is_tiled(n->client))
-         window_raise(n->client->window);
+     if (focus_follows_pointer) {
+         save_pointer_position(&last_pointer_position);
+         if (n != mon->desk->focus) {
+             if (last_focused_window != XCB_NONE) {
+                 uint32_t values[] = {CLIENT_EVENT_MASK_FFP};
+                 xcb_change_window_attributes(dpy, last_focused_window, XCB_CW_EVENT_MASK, values);
+             }
+             uint32_t values[] = {CLIENT_EVENT_MASK};
+             xcb_change_window_attributes(dpy, n->client->window, XCB_CW_EVENT_MASK, values);
+             last_focused_window = n->client->window;
+         }
+     }
+     if (!is_tiled(n->client)) {
+         if (!adaptative_raise || !might_cover(d, n))
+             window_raise(n->client->window);
+     } else {
+         window_pseudo_raise(d, n->client->window);
+     }
  
      if (d->focus != n) {
 -        d->last_focus = d->focus;
          d->focus = n;
 +        history_add(d->focus_history, n);
      }
  
      ewmh_update_active_window();
diff --cc tree.h
index df7a2bb834e9b49adc2393eb4ce5f46db23e8037,ad076e6ad472bfa8a763ee231faeb8bc7175ac89..12a745b2941864c314de9831b1d3499d29889cd3
--- 1/tree.h
--- 2/tree.h
+++ b/tree.h
@@@ -42,8 -37,10 +37,11 @@@ void cycle_leaf(monitor_t *, desktop_t 
  void nearest_leaf(monitor_t *, desktop_t *, node_t *, nearest_arg_t, skip_client_t);
  void circulate_leaves(monitor_t *, desktop_t *, circulate_dir_t);
  void update_vacant_state(node_t *);
- void add_desktop(monitor_t *, char *);
- void add_monitor(xcb_rectangle_t *);
- monitor_t *find_monitor(char *);
+ void put_status(void);
++void list_history(desktop_t *, char *);
+ void list_monitors(list_option_t, char *);
+ void list_desktops(monitor_t *, list_option_t, unsigned int, char *);
+ void list(desktop_t *, node_t *, char *, unsigned int);
+ void restore(char *);
  
  #endif
diff --cc types.c
Simple merge
diff --cc types.h
index f8016437c7e3901ef4b1b5bab8d664439150f11d,199ef727267fca90b135e67330a03072c99db887..16bab1412f59b8412da352fdcbdc38d6fd11f424
+++ b/types.h
@@@ -191,13 -198,15 +211,19 @@@ typedef struct 
  
  node_t *make_node(void);
  monitor_t *make_monitor(xcb_rectangle_t *);
+ monitor_t *find_monitor(char *);
+ void add_monitor(xcb_rectangle_t *);
+ void remove_monitor(monitor_t *);
  desktop_t *make_desktop(const char *);
+ void add_desktop(monitor_t *, char *);
+ void empty_desktop(desktop_t *);
+ void remove_desktop(monitor_t *, desktop_t *);
  client_t *make_client(xcb_window_t);
 +focus_history_t *make_focus_history(void);
 +node_list_t *make_node_list(void);
  rule_t *make_rule(void);
  pointer_state_t *make_pointer_state(void);
 +void history_add(focus_history_t *, node_t *);
 +void history_remove(focus_history_t *, node_t *);
  
  #endif
diff --cc window.c
Simple merge
diff --cc window.h
index 9fc5407f07a830401a69f9d59e7ee9d58325aa63,dc8a2cb20abafaabf8bec95d475ba6c06983362d..abf85f79d92bd30707dc111ace0aa4c2c5280e1c
+++ b/window.h
@@@ -19,9 -27,10 +27,11 @@@ void disable_shadow(xcb_window_t)
  void window_border_width(xcb_window_t, uint32_t);
  void window_move(xcb_window_t, int16_t, int16_t);
  void window_move_resize(xcb_window_t, int16_t, int16_t, uint16_t, uint16_t);
+ void window_focus(xcb_window_t);
  void window_raise(xcb_window_t);
+ void window_pseudo_raise(desktop_t *, xcb_window_t);
  void window_lower(xcb_window_t);
 +void window_pseudo_raise(desktop_t *, xcb_window_t);
  void window_set_visibility(xcb_window_t, bool);
  void window_hide(xcb_window_t);
  void window_show(xcb_window_t);