client.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. void client_configure(struct client *c);
  10. struct client *client_gb_win(Window w);
  11. inline struct client *client_gb_pos(struct tag *t, int x, int y);
  12. struct client *client_next_with_pos(struct client *bc, Position p);
  13. void client_swap(struct client *c1, struct client *c2);
  14. void client_focus(struct client *c);
  15. void client_get_name(struct client *c);
  16. void client_close(struct client *c);
  17. void uicb_client_close(Uicb cmd);
  18. struct client *client_new(Window w, XWindowAttributes *wa);
  19. void client_moveresize(struct client *c, struct geo g);
  20. void client_maximize(struct client *c);
  21. void client_fac_resize(struct client *c, Position p, int fac);
  22. void client_remove(struct client *c);
  23. void client_free(void);
  24. /* Generated */
  25. void uicb_client_resize_Right(Uicb);
  26. void uicb_client_resize_Left(Uicb);
  27. void uicb_client_resize_Top(Uicb);
  28. void uicb_client_resize_Bottom(Uicb);
  29. void uicb_client_focus_Right(Uicb);
  30. void uicb_client_focus_Left(Uicb);
  31. void uicb_client_focus_Top(Uicb);
  32. void uicb_client_focus_Bottom(Uicb);
  33. void uicb_client_swapsel_Right(Uicb);
  34. void uicb_client_swapsel_Left(Uicb);
  35. void uicb_client_swapsel_Top(Uicb);
  36. void uicb_client_swapsel_Bottom(Uicb);
  37. void uicb_client_focus_next(Uicb);
  38. void uicb_client_focus_prev(Uicb);
  39. void uicb_client_swapsel_next(Uicb);
  40. void uicb_client_swapsel_prev(Uicb);
  41. static inline struct client*
  42. client_next(struct client *c)
  43. {
  44. return (SLIST_NEXT(c, tnext)
  45. ? SLIST_NEXT(c, tnext)
  46. : SLIST_FIRST(&c->tag->clients));
  47. }
  48. static inline struct client*
  49. client_prev(struct client *c)
  50. {
  51. struct client *cc;
  52. for(cc = SLIST_FIRST(&c->tag->clients);
  53. SLIST_NEXT(cc, tnext) && SLIST_NEXT(cc, tnext) != c;
  54. cc = SLIST_NEXT(cc, tnext));
  55. return cc;
  56. }
  57. static inline bool
  58. client_fac_geo(struct client *c, Position p, int fac)
  59. {
  60. struct geo cg = c->geo;
  61. switch(p)
  62. {
  63. default:
  64. case Right:
  65. cg.w += fac;
  66. break;
  67. case Left:
  68. cg.x -= fac;
  69. cg.w += fac;
  70. break;
  71. case Top:
  72. cg.y -= fac;
  73. cg.h += fac;
  74. break;
  75. case Bottom:
  76. cg.h += fac;
  77. break;
  78. }
  79. /* Check for incompatible geo */
  80. if(cg.w > c->screen->ugeo.w || cg.h > c->screen->ugeo.h
  81. || cg.w < 5 || cg.h < 5)
  82. return false;
  83. /* Set transformed geo in tmp geo */
  84. c->tgeo = cg;
  85. return true;
  86. }
  87. static inline bool
  88. client_fac_check_row(struct client *c, Position p, int fac)
  89. {
  90. struct geo g = c->geo;
  91. struct client *cc;
  92. /* Travel clients to search parents of row and check geos */
  93. SLIST_FOREACH(cc, &c->tag->clients, tnext)
  94. if(GEO_PARENTROW(g, cc->geo, p) && !client_fac_geo(cc, p, fac))
  95. return false;
  96. return true;
  97. }
  98. static inline void
  99. client_fac_arrange_row(struct client *c, Position p, int fac)
  100. {
  101. struct geo g = c->geo;
  102. struct client *cc;
  103. /* Travel clients to search row parents and apply fac */
  104. SLIST_FOREACH(cc, &c->tag->clients, tnext)
  105. if(GEO_PARENTROW(g, cc->geo, p))
  106. {
  107. client_fac_geo(cc, p, fac);
  108. client_moveresize(cc, cc->tgeo);
  109. }
  110. }
  111. #endif /* CLIENT_H */