client.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /*
  2. * wmfs2 by Martin Duquesnoy <xorg62@gmail.com> { for(i = 2011; i < 2111; ++i) ©(i); }
  3. * For license, see COPYING.
  4. */
  5. #ifndef CLIENT_H
  6. #define CLIENT_H
  7. #include "wmfs.h"
  8. #include "layout.h"
  9. #include "ewmh.h"
  10. #include "util.h"
  11. #define TCLIENT_CHECK(C) (C->flags & CLIENT_TABBED && !(C->flags & CLIENT_TABMASTER))
  12. /* SLIST_FOREACH for client with no free client */
  13. #define FOREACH_NFCLIENT(V, H, F) \
  14. SLIST_FOREACH(V, H, F) \
  15. if(!(V->flags & CLIENT_FREE))
  16. /* Are two clients compatibles ? (to be tabbed together) */
  17. #define COMPCLIENT(C1, C2) ((C1->flags & CLIENT_IGNORE_TAG) == (C2->flags & CLIENT_IGNORE_TAG))
  18. void client_configure(struct client *c);
  19. struct client *client_gb_win(Window w);
  20. struct client *client_gb_frame(Window w);
  21. struct client *client_gb_pos(struct tag *t, int x, int y);
  22. struct client *client_gb_titlebar(Window w);
  23. struct client *client_next_with_pos(struct client *bc, enum position p);
  24. void client_swap2(struct client *c1, struct client *c2);
  25. void client_swap(struct client *c, enum position p);
  26. #define CCOL(c) (c == W->client ? &c->scol : &c->ncol)
  27. void client_frame_update(struct client *c, struct colpair *cp);
  28. void client_tab_pull(struct client *c);
  29. void _client_tab(struct client *c, struct client *cm);
  30. void client_tab_focus(struct client *c);
  31. void client_focus(struct client *c);
  32. void uicb_client_focus_click(Uicb);
  33. void client_get_name(struct client *c);
  34. void client_close(struct client *c);
  35. void uicb_client_close(Uicb cmd);
  36. struct client *client_new(Window w, XWindowAttributes *wa, bool scan);
  37. void client_geo_hints(struct geo *g, int *s);
  38. void client_get_sizeh(struct client *c);
  39. bool client_winsize(struct client *c, struct geo *geo);
  40. void client_moveresize(struct client *c, struct geo *g);
  41. void client_maximize(struct client *c);
  42. void client_fac_resize(struct client *c, enum position p, int fac);
  43. void client_fac_adjust(struct client *c);
  44. void client_remove(struct client *c);
  45. void client_free(void);
  46. void _fac_resize(struct client *c, enum position p, int fac);
  47. void client_apply_tgeo(struct tag *t);
  48. #define CPROP_LOC 0x01
  49. #define CPROP_FLAG 0x02
  50. #define CPROP_GEO 0x04
  51. #define CPROP_TAB 0x08
  52. void client_update_props(struct client *c, Flags f);
  53. void client_fac_hint(struct client *c);
  54. void uicb_client_untab(Uicb cmd);
  55. void uicb_client_toggle_free(Uicb cmd);
  56. void uicb_client_toggle_ignore_tag(Uicb cmd);
  57. void uicb_client_tab_next_opened(Uicb cmd);
  58. /* Generated */
  59. void uicb_client_resize_Right(Uicb);
  60. void uicb_client_resize_Left(Uicb);
  61. void uicb_client_resize_Top(Uicb);
  62. void uicb_client_resize_Bottom(Uicb);
  63. void uicb_client_focus_Right(Uicb);
  64. void uicb_client_focus_Left(Uicb);
  65. void uicb_client_focus_Top(Uicb);
  66. void uicb_client_focus_Bottom(Uicb);
  67. void uicb_client_tab_Right(Uicb);
  68. void uicb_client_tab_Left(Uicb);
  69. void uicb_client_tab_Top(Uicb);
  70. void uicb_client_tab_Bottom(Uicb);
  71. void uicb_client_swap_Right(Uicb);
  72. void uicb_client_swap_Left(Uicb);
  73. void uicb_client_swap_Top(Uicb);
  74. void uicb_client_swap_Bottom(Uicb);
  75. void uicb_client_focus_next(Uicb);
  76. void uicb_client_focus_prev(Uicb);
  77. void uicb_client_swapsel_next(Uicb);
  78. void uicb_client_swapsel_prev(Uicb);
  79. void uicb_client_focus_next_tab(Uicb);
  80. void uicb_client_focus_prev_tab(Uicb);
  81. static inline struct client*
  82. client_next(struct client *c)
  83. {
  84. return (SLIST_NEXT(c, tnext)
  85. ? SLIST_NEXT(c, tnext)
  86. : SLIST_FIRST(&c->tag->clients));
  87. }
  88. static inline struct client*
  89. client_prev(struct client *c)
  90. {
  91. struct client *cc = SLIST_FIRST(&c->tag->clients);
  92. while(SLIST_NEXT(cc, tnext) && SLIST_NEXT(cc, tnext) != c)
  93. cc = SLIST_NEXT(cc, tnext);
  94. return cc;
  95. }
  96. static inline struct client*
  97. client_next_tab(struct client *c)
  98. {
  99. struct client *n = client_next(c);
  100. if(!(c->flags & CLIENT_TABMASTER))
  101. return NULL;
  102. while((!(n->flags & CLIENT_TABBED) || n->tabmaster != c) && n != c)
  103. n = client_next(n);
  104. return n;
  105. }
  106. static inline struct client*
  107. client_prev_tab(struct client *c)
  108. {
  109. struct client *p = client_prev(c);
  110. if(!(c->flags & CLIENT_TABMASTER))
  111. return NULL;
  112. while((!(p->flags & CLIENT_TABBED) || p->tabmaster != c) && p != c)
  113. p = client_prev(p);
  114. return p;
  115. }
  116. static inline struct client*
  117. client_tab_next(struct client *c)
  118. {
  119. return (c && c->tabmaster ? c->tabmaster : c);
  120. }
  121. static inline void
  122. client_map(struct client *c)
  123. {
  124. if(!(c->flags & CLIENT_MAPPED))
  125. {
  126. WIN_STATE(c->frame, Map);
  127. WIN_STATE(c->win, Map);
  128. ewmh_set_wm_state(c->win, NormalState);
  129. c->flags ^= CLIENT_MAPPED;
  130. }
  131. }
  132. static inline void
  133. client_unmap(struct client *c)
  134. {
  135. if(c->flags & CLIENT_MAPPED)
  136. {
  137. WIN_STATE(c->frame, Unmap);
  138. WIN_STATE(c->win, Unmap);
  139. ewmh_set_wm_state(c->win, IconicState);
  140. c->flags ^= CLIENT_MAPPED;
  141. }
  142. }
  143. static inline void
  144. clients_arrange_map(void)
  145. {
  146. struct client *c;
  147. SLIST_FOREACH(c, &W->h.client, next)
  148. {
  149. if(c->tag == c->screen->seltag && !(c->flags & CLIENT_TABBED))
  150. client_map(c);
  151. else
  152. client_unmap(c);
  153. }
  154. }
  155. static inline void
  156. clients_tag_arrange_map(struct tag *t)
  157. {
  158. struct client *c;
  159. void (*sfunc)(struct client*)
  160. = (t == t->screen->seltag ? client_map : client_unmap);
  161. SLIST_FOREACH(c, &t->clients, tnext)
  162. sfunc(c);
  163. }
  164. static inline struct client*
  165. client_get_larger(struct tag *t, bool ignoring_tag)
  166. {
  167. struct client *c, *lc = NULL;
  168. int tmp, l = 0;
  169. FOREACH_NFCLIENT(c, &t->clients, tnext)
  170. {
  171. if((tmp = (c->geo.w + c->geo.h)) > l && (c->flags & CLIENT_IGNORE_TAG) == ignoring_tag)
  172. {
  173. l = tmp;
  174. lc = c;
  175. }
  176. }
  177. if(lc && (lc->flags & CLIENT_TABBED))
  178. lc = lc->tabmaster;
  179. return lc;
  180. }
  181. #endif /* CLIENT_H */