client.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. void client_configure(struct client *c);
  17. struct client *client_gb_win(Window w);
  18. struct client *client_gb_frame(Window w);
  19. struct client *client_gb_pos(struct tag *t, int x, int y);
  20. struct client *client_gb_titlebar(Window w);
  21. struct client *client_next_with_pos(struct client *bc, enum position p);
  22. void client_swap2(struct client *c1, struct client *c2);
  23. void client_swap(struct client *c, enum position p);
  24. #define CCOL(c) (c == W->client ? &c->scol : &c->ncol)
  25. void client_frame_update(struct client *c, struct colpair *cp);
  26. void client_tab_pull(struct client *c);
  27. void _client_tab(struct client *c, struct client *cm);
  28. void client_tab_focus(struct client *c);
  29. void client_focus(struct client *c);
  30. void uicb_client_focus_click(Uicb);
  31. void client_get_name(struct client *c);
  32. void client_close(struct client *c);
  33. void uicb_client_close(Uicb cmd);
  34. struct client *client_new(Window w, XWindowAttributes *wa, bool scan);
  35. void client_geo_hints(struct geo *g, int *s);
  36. void client_get_sizeh(struct client *c);
  37. bool client_winsize(struct client *c, struct geo *geo);
  38. void client_moveresize(struct client *c, struct geo *g);
  39. void client_maximize(struct client *c);
  40. void client_fac_resize(struct client *c, enum position p, int fac);
  41. void client_fac_adjust(struct client *c);
  42. void client_remove(struct client *c);
  43. void client_free(void);
  44. void _fac_resize(struct client *c, enum position p, int fac);
  45. void client_apply_tgeo(struct tag *t);
  46. #define CPROP_LOC 0x01
  47. #define CPROP_FLAG 0x02
  48. #define CPROP_GEO 0x04
  49. #define CPROP_TAB 0x08
  50. void client_update_props(struct client *c, Flags f);
  51. void client_fac_hint(struct client *c);
  52. void uicb_client_untab(Uicb cmd);
  53. void uicb_client_toggle_free(Uicb cmd);
  54. /* Generated */
  55. void uicb_client_resize_Right(Uicb);
  56. void uicb_client_resize_Left(Uicb);
  57. void uicb_client_resize_Top(Uicb);
  58. void uicb_client_resize_Bottom(Uicb);
  59. void uicb_client_focus_Right(Uicb);
  60. void uicb_client_focus_Left(Uicb);
  61. void uicb_client_focus_Top(Uicb);
  62. void uicb_client_focus_Bottom(Uicb);
  63. void uicb_client_tab_Right(Uicb);
  64. void uicb_client_tab_Left(Uicb);
  65. void uicb_client_tab_Top(Uicb);
  66. void uicb_client_tab_Bottom(Uicb);
  67. void uicb_client_swap_Right(Uicb);
  68. void uicb_client_swap_Left(Uicb);
  69. void uicb_client_swap_Top(Uicb);
  70. void uicb_client_swap_Bottom(Uicb);
  71. void uicb_client_focus_next(Uicb);
  72. void uicb_client_focus_prev(Uicb);
  73. void uicb_client_swapsel_next(Uicb);
  74. void uicb_client_swapsel_prev(Uicb);
  75. void uicb_client_focus_next_tab(Uicb);
  76. void uicb_client_focus_prev_tab(Uicb);
  77. static inline struct client*
  78. client_next(struct client *c)
  79. {
  80. return (SLIST_NEXT(c, tnext)
  81. ? SLIST_NEXT(c, tnext)
  82. : SLIST_FIRST(&c->tag->clients));
  83. }
  84. static inline struct client*
  85. client_prev(struct client *c)
  86. {
  87. struct client *cc = SLIST_FIRST(&c->tag->clients);
  88. while(SLIST_NEXT(cc, tnext) && SLIST_NEXT(cc, tnext) != c)
  89. cc = SLIST_NEXT(cc, tnext);
  90. return cc;
  91. }
  92. static inline struct client*
  93. client_next_tab(struct client *c)
  94. {
  95. struct client *n = client_next(c);
  96. if(!(c->flags & CLIENT_TABMASTER))
  97. return NULL;
  98. while((!(n->flags & CLIENT_TABBED) || n->tabmaster != c) && n != c)
  99. n = client_next(n);
  100. return n;
  101. }
  102. static inline struct client*
  103. client_prev_tab(struct client *c)
  104. {
  105. struct client *p = client_prev(c);
  106. if(!(c->flags & CLIENT_TABMASTER))
  107. return NULL;
  108. while((!(p->flags & CLIENT_TABBED) || p->tabmaster != c) && p != c)
  109. p = client_prev(p);
  110. return p;
  111. }
  112. static inline struct client*
  113. client_tab_next(struct client *c)
  114. {
  115. return (c && c->tabmaster ? c->tabmaster : c);
  116. }
  117. static inline void
  118. client_map(struct client *c)
  119. {
  120. if(!(c->flags & CLIENT_MAPPED))
  121. {
  122. WIN_STATE(c->frame, Map);
  123. WIN_STATE(c->win, Map);
  124. ewmh_set_wm_state(c->win, NormalState);
  125. c->flags ^= CLIENT_MAPPED;
  126. }
  127. }
  128. static inline void
  129. client_unmap(struct client *c)
  130. {
  131. if(c->flags & CLIENT_MAPPED)
  132. {
  133. WIN_STATE(c->frame, Unmap);
  134. WIN_STATE(c->win, Unmap);
  135. ewmh_set_wm_state(c->win, IconicState);
  136. c->flags ^= CLIENT_MAPPED;
  137. }
  138. }
  139. static inline void
  140. clients_arrange_map(void)
  141. {
  142. struct client *c;
  143. SLIST_FOREACH(c, &W->h.client, next)
  144. {
  145. if(c->tag == c->screen->seltag && !(c->flags & CLIENT_TABBED))
  146. client_map(c);
  147. else
  148. client_unmap(c);
  149. }
  150. }
  151. static inline void
  152. clients_tag_arrange_map(struct tag *t)
  153. {
  154. struct client *c;
  155. void (*sfunc)(struct client*)
  156. = (t == t->screen->seltag ? client_map : client_unmap);
  157. SLIST_FOREACH(c, &t->clients, tnext)
  158. sfunc(c);
  159. }
  160. #endif /* CLIENT_H */