Advertisement
Guest User

Untitled

a guest
Jan 11th, 2012
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 14.92 KB | None | 0 0
  1. diff --git a/openbox/actions/cyclewindows.c b/openbox/actions/cyclewindows.c
  2. index 5f0db27..5fee534 100644
  3. --- a/openbox/actions/cyclewindows.c
  4. +++ b/openbox/actions/cyclewindows.c
  5. @@ -4,6 +4,7 @@
  6.  #include "openbox/event.h"
  7.  #include "openbox/focus_cycle.h"
  8.  #include "openbox/openbox.h"
  9. +#include "openbox/screen.h"
  10.  #include "gettext.h"
  11.  #include "obt/keyboard.h"
  12.  
  13. @@ -13,7 +14,7 @@ typedef struct {
  14.      gboolean desktop_windows;
  15.      gboolean only_hilite_windows;
  16.      gboolean all_desktops;
  17. -    gboolean forward;
  18. +    int direction;
  19.      gboolean bar;
  20.      gboolean raise;
  21.      ObFocusCyclePopupMode dialog_mode;
  22. @@ -23,6 +24,8 @@ typedef struct {
  23.      /* options for after we're done */
  24.      gboolean cancel; /* did the user cancel or not */
  25.      guint state;     /* keyboard state when finished */
  26. +
  27. +    gint screen_desktop;
  28.  } Options;
  29.  
  30.  static gpointer setup_func(xmlNodePtr node,
  31. @@ -70,6 +73,8 @@ static gpointer setup_func(xmlNodePtr node,
  32.      o->bar = TRUE;
  33.      o->dialog_mode = OB_FOCUS_CYCLE_POPUP_MODE_LIST;
  34.  
  35. +    o->screen_desktop = -1;
  36. +
  37.      if ((n = obt_xml_find_node(node, "linear")))
  38.          o->linear = obt_xml_node_bool(n);
  39.      if ((n = obt_xml_find_node(node, "dialog"))) {
  40. @@ -125,7 +130,7 @@ static gpointer setup_forward_func(xmlNodePtr node,
  41.                                     ObActionsIPostFunc *post)
  42.  {
  43.      Options *o = setup_func(node, pre, input, cancel, post);
  44. -    o->forward = TRUE;
  45. +    o->direction = 1;
  46.      return o;
  47.  }
  48.  
  49. @@ -136,7 +141,7 @@ static gpointer setup_backward_func(xmlNodePtr node,
  50.                                      ObActionsIPostFunc *post)
  51.  {
  52.      Options *o = setup_func(node, pre, input, cancel, post);
  53. -    o->forward = FALSE;
  54. +    o->direction = -1;
  55.      return o;
  56.  }
  57.  
  58. @@ -157,7 +162,10 @@ static gboolean run_func(ObActionsData *data, gpointer options)
  59.      Options *o = options;
  60.      struct _ObClient *ft;
  61.  
  62. -    ft = focus_cycle(o->forward,
  63. +    if (o->screen_desktop < 0)
  64. +        o->screen_desktop = screen_desktop;
  65. +
  66. +    ft = focus_cycle(o->direction,
  67.                       o->all_desktops,
  68.                       !o->only_hilite_windows,
  69.                       o->dock_windows,
  70. @@ -182,6 +190,8 @@ static gboolean i_input_func(guint initial_state,
  71.  {
  72.      Options *o = options;
  73.      guint mods;
  74. +    guint d;
  75. +    struct _ObClient *ft;
  76.  
  77.      mods = obt_keyboard_only_modmasks(e->xkey.state);
  78.      if (e->type == KeyRelease) {
  79. @@ -197,6 +207,9 @@ static gboolean i_input_func(guint initial_state,
  80.          if (sym == XK_Escape) {
  81.              o->cancel = TRUE;
  82.              o->state = e->xkey.state;
  83. +            if (o->screen_desktop >= 0)
  84. +                screen_set_desktop(o->screen_desktop, TRUE, FALSE);
  85. +            o->screen_desktop = -1;
  86.              return FALSE;
  87.          }
  88.  
  89. @@ -206,6 +219,27 @@ static gboolean i_input_func(guint initial_state,
  90.              o->state = e->xkey.state;
  91.              return FALSE;
  92.          }
  93. +
  94. +        else if ((sym == XK_Left || sym == XK_Right) ) {
  95. +            d = screen_find_desktop(screen_desktop,
  96. +                                    sym == XK_Right ? OB_DIRECTION_EAST : OB_DIRECTION_WEST, TRUE, TRUE);
  97. +
  98. +            screen_set_desktop(d, TRUE, FALSE);
  99. +            ft = focus_cycle(0,
  100. +                             o->all_desktops,
  101. +                             !o->only_hilite_windows,
  102. +                             o->dock_windows,
  103. +                             o->desktop_windows,
  104. +                             o->linear,
  105. +                             TRUE,
  106. +                             o->bar,
  107. +                             o->dialog_mode,
  108. +                             FALSE, FALSE);
  109. +            stacking_restore();
  110. +            if (o->raise && ft) stacking_temp_raise(CLIENT_AS_WINDOW(ft));
  111. +            screen_show_desktop_popup(d, FALSE, FALSE);
  112. +            return TRUE;
  113. +        }
  114.      }
  115.      /* They released the modifiers */
  116.      else if (e->type == KeyRelease && initial_state && !(mods & initial_state))
  117. @@ -223,6 +257,10 @@ static void i_cancel_func(gpointer options)
  118.      Options *o = options;
  119.      o->cancel = TRUE;
  120.      o->state = 0;
  121. +
  122. +    if (o->screen_desktop >= 0)
  123. +        screen_set_desktop(o->screen_desktop, TRUE, FALSE);
  124. +    o->screen_desktop = -1;
  125.  }
  126.  
  127.  static void i_post_func(gpointer options)
  128. @@ -230,7 +268,9 @@ static void i_post_func(gpointer options)
  129.      Options *o = options;
  130.      struct _ObClient *ft;
  131.  
  132. -    ft = focus_cycle(o->forward,
  133. +    o->screen_desktop = -1;
  134. +
  135. +    ft = focus_cycle(o->direction,
  136.                       o->all_desktops,
  137.                       !o->only_hilite_windows,
  138.                       o->dock_windows,
  139. diff --git a/openbox/actions/desktop.c b/openbox/actions/desktop.c
  140. index a3a1f6b..7886b7c 100644
  141. --- a/openbox/actions/desktop.c
  142. +++ b/openbox/actions/desktop.c
  143. @@ -302,7 +302,7 @@ static gboolean run_func(ObActionsData *data, gpointer options)
  144.          }
  145.  
  146.          if (go) {
  147. -            screen_set_desktop(d, TRUE);
  148. +            screen_set_desktop(d, TRUE, TRUE);
  149.              if (data->client)
  150.                  client_bring_helper_windows(data->client);
  151.          }
  152. @@ -356,7 +356,7 @@ static gboolean i_pre_func(guint initial_state, gpointer options)
  153.          return FALSE;
  154.      }
  155.      else {
  156. -        screen_show_desktop_popup(screen_desktop, TRUE);
  157. +        screen_show_desktop_popup(screen_desktop, TRUE, TRUE);
  158.          return TRUE;
  159.      }
  160.  }
  161. diff --git a/openbox/client.c b/openbox/client.c
  162. index f3b4bda..feff3a6 100644
  163. --- a/openbox/client.c
  164. +++ b/openbox/client.c
  165. @@ -4029,7 +4029,7 @@ static void client_present(ObClient *self, gboolean here, gboolean raise,
  166.          if (here)
  167.              client_set_desktop(self, screen_desktop, FALSE, TRUE);
  168.          else
  169. -            screen_set_desktop(self->desktop, FALSE);
  170. +            screen_set_desktop(self->desktop, FALSE, TRUE);
  171.      } else if (!self->frame->visible)
  172.          /* if its not visible for other reasons, then don't mess
  173.             with it */
  174. diff --git a/openbox/client_list_combined_menu.c b/openbox/client_list_combined_menu.c
  175. index c26b6fa..f2027e4 100644
  176. --- a/openbox/client_list_combined_menu.c
  177. +++ b/openbox/client_list_combined_menu.c
  178. @@ -126,10 +126,10 @@ static void menu_execute(ObMenuEntry *self, ObMenuFrame *f,
  179.              /* if the window is omnipresent then we need to go to its
  180.                 desktop */
  181.              if (!here && t->desktop == DESKTOP_ALL)
  182. -                screen_set_desktop(self->id, FALSE);
  183. +                screen_set_desktop(self->id, FALSE, TRUE);
  184.          }
  185.          else
  186. -            screen_set_desktop(self->id, TRUE);
  187. +            screen_set_desktop(self->id, TRUE, TRUE);
  188.      }
  189.  }
  190.  
  191. diff --git a/openbox/client_list_menu.c b/openbox/client_list_menu.c
  192. index f3df2a5..0b5af55 100644
  193. --- a/openbox/client_list_menu.c
  194. +++ b/openbox/client_list_menu.c
  195. @@ -106,10 +106,10 @@ static void desk_menu_execute(ObMenuEntry *self, ObMenuFrame *f,
  196.          /* if the window is omnipresent then we need to go to its
  197.             desktop */
  198.          if (!here && t->desktop == DESKTOP_ALL)
  199. -            screen_set_desktop(self->id, FALSE);
  200. +            screen_set_desktop(self->id, FALSE, TRUE);
  201.      }
  202.      else
  203. -        screen_set_desktop(self->id, TRUE);
  204. +        screen_set_desktop(self->id, TRUE, TRUE);
  205.  }
  206.  
  207.  static void desk_menu_destroy(ObMenu *menu, gpointer data)
  208. diff --git a/openbox/event.c b/openbox/event.c
  209. index cf089b6..d9d60a4 100644
  210. --- a/openbox/event.c
  211. +++ b/openbox/event.c
  212. @@ -768,7 +768,7 @@ static void event_handle_root(XEvent *e)
  213.                                    "a timestamp");
  214.                  else
  215.                      event_sourcetime = e->xclient.data.l[1];
  216. -                screen_set_desktop(d, TRUE);
  217. +                screen_set_desktop(d, TRUE, TRUE);
  218.              }
  219.          } else if (msgtype == OBT_PROP_ATOM(NET_NUMBER_OF_DESKTOPS)) {
  220.              guint d = e->xclient.data.l[0];
  221. diff --git a/openbox/focus_cycle.c b/openbox/focus_cycle.c
  222. index 6d4cc2a..1549d6e 100644
  223. --- a/openbox/focus_cycle.c
  224. +++ b/openbox/focus_cycle.c
  225. @@ -92,13 +92,13 @@ void focus_cycle_reorder()
  226.                                                         focus_cycle_linear);
  227.          focus_cycle_update_indicator(focus_cycle_target);
  228.          if (!focus_cycle_target)
  229. -            focus_cycle(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
  230. +            focus_cycle(1, TRUE, TRUE, TRUE, TRUE, TRUE,
  231.                          TRUE, TRUE, OB_FOCUS_CYCLE_POPUP_MODE_NONE,
  232.                          TRUE, TRUE);
  233.      }
  234.  }
  235.  
  236. -ObClient* focus_cycle(gboolean forward, gboolean all_desktops,
  237. +ObClient* focus_cycle(int direction, gboolean all_desktops,
  238.                        gboolean nonhilite_windows,
  239.                        gboolean dock_windows, gboolean desktop_windows,
  240.                        gboolean linear, gboolean interactive,
  241. @@ -140,14 +140,15 @@ ObClient* focus_cycle(gboolean forward, gboolean all_desktops,
  242.          start = it = g_list_find(list, focus_cycle_target);
  243.  
  244.      if (!start) /* switched desktops or something? */
  245. -        start = it = forward ? g_list_last(list) : g_list_first(list);
  246. +        start = it = (direction >= 0) ? g_list_last(list) : g_list_first(list);
  247.      if (!start) goto done_cycle;
  248.  
  249.      do {
  250. -        if (forward) {
  251. +        again:
  252. +        if (direction > 0) {
  253.              it = it->next;
  254.              if (it == NULL) it = g_list_first(list);
  255. -        } else {
  256. +        } else if (direction < 0) {
  257.              it = it->prev;
  258.              if (it == NULL) it = g_list_last(list);
  259.          }
  260. @@ -169,6 +170,11 @@ ObClient* focus_cycle(gboolean forward, gboolean all_desktops,
  261.                  break;
  262.              }
  263.          }
  264. +        if (direction == 0)
  265. +        {
  266. +            direction = 1;
  267. +            goto again;
  268. +        }
  269.      } while (it != start);
  270.  
  271.  done_cycle:
  272. diff --git a/openbox/focus_cycle.h b/openbox/focus_cycle.h
  273. index 9394b3d..f14eb16 100644
  274. --- a/openbox/focus_cycle.h
  275. +++ b/openbox/focus_cycle.h
  276. @@ -35,7 +35,7 @@ void focus_cycle_startup(gboolean reconfig);
  277.  void focus_cycle_shutdown(gboolean reconfig);
  278.  
  279.  /*! Cycle focus amongst windows. */
  280. -struct _ObClient* focus_cycle(gboolean forward, gboolean all_desktops,
  281. +struct _ObClient* focus_cycle(int direction, gboolean all_desktops,
  282.                                gboolean nonhilite_windows,
  283.                                gboolean dock_windows, gboolean desktop_windows,
  284.                                gboolean linear, gboolean interactive,
  285. diff --git a/openbox/moveresize.c b/openbox/moveresize.c
  286. index 3a98db3..a776b7c 100644
  287. --- a/openbox/moveresize.c
  288. +++ b/openbox/moveresize.c
  289. @@ -611,7 +611,7 @@ static gboolean edge_warp_delay_func(gpointer data)
  290.          d = screen_find_desktop(screen_desktop, edge_warp_dir, TRUE, FALSE);
  291.          if (d != screen_desktop) {
  292.              if (config_mouse_screenedgewarp) edge_warp_move_ptr();
  293. -            screen_set_desktop(d, TRUE);
  294. +            screen_set_desktop(d, TRUE, TRUE);
  295.          }
  296.      }
  297.      edge_warp_odd = !edge_warp_odd;
  298. diff --git a/openbox/screen.c b/openbox/screen.c
  299. index ffe74a0..5e69a32 100644
  300. --- a/openbox/screen.c
  301. +++ b/openbox/screen.c
  302. @@ -433,13 +433,13 @@ void screen_startup(gboolean reconfig)
  303.                         NET_CURRENT_DESKTOP, CARDINAL, &d) &&
  304.          d < screen_num_desktops)
  305.      {
  306. -        screen_set_desktop(d, FALSE);
  307. +        screen_set_desktop(d, FALSE, TRUE);
  308.      } else if (session_desktop >= 0)
  309.          screen_set_desktop(MIN((guint)session_desktop,
  310. -                               screen_num_desktops), FALSE);
  311. +                               screen_num_desktops), FALSE, TRUE);
  312.      else
  313.          screen_set_desktop(MIN(config_screen_firstdesk,
  314. -                               screen_num_desktops) - 1, FALSE);
  315. +                               screen_num_desktops) - 1, FALSE, TRUE);
  316.      screen_last_desktop = screen_desktop;
  317.  
  318.      /* don't start in showing-desktop mode */
  319. @@ -553,7 +553,7 @@ void screen_set_num_desktops(guint num)
  320.  
  321.      /* change our desktop if we're on one that no longer exists! */
  322.      if (screen_desktop >= screen_num_desktops)
  323. -        screen_set_desktop(num - 1, TRUE);
  324. +        screen_set_desktop(num - 1, TRUE, TRUE);
  325.  }
  326.  
  327.  static void screen_fallback_focus(void)
  328. @@ -604,7 +604,7 @@ static gboolean last_desktop_func(gpointer data)
  329.      return FALSE; /* don't repeat */
  330.  }
  331.  
  332. -void screen_set_desktop(guint num, gboolean dofocus)
  333. +void screen_set_desktop(guint num, gboolean dofocus, gboolean show_popup)
  334.  {
  335.      GList *it;
  336.      guint previous;
  337. @@ -689,8 +689,8 @@ void screen_set_desktop(guint num, gboolean dofocus)
  338.  
  339.      ob_debug("Moving to desktop %d", num+1);
  340.  
  341. -    if (ob_state() == OB_STATE_RUNNING)
  342. -        screen_show_desktop_popup(screen_desktop, FALSE);
  343. +    if (show_popup && ob_state() == OB_STATE_RUNNING)
  344. +        screen_show_desktop_popup(screen_desktop, FALSE, TRUE);
  345.  
  346.      /* ignore enter events caused by the move */
  347.      ignore_start = event_start_ignore_all_enters();
  348. @@ -941,7 +941,7 @@ static gboolean hide_desktop_popup_func(gpointer data)
  349.      return FALSE; /* don't repeat */
  350.  }
  351.  
  352. -void screen_show_desktop_popup(guint d, gboolean perm)
  353. +void screen_show_desktop_popup(guint d, gboolean perm, gboolean center)
  354.  {
  355.      const Rect *a;
  356.  
  357. @@ -949,8 +949,12 @@ void screen_show_desktop_popup(guint d, gboolean perm)
  358.      if (!config_desktop_popup_time) return;
  359.  
  360.      a = screen_physical_area_primary(FALSE);
  361. -    pager_popup_position(desktop_popup, CenterGravity,
  362. -                         a->x + a->width / 2, a->y + a->height / 2);
  363. +    if (center)
  364. +        pager_popup_position(desktop_popup, CenterGravity,
  365. +                             a->x + a->width / 2, a->y + a->height / 2);
  366. +    else
  367. +        pager_popup_position(desktop_popup, NorthGravity,
  368. +                             a->x + a->width / 2, a->y);
  369.      pager_popup_icon_size_multiplier(desktop_popup,
  370.                                       (screen_desktop_layout.columns /
  371.                                        screen_desktop_layout.rows) / 2,
  372. diff --git a/openbox/screen.h b/openbox/screen.h
  373. index a6a3995..af1aeb2 100644
  374. --- a/openbox/screen.h
  375. +++ b/openbox/screen.h
  376. @@ -66,7 +66,7 @@ void screen_resize(void);
  377.  /*! Change the number of available desktops */
  378.  void screen_set_num_desktops(guint num);
  379.  /*! Change the current desktop */
  380. -void screen_set_desktop(guint num, gboolean dofocus);
  381. +void screen_set_desktop(guint num, gboolean dofocus, gboolean show_popup);
  382.  /*! Add a new desktop either at the end or inserted at the current desktop */
  383.  void screen_add_desktop(gboolean current);
  384.  /*! Remove a desktop, either at the end or the current desktop */
  385. @@ -80,7 +80,7 @@ guint screen_find_desktop(guint from, ObDirection dir,
  386.               screen_hide_desktop_popup().  Otherwise it will hide after a
  387.               delay.
  388.   */
  389. -void screen_show_desktop_popup(guint d, gboolean permanent);
  390. +void screen_show_desktop_popup(guint d, gboolean permanent, gboolean center);
  391.  /*! Hide it */
  392.  void screen_hide_desktop_popup(void);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement