key: move grabbing code to window
[awesome.git] / client.c
blob9950958044ee78b3c888da04075bd4e50fcf911c
1 /*
2 * client.c - client management
4 * Copyright © 2007-2009 Julien Danjou <julien@danjou.info>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <xcb/xcb_atom.h>
23 #include <xcb/xcb_image.h>
25 #include "tag.h"
26 #include "ewmh.h"
27 #include "screen.h"
28 #include "titlebar.h"
29 #include "systray.h"
30 #include "property.h"
31 #include "spawn.h"
32 #include "luaa.h"
33 #include "common/atoms.h"
34 #include "common/xutil.h"
36 client_t *
37 luaA_client_checkudata(lua_State *L, int ud)
39 client_t *c = luaA_checkudata(L, ud, &client_class);
40 if(c->invalid)
41 luaL_error(L, "client is invalid\n");
42 return c;
45 /** Collect a client.
46 * \param L The Lua VM state.
47 * \return The number of element pushed on stack.
49 static int
50 luaA_client_gc(lua_State *L)
52 client_t *c = luaA_checkudata(L, 1, &client_class);
53 button_array_wipe(&c->buttons);
54 key_array_wipe(&c->keys);
55 xcb_get_wm_protocols_reply_wipe(&c->protocols);
56 p_delete(&c->class);
57 p_delete(&c->instance);
58 p_delete(&c->icon_name);
59 p_delete(&c->alt_icon_name);
60 p_delete(&c->name);
61 p_delete(&c->alt_name);
62 return luaA_object_gc(L);
65 /** Change the client opacity.
66 * \param L The Lua VM state.
67 * \param cidx The client index.
68 * \param opacity The opacity.
70 void
71 client_set_opacity(lua_State *L, int cidx, double opacity)
73 client_t *c = luaA_client_checkudata(L, cidx);
75 if(c->opacity != opacity)
77 c->opacity = opacity;
78 window_opacity_set(c->window, opacity);
79 luaA_object_emit_signal(L, cidx, "property::opacity", 0);
83 /** Change the clients urgency flag.
84 * \param L The Lua VM state.
85 * \param cidx The client index on the stack.
86 * \param urgent The new flag state.
88 void
89 client_set_urgent(lua_State *L, int cidx, bool urgent)
91 client_t *c = luaA_client_checkudata(L, cidx);
93 if(c->urgent != urgent)
95 xcb_get_property_cookie_t hints =
96 xcb_get_wm_hints_unchecked(globalconf.connection, c->window);
98 c->urgent = urgent;
99 ewmh_client_update_hints(c);
101 /* update ICCCM hints */
102 xcb_wm_hints_t wmh;
103 xcb_get_wm_hints_reply(globalconf.connection, hints, &wmh, NULL);
105 if(urgent)
106 wmh.flags |= XCB_WM_HINT_X_URGENCY;
107 else
108 wmh.flags &= ~XCB_WM_HINT_X_URGENCY;
110 xcb_set_wm_hints(globalconf.connection, c->window, &wmh);
112 hook_property(c, "urgent");
113 luaA_object_emit_signal(L, cidx, "property::urgent", 0);
117 void
118 client_set_group_window(lua_State *L, int cidx, xcb_window_t window)
120 client_t *c = luaA_client_checkudata(L, cidx);
122 if(c->group_window != window)
124 c->group_window = window;
125 luaA_object_emit_signal(L, cidx, "property::group_window", 0);
129 void
130 client_set_type(lua_State *L, int cidx, window_type_t type)
132 client_t *c = luaA_client_checkudata(L, cidx);
134 if(c->type != type)
136 c->type = type;
137 luaA_object_emit_signal(L, cidx, "property::type", 0);
141 void
142 client_set_pid(lua_State *L, int cidx, uint32_t pid)
144 client_t *c = luaA_client_checkudata(L, cidx);
146 if(c->pid != pid)
148 c->pid = pid;
149 luaA_object_emit_signal(L, cidx, "property::pid", 0);
153 void
154 client_set_icon_name(lua_State *L, int cidx, char *icon_name)
156 client_t *c = luaA_client_checkudata(L, cidx);
157 p_delete(&c->icon_name);
158 c->icon_name = icon_name;
159 luaA_object_emit_signal(L, cidx, "property::icon_name", 0);
160 hook_property(c, "icon_name");
163 void
164 client_set_alt_icon_name(lua_State *L, int cidx, char *icon_name)
166 client_t *c = luaA_client_checkudata(L, cidx);
167 p_delete(&c->alt_icon_name);
168 c->alt_icon_name = icon_name;
169 luaA_object_emit_signal(L, cidx, "property::icon_name", 0);
170 hook_property(c, "icon_name");
173 void
174 client_set_role(lua_State *L, int cidx, char *role)
176 client_t *c = luaA_client_checkudata(L, cidx);
177 p_delete(&c->role);
178 c->role = role;
179 luaA_object_emit_signal(L, cidx, "property::role", 0);
182 void
183 client_set_machine(lua_State *L, int cidx, char *machine)
185 client_t *c = luaA_client_checkudata(L, cidx);
186 p_delete(&c->machine);
187 c->machine = machine;
188 luaA_object_emit_signal(L, cidx, "property::machine", 0);
191 void
192 client_set_class_instance(lua_State *L, int cidx, const char *class, const char *instance)
194 client_t *c = luaA_client_checkudata(L, cidx);
195 p_delete(&c->class);
196 p_delete(&c->instance);
197 c->class = a_strdup(class);
198 c->instance = a_strdup(instance);
199 luaA_object_emit_signal(L, cidx, "property::class", 0);
200 luaA_object_emit_signal(L, cidx, "property::instance", 0);
203 void
204 client_set_transient_for(lua_State *L, int cidx, client_t *transient_for)
206 client_t *c = luaA_client_checkudata(L, cidx);
208 if(c->transient_for != transient_for)
210 c->transient_for = transient_for;
211 luaA_object_emit_signal(L, cidx, "property::transient_for", 0);
215 void
216 client_set_name(lua_State *L, int cidx, char *name)
218 client_t *c = luaA_client_checkudata(L, cidx);
219 p_delete(&c->name);
220 c->name = name;
221 hook_property(c, "name");
222 luaA_object_emit_signal(L, cidx, "property::name", 0);
225 void
226 client_set_alt_name(lua_State *L, int cidx, char *name)
228 client_t *c = luaA_client_checkudata(L, cidx);
229 p_delete(&c->alt_name);
230 c->alt_name = name;
231 hook_property(c, "name");
232 luaA_object_emit_signal(L, cidx, "property::name", 0);
235 /** Returns true if a client is tagged
236 * with one of the tags of the specified screen.
237 * \param c The client to check.
238 * \param screen Virtual screen.
239 * \return true if the client is visible, false otherwise.
241 bool
242 client_maybevisible(client_t *c, screen_t *screen)
244 if(screen && c->screen == screen)
246 if(c->sticky || c->type == WINDOW_TYPE_DESKTOP)
247 return true;
249 foreach(tag, screen->tags)
250 if(tag_get_selected(*tag) && is_client_tagged(c, *tag))
251 return true;
253 return false;
256 /** Get a client by its window.
257 * \param w The client window to find.
258 * \return A client pointer if found, NULL otherwise.
260 client_t *
261 client_getbywin(xcb_window_t w)
263 foreach(c, globalconf.clients)
264 if((*c)->window == w)
265 return *c;
267 return NULL;
270 /** Record that a client lost focus.
271 * \param c Client being unfocused
273 void
274 client_unfocus_update(client_t *c)
276 globalconf.screens.tab[c->phys_screen].client_focus = NULL;
277 ewmh_update_net_active_window(c->phys_screen);
279 /* Call hook */
280 if(globalconf.hooks.unfocus != LUA_REFNIL)
282 luaA_object_push(globalconf.L, c);
283 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.unfocus, 1, 0);
286 luaA_object_push(globalconf.L, c);
287 luaA_class_emit_signal(globalconf.L, &client_class, "unfocus", 1);
290 /** Unfocus a client.
291 * \param c The client.
293 void
294 client_unfocus(client_t *c)
297 xcb_window_t root_win = xutil_screen_get(globalconf.connection, c->phys_screen)->root;
298 /* Set focus on root window, so no events leak to the current window.
299 * This kind of inlines client_set_focus(), but a root window will never have
300 * the WM_TAKE_FOCUS protocol.
302 xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_PARENT,
303 root_win, XCB_CURRENT_TIME);
305 client_unfocus_update(c);
308 /** Check if client supports atom a protocol in WM_PROTOCOL.
309 * \param c The client.
310 * \param atom The protocol atom to check for.
311 * \return True if client has the atom in protocol, false otherwise.
313 bool
314 client_hasproto(client_t *c, xcb_atom_t atom)
316 for(uint32_t i = 0; i < c->protocols.atoms_len; i++)
317 if(c->protocols.atoms[i] == atom)
318 return true;
319 return false;
322 /** Sets focus on window - using xcb_set_input_focus or WM_TAKE_FOCUS
323 * \param c Client that should get focus
324 * \param set_input_focus Should we call xcb_set_input_focus
326 void
327 client_set_focus(client_t *c, bool set_input_focus)
329 bool takefocus = client_hasproto(c, WM_TAKE_FOCUS);
330 if(set_input_focus)
331 xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_PARENT,
332 c->window, XCB_CURRENT_TIME);
333 if(takefocus)
334 window_takefocus(c->window);
337 /** Ban client and move it out of the viewport.
338 * \param c The client.
340 void
341 client_ban(client_t *c)
343 if(!c->isbanned)
345 xcb_unmap_window(globalconf.connection, c->window);
347 c->isbanned = true;
349 if(globalconf.screens.tab[c->phys_screen].prev_client_focus == c)
350 globalconf.screens.tab[c->phys_screen].prev_client_focus = NULL;
352 /* Wait until the last moment to take away the focus from the window. */
353 if(globalconf.screens.tab[c->phys_screen].client_focus == c)
354 client_unfocus(c);
358 /** This is part of The Bob Marley Algorithm: we ignore enter and leave window
359 * in certain cases, like map/unmap or move, so we don't get spurious events.
361 void
362 client_ignore_enterleave_events(void)
364 foreach(c, globalconf.clients)
365 xcb_change_window_attributes(globalconf.connection,
366 (*c)->window,
367 XCB_CW_EVENT_MASK,
368 (const uint32_t []) { CLIENT_SELECT_INPUT_EVENT_MASK & ~(XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW) });
371 void
372 client_restore_enterleave_events(void)
374 foreach(c, globalconf.clients)
375 xcb_change_window_attributes(globalconf.connection,
376 (*c)->window,
377 XCB_CW_EVENT_MASK,
378 (const uint32_t []) { CLIENT_SELECT_INPUT_EVENT_MASK });
381 /** Record that a client got focus.
382 * \param c The client.
384 void
385 client_focus_update(client_t *c)
387 if(!client_maybevisible(c, c->screen))
389 /* Focus previously focused client */
390 client_focus(globalconf.screen_focus->prev_client_focus);
391 return;
394 if(globalconf.screen_focus
395 && globalconf.screen_focus->client_focus)
397 if (globalconf.screen_focus->client_focus != c)
398 client_unfocus_update(globalconf.screen_focus->client_focus);
399 else
400 /* Already focused */
401 return;
403 luaA_object_push(globalconf.L, c);
404 client_set_minimized(globalconf.L, -1, false);
406 /* unban the client before focusing for consistency */
407 client_unban(c);
409 globalconf.screen_focus = &globalconf.screens.tab[c->phys_screen];
410 globalconf.screen_focus->prev_client_focus = c;
411 globalconf.screen_focus->client_focus = c;
413 /* according to EWMH, we have to remove the urgent state from a client */
414 client_set_urgent(globalconf.L, -1, false);
416 ewmh_update_net_active_window(c->phys_screen);
418 /* execute hook */
419 if(globalconf.hooks.focus != LUA_REFNIL)
421 luaA_object_push(globalconf.L, c);
422 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.focus, 1, 0);
425 luaA_object_push(globalconf.L, c);
426 luaA_class_emit_signal(globalconf.L, &client_class, "focus", 1);
429 /** Give focus to client, or to first client if client is NULL.
430 * \param c The client.
432 void
433 client_focus(client_t *c)
435 /* We have to set focus on first client */
436 if(!c && globalconf.clients.len && !(c = globalconf.clients.tab[0]))
437 return;
439 if(!client_maybevisible(c, c->screen))
440 return;
442 if (!c->nofocus)
443 client_focus_update(c);
445 client_set_focus(c, !c->nofocus);
448 /** Stack a window below.
449 * \param c The client.
450 * \param previous The previous window on the stack.
451 * \return The next-previous!
453 static xcb_window_t
454 client_stack_above(client_t *c, xcb_window_t previous)
456 uint32_t config_win_vals[2];
458 config_win_vals[0] = previous;
459 config_win_vals[1] = XCB_STACK_MODE_ABOVE;
461 xcb_configure_window(globalconf.connection, c->window,
462 XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
463 config_win_vals);
465 config_win_vals[0] = c->window;
467 if(c->titlebar)
469 xcb_configure_window(globalconf.connection,
470 c->titlebar->window,
471 XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
472 config_win_vals);
473 previous = c->titlebar->window;
475 else
476 previous = c->window;
478 /* stack transient window on top of their parents */
479 foreach(node, globalconf.stack)
480 if((*node)->transient_for == c)
481 previous = client_stack_above(*node, previous);
483 return previous;
486 /** Stacking layout layers */
487 typedef enum
489 /** This one is a special layer */
490 LAYER_IGNORE,
491 LAYER_DESKTOP,
492 LAYER_BELOW,
493 LAYER_NORMAL,
494 LAYER_ABOVE,
495 LAYER_FULLSCREEN,
496 LAYER_ONTOP,
497 /** This one only used for counting and is not a real layer */
498 LAYER_COUNT
499 } layer_t;
501 /** Get the real layer of a client according to its attribute (fullscreen, …)
502 * \param c The client.
503 * \return The real layer.
505 static layer_t
506 client_layer_translator(client_t *c)
508 /* first deal with user set attributes */
509 if(c->ontop)
510 return LAYER_ONTOP;
511 else if(c->fullscreen)
512 return LAYER_FULLSCREEN;
513 else if(c->above)
514 return LAYER_ABOVE;
515 else if(c->below)
516 return LAYER_BELOW;
518 /* check for transient attr */
519 if(c->transient_for)
520 return LAYER_IGNORE;
522 /* then deal with windows type */
523 switch(c->type)
525 case WINDOW_TYPE_DESKTOP:
526 return LAYER_DESKTOP;
527 default:
528 break;
531 return LAYER_NORMAL;
534 /** Restack clients.
535 * \todo It might be worth stopping to restack everyone and only stack `c'
536 * relatively to the first matching in the list.
538 void
539 client_stack_refresh()
541 uint32_t config_win_vals[2];
542 layer_t layer;
544 if (!globalconf.client_need_stack_refresh)
545 return;
546 globalconf.client_need_stack_refresh = false;
548 config_win_vals[0] = XCB_NONE;
549 config_win_vals[1] = XCB_STACK_MODE_ABOVE;
551 /* stack desktop windows */
552 for(layer = LAYER_DESKTOP; layer < LAYER_BELOW; layer++)
553 foreach(node, globalconf.stack)
554 if(client_layer_translator(*node) == layer)
555 config_win_vals[0] = client_stack_above(*node,
556 config_win_vals[0]);
558 /* first stack not ontop wibox window */
559 foreach(_sb, globalconf.wiboxes)
561 wibox_t *sb = *_sb;
562 if(!sb->ontop)
564 xcb_configure_window(globalconf.connection,
565 sb->window,
566 XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
567 config_win_vals);
568 config_win_vals[0] = sb->window;
572 /* then stack clients */
573 for(layer = LAYER_BELOW; layer < LAYER_COUNT; layer++)
574 foreach(node, globalconf.stack)
575 if(client_layer_translator(*node) == layer)
576 config_win_vals[0] = client_stack_above(*node,
577 config_win_vals[0]);
579 /* then stack ontop wibox window */
580 foreach(_sb, globalconf.wiboxes)
582 wibox_t *sb = *_sb;
583 if(sb->ontop)
585 xcb_configure_window(globalconf.connection,
586 sb->window,
587 XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
588 config_win_vals);
589 config_win_vals[0] = sb->window;
594 /** Manage a new client.
595 * \param w The window.
596 * \param wgeom Window geometry.
597 * \param phys_screen Physical screen number.
598 * \param startup True if we are managing at startup time.
600 void
601 client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen, bool startup)
603 screen_t *screen;
604 const uint32_t select_input_val[] = { CLIENT_SELECT_INPUT_EVENT_MASK };
606 if(systray_iskdedockapp(w))
608 systray_request_handle(w, phys_screen, NULL);
609 return;
612 /* If this is a new client that just has been launched, then request its
613 * startup id. */
614 xcb_get_property_cookie_t startup_id_q = { 0 };
615 if(!startup)
616 startup_id_q = xcb_get_any_property(globalconf.connection,
617 false, w, _NET_STARTUP_ID, UINT_MAX);
619 xcb_change_window_attributes(globalconf.connection, w, XCB_CW_EVENT_MASK, select_input_val);
621 client_t *c = client_new(globalconf.L);
622 /* Push client in client list */
623 client_array_push(&globalconf.clients, luaA_object_ref(globalconf.L, -1));
626 screen = c->screen = screen_getbycoord(&globalconf.screens.tab[phys_screen],
627 wgeom->x, wgeom->y);
629 c->phys_screen = phys_screen;
631 /* consider the window banned */
632 c->isbanned = true;
634 /* Initial values */
635 c->window = w;
636 c->geometry.x = wgeom->x;
637 c->geometry.y = wgeom->y;
638 /* Border will be added later. */
639 c->geometry.width = wgeom->width;
640 c->geometry.height = wgeom->height;
641 /* Also set internal geometry (client_ban() needs it). */
642 c->geometries.internal.x = wgeom->x;
643 c->geometries.internal.y = wgeom->y;
644 c->geometries.internal.width = wgeom->width;
645 c->geometries.internal.height = wgeom->height;
647 /* Push client */
648 luaA_object_push(globalconf.L, c);
649 client_set_border_width(globalconf.L, -1, wgeom->border_width);
650 lua_pop(globalconf.L, 1);
652 /* we honor size hints by default */
653 c->size_hints_honor = true;
655 /* update hints */
656 property_update_wm_normal_hints(c, NULL);
657 property_update_wm_hints(c, NULL);
658 property_update_wm_transient_for(c, NULL);
659 property_update_wm_client_leader(c, NULL);
660 property_update_wm_client_machine(c, NULL);
661 property_update_wm_window_role(c, NULL);
662 property_update_net_wm_pid(c, NULL);
663 property_update_net_wm_icon(c, NULL);
665 /* get opacity */
666 c->opacity = window_opacity_get(c->window);
668 /* Then check clients hints */
669 ewmh_client_check_hints(c);
671 screen_client_moveto(c, screen, true);
673 /* Push client in stack */
674 client_raise(c);
676 /* update window title */
677 property_update_wm_name(c, NULL);
678 property_update_net_wm_name(c, NULL);
679 property_update_wm_icon_name(c, NULL);
680 property_update_net_wm_icon_name(c, NULL);
681 property_update_wm_class(c, NULL);
682 property_update_wm_protocols(c, NULL);
684 /* update strut */
685 ewmh_process_client_strut(c, NULL);
687 ewmh_update_net_client_list(c->phys_screen);
689 /* Always stay in NORMAL_STATE. Even though iconified seems more
690 * appropriate sometimes. The only possible loss is that clients not using
691 * visibility events may continue to process data (when banned).
692 * Without any exposes or other events the cost should be fairly limited though.
694 * Some clients may expect the window to be unmapped when STATE_ICONIFIED.
695 * Two conflicting parts of the ICCCM v2.0 (section 4.1.4):
697 * "Normal -> Iconic - The client should send a ClientMessage event as described later in this section."
698 * (note no explicit mention of unmapping, while Normal->Widthdrawn does mention that)
700 * "Once a client's window has left the Withdrawn state, the window will be mapped
701 * if it is in the Normal state and the window will be unmapped if it is in the Iconic state."
703 * At this stage it's just safer to keep it in normal state and avoid confusion.
705 window_state_set(c->window, XCB_WM_STATE_NORMAL);
707 if(!startup)
709 /* Request our response */
710 xcb_get_property_reply_t *reply =
711 xcb_get_property_reply(globalconf.connection, startup_id_q, NULL);
712 /* Say spawn that a client has been started, with startup id as argument */
713 char *startup_id = xutil_get_text_property_from_reply(reply);
714 p_delete(&reply);
715 spawn_start_notify(c, startup_id);
716 p_delete(&startup_id);
719 /* Call hook to notify list change */
720 if(globalconf.hooks.clients != LUA_REFNIL)
721 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.clients, 0, 0);
723 luaA_class_emit_signal(globalconf.L, &client_class, "list", 0);
725 /* call hook */
726 if(globalconf.hooks.manage != LUA_REFNIL)
728 luaA_object_push(globalconf.L, c);
729 lua_pushboolean(globalconf.L, startup);
730 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.manage, 2, 0);
733 luaA_object_push(globalconf.L, c);
734 lua_pushboolean(globalconf.L, startup);
735 luaA_class_emit_signal(globalconf.L, &client_class, "manage", 2);
738 /** Compute client geometry with respect to its geometry hints.
739 * \param c The client.
740 * \param geometry The geometry that the client might receive.
741 * \return The geometry the client must take respecting its hints.
743 area_t
744 client_geometry_hints(client_t *c, area_t geometry)
746 int32_t basew, baseh, minw, minh;
748 /* base size is substituted with min size if not specified */
749 if(c->size_hints.flags & XCB_SIZE_HINT_P_SIZE)
751 basew = c->size_hints.base_width;
752 baseh = c->size_hints.base_height;
754 else if(c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)
756 basew = c->size_hints.min_width;
757 baseh = c->size_hints.min_height;
759 else
760 basew = baseh = 0;
762 /* min size is substituted with base size if not specified */
763 if(c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)
765 minw = c->size_hints.min_width;
766 minh = c->size_hints.min_height;
768 else if(c->size_hints.flags & XCB_SIZE_HINT_P_SIZE)
770 minw = c->size_hints.base_width;
771 minh = c->size_hints.base_height;
773 else
774 minw = minh = 0;
776 if(c->size_hints.flags & XCB_SIZE_HINT_P_ASPECT
777 && c->size_hints.min_aspect_num > 0
778 && c->size_hints.min_aspect_den > 0
779 && geometry.height - baseh > 0
780 && geometry.width - basew > 0)
782 double dx = (double) (geometry.width - basew);
783 double dy = (double) (geometry.height - baseh);
784 double min = (double) c->size_hints.min_aspect_num / (double) c->size_hints.min_aspect_den;
785 double max = (double) c->size_hints.max_aspect_num / (double) c->size_hints.min_aspect_den;
786 double ratio = dx / dy;
787 if(max > 0 && min > 0 && ratio > 0)
789 if(ratio < min)
791 dy = (dx * min + dy) / (min * min + 1);
792 dx = dy * min;
793 geometry.width = (int) dx + basew;
794 geometry.height = (int) dy + baseh;
796 else if(ratio > max)
798 dy = (dx * min + dy) / (max * max + 1);
799 dx = dy * min;
800 geometry.width = (int) dx + basew;
801 geometry.height = (int) dy + baseh;
806 if(minw)
807 geometry.width = MAX(geometry.width, minw);
808 if(minh)
809 geometry.height = MAX(geometry.height, minh);
811 if(c->size_hints.flags & XCB_SIZE_HINT_P_MAX_SIZE)
813 if(c->size_hints.max_width)
814 geometry.width = MIN(geometry.width, c->size_hints.max_width);
815 if(c->size_hints.max_height)
816 geometry.height = MIN(geometry.height, c->size_hints.max_height);
819 if(c->size_hints.flags & (XCB_SIZE_HINT_P_RESIZE_INC | XCB_SIZE_HINT_BASE_SIZE)
820 && c->size_hints.width_inc && c->size_hints.height_inc)
822 uint16_t t1 = geometry.width, t2 = geometry.height;
823 unsigned_subtract(t1, basew);
824 unsigned_subtract(t2, baseh);
825 geometry.width -= t1 % c->size_hints.width_inc;
826 geometry.height -= t2 % c->size_hints.height_inc;
829 return geometry;
832 /** Resize client window.
833 * The sizes given as parameters are with titlebar and borders!
834 * \param c Client to resize.
835 * \param geometry New window geometry.
836 * \param hints Use size hints.
837 * \return true if an actual resize occurred.
839 bool
840 client_resize(client_t *c, area_t geometry, bool hints)
842 area_t geometry_internal;
843 area_t area;
845 /* offscreen appearance fixes */
846 area = display_area_get(c->phys_screen);
848 if(geometry.x > area.width)
849 geometry.x = area.width - geometry.width;
850 if(geometry.y > area.height)
851 geometry.y = area.height - geometry.height;
852 if(geometry.x + geometry.width < 0)
853 geometry.x = 0;
854 if(geometry.y + geometry.height < 0)
855 geometry.y = 0;
857 /* Real client geometry, please keep it contained to C code at the very least. */
858 geometry_internal = titlebar_geometry_remove(c->titlebar, c->border_width, geometry);
860 if(hints)
861 geometry_internal = client_geometry_hints(c, geometry_internal);
863 if(geometry_internal.width == 0 || geometry_internal.height == 0)
864 return false;
866 /* Also let client hints propagate to the "official" geometry. */
867 geometry = titlebar_geometry_add(c->titlebar, c->border_width, geometry_internal);
869 if(c->geometries.internal.x != geometry_internal.x
870 || c->geometries.internal.y != geometry_internal.y
871 || c->geometries.internal.width != geometry_internal.width
872 || c->geometries.internal.height != geometry_internal.height)
874 screen_t *new_screen = screen_getbycoord(c->screen,
875 geometry_internal.x, geometry_internal.y);
877 /* Values to configure a window is an array where values are
878 * stored according to 'value_mask' */
879 uint32_t values[4];
881 c->geometries.internal.x = values[0] = geometry_internal.x;
882 c->geometries.internal.y = values[1] = geometry_internal.y;
883 c->geometries.internal.width = values[2] = geometry_internal.width;
884 c->geometries.internal.height = values[3] = geometry_internal.height;
886 /* Also store geometry including border and titlebar. */
887 c->geometry = geometry;
889 titlebar_update_geometry(c);
891 /* Ignore all spurious enter/leave notify events */
892 client_ignore_enterleave_events();
894 xcb_configure_window(globalconf.connection, c->window,
895 XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y
896 | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
897 values);
899 client_restore_enterleave_events();
901 screen_client_moveto(c, new_screen, false);
903 /* execute hook */
904 hook_property(c, "geometry");
906 return true;
909 return false;
912 /** Set a client minimized, or not.
913 * \param L The Lua VM state.
914 * \param cidx The client index.
915 * \param s Set or not the client minimized.
917 void
918 client_set_minimized(lua_State *L, int cidx, bool s)
920 client_t *c = luaA_client_checkudata(L, cidx);
922 if(c->minimized != s)
924 client_need_reban(c);
925 c->minimized = s;
926 client_need_reban(c);
927 if(s)
928 window_state_set(c->window, XCB_WM_STATE_ICONIC);
929 else
930 window_state_set(c->window, XCB_WM_STATE_NORMAL);
931 ewmh_client_update_hints(c);
932 if(strut_has_value(&c->strut))
933 screen_emit_signal(globalconf.L, c->screen, "property::workarea", 0);
934 /* execute hook */
935 hook_property(c, "minimized");
936 luaA_object_emit_signal(L, cidx, "property::minimized", 0);
940 /** Set a client sticky, or not.
941 * \param L The Lua VM state.
942 * \param cidx The client index.
943 * \param s Set or not the client sticky.
945 void
946 client_set_sticky(lua_State *L, int cidx, bool s)
948 client_t *c = luaA_client_checkudata(L, cidx);
950 if(c->sticky != s)
952 client_need_reban(c);
953 c->sticky = s;
954 client_need_reban(c);
955 ewmh_client_update_hints(c);
956 hook_property(c, "sticky");
957 luaA_object_emit_signal(L, cidx, "property::sticky", 0);
961 /** Set a client fullscreen, or not.
962 * \param L The Lua VM state.
963 * \param cidx The client index.
964 * \param s Set or not the client fullscreen.
966 void
967 client_set_fullscreen(lua_State *L, int cidx, bool s)
969 client_t *c = luaA_client_checkudata(L, cidx);
971 if(c->fullscreen != s)
973 area_t geometry;
975 /* become fullscreen! */
976 if(s)
978 /* Make sure the current geometry is stored without titlebar. */
979 titlebar_ban(c->titlebar);
980 /* remove any max state */
981 client_set_maximized_horizontal(L, cidx, false);
982 client_set_maximized_vertical(L, cidx, false);
983 /* You can only be part of one of the special layers. */
984 client_set_below(L, cidx, false);
985 client_set_above(L, cidx, false);
986 client_set_ontop(L, cidx, false);
988 geometry = screen_area_get(c->screen, false);
989 c->geometries.fullscreen = c->geometry;
990 c->border_width_fs = c->border_width;
991 client_set_border_width(L, cidx, 0);
992 c->fullscreen = true;
994 else
996 geometry = c->geometries.fullscreen;
997 c->fullscreen = false;
998 client_set_border_width(L, cidx, c->border_width_fs);
1000 client_resize(c, geometry, false);
1001 client_stack();
1002 ewmh_client_update_hints(c);
1003 hook_property(c, "fullscreen");
1004 luaA_object_emit_signal(L, cidx, "property::fullscreen", 0);
1008 /** Set a client horizontally maximized.
1009 * \param L The Lua VM state.
1010 * \param cidx The client index.
1011 * \param s The maximized status.
1013 void
1014 client_set_maximized_horizontal(lua_State *L, int cidx, bool s)
1016 client_t *c = luaA_client_checkudata(L, cidx);
1018 if(c->maximized_horizontal != s)
1020 area_t geometry;
1022 if((c->maximized_horizontal = s))
1024 /* remove fullscreen mode */
1025 client_set_fullscreen(L, cidx, false);
1027 geometry = screen_area_get(c->screen, true);
1028 geometry.y = c->geometry.y;
1029 geometry.height = c->geometry.height;
1030 c->geometries.max.x = c->geometry.x;
1031 c->geometries.max.width = c->geometry.width;
1033 else
1035 geometry = c->geometry;
1036 geometry.x = c->geometries.max.x;
1037 geometry.width = c->geometries.max.width;
1040 client_resize(c, geometry, c->size_hints_honor);
1041 client_stack();
1042 ewmh_client_update_hints(c);
1043 hook_property(c, "maximized_horizontal");
1044 luaA_object_emit_signal(L, cidx, "property::maximized_horizontal", 0);
1048 /** Set a client vertically maximized.
1049 * \param L The Lua VM state.
1050 * \param cidx The client index.
1051 * \param s The maximized status.
1053 void
1054 client_set_maximized_vertical(lua_State *L, int cidx, bool s)
1056 client_t *c = luaA_client_checkudata(L, cidx);
1058 if(c->maximized_vertical != s)
1060 area_t geometry;
1062 if((c->maximized_vertical = s))
1064 /* remove fullscreen mode */
1065 client_set_fullscreen(L, cidx, false);
1067 geometry = screen_area_get(c->screen, true);
1068 geometry.x = c->geometry.x;
1069 geometry.width = c->geometry.width;
1070 c->geometries.max.y = c->geometry.y;
1071 c->geometries.max.height = c->geometry.height;
1073 else
1075 geometry = c->geometry;
1076 geometry.y = c->geometries.max.y;
1077 geometry.height = c->geometries.max.height;
1080 client_resize(c, geometry, c->size_hints_honor);
1081 client_stack();
1082 ewmh_client_update_hints(c);
1083 hook_property(c, "maximized_vertical");
1084 luaA_object_emit_signal(L, cidx, "property::maximized_vertical", 0);
1088 /** Set a client above, or not.
1089 * \param L The Lua VM state.
1090 * \param cidx The client index.
1091 * \param s Set or not the client above.
1093 void
1094 client_set_above(lua_State *L, int cidx, bool s)
1096 client_t *c = luaA_client_checkudata(L, cidx);
1098 if(c->above != s)
1100 /* You can only be part of one of the special layers. */
1101 if(s)
1103 client_set_below(L, cidx, false);
1104 client_set_ontop(L, cidx, false);
1105 client_set_fullscreen(L, cidx, false);
1107 c->above = s;
1108 client_stack();
1109 ewmh_client_update_hints(c);
1110 /* execute hook */
1111 hook_property(c, "above");
1112 luaA_object_emit_signal(L, cidx, "property::above", 0);
1116 /** Set a client below, or not.
1117 * \param L The Lua VM state.
1118 * \param cidx The client index.
1119 * \param s Set or not the client below.
1121 void
1122 client_set_below(lua_State *L, int cidx, bool s)
1124 client_t *c = luaA_client_checkudata(L, cidx);
1126 if(c->below != s)
1128 /* You can only be part of one of the special layers. */
1129 if(s)
1131 client_set_above(L, cidx, false);
1132 client_set_ontop(L, cidx, false);
1133 client_set_fullscreen(L, cidx, false);
1135 c->below = s;
1136 client_stack();
1137 ewmh_client_update_hints(c);
1138 /* execute hook */
1139 hook_property(c, "below");
1140 luaA_object_emit_signal(L, cidx, "property::below", 0);
1144 /** Set a client modal, or not.
1145 * \param L The Lua VM state.
1146 * \param cidx The client index.
1147 * \param s Set or not the client modal attribute.
1149 void
1150 client_set_modal(lua_State *L, int cidx, bool s)
1152 client_t *c = luaA_client_checkudata(L, cidx);
1154 if(c->modal != s)
1156 c->modal = s;
1157 client_stack();
1158 ewmh_client_update_hints(c);
1159 /* execute hook */
1160 hook_property(c, "modal");
1161 luaA_object_emit_signal(L, cidx, "property::modal", 0);
1165 /** Set a client ontop, or not.
1166 * \param L The Lua VM state.
1167 * \param cidx The client index.
1168 * \param s Set or not the client ontop attribute.
1170 void
1171 client_set_ontop(lua_State *L, int cidx, bool s)
1173 client_t *c = luaA_client_checkudata(L, cidx);
1175 if(c->ontop != s)
1177 /* You can only be part of one of the special layers. */
1178 if(s)
1180 client_set_above(L, cidx, false);
1181 client_set_below(L, cidx, false);
1182 client_set_fullscreen(L, cidx, false);
1184 c->ontop = s;
1185 client_stack();
1186 /* execute hook */
1187 hook_property(c, "ontop");
1188 luaA_object_emit_signal(L, cidx, "property::ontop", 0);
1192 /** Set a client skip taskbar attribute.
1193 * \param L Tha Lua VM state.
1194 * \param cidx The client index.
1195 * \param s Set or not the client skip taskbar attribute.
1197 void
1198 client_set_skip_taskbar(lua_State *L, int cidx, bool s)
1200 client_t *c = luaA_client_checkudata(L, cidx);
1202 if(c->skip_taskbar != s)
1204 c->skip_taskbar = s;
1205 ewmh_client_update_hints(c);
1206 luaA_object_emit_signal(L, cidx, "property::skip_taskbar", 0);
1210 /** Unban a client and move it back into the viewport.
1211 * \param c The client.
1213 void
1214 client_unban(client_t *c)
1216 if(c->isbanned)
1218 xcb_map_window(globalconf.connection, c->window);
1220 c->isbanned = false;
1224 /** Unmanage a client.
1225 * \param c The client.
1227 void
1228 client_unmanage(client_t *c)
1230 tag_array_t *tags = &c->screen->tags;
1232 /* Reset transient_for attributes of widows that maybe referring to us */
1233 foreach(_tc, globalconf.clients)
1235 client_t *tc = *_tc;
1236 if(tc->transient_for == c)
1237 tc->transient_for = NULL;
1240 if(globalconf.screens.tab[c->phys_screen].prev_client_focus == c)
1241 globalconf.screens.tab[c->phys_screen].prev_client_focus = NULL;
1243 if(globalconf.screens.tab[c->phys_screen].client_focus == c)
1244 client_unfocus(c);
1246 /* remove client from global list and everywhere else */
1247 foreach(elem, globalconf.clients)
1248 if(*elem == c)
1250 client_array_remove(&globalconf.clients, elem);
1251 break;
1253 stack_client_remove(c);
1254 for(int i = 0; i < tags->len; i++)
1255 untag_client(c, tags->tab[i]);
1257 /* call hook */
1258 if(globalconf.hooks.unmanage != LUA_REFNIL)
1260 luaA_object_push(globalconf.L, c);
1261 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.unmanage, 1, 0);
1264 luaA_object_push(globalconf.L, c);
1265 luaA_class_emit_signal(globalconf.L, &client_class, "unmanage", 1);
1267 /* Call hook to notify list change */
1268 if(globalconf.hooks.clients != LUA_REFNIL)
1269 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.clients, 0, 0);
1271 luaA_class_emit_signal(globalconf.L, &client_class, "list", 0);
1273 if(strut_has_value(&c->strut))
1274 screen_emit_signal(globalconf.L, c->screen, "property::workarea", 0);
1276 window_state_set(c->window, XCB_WM_STATE_WITHDRAWN);
1278 titlebar_client_detach(c);
1280 ewmh_update_net_client_list(c->phys_screen);
1282 /* set client as invalid */
1283 c->invalid = true;
1285 luaA_object_unref(globalconf.L, c);
1288 /** Kill a client via a WM_DELETE_WINDOW request or KillClient if not
1289 * supported.
1290 * \param c The client to kill.
1292 void
1293 client_kill(client_t *c)
1295 if(client_hasproto(c, WM_DELETE_WINDOW))
1297 xcb_client_message_event_t ev;
1299 /* Initialize all of event's fields first */
1300 p_clear(&ev, 1);
1302 ev.response_type = XCB_CLIENT_MESSAGE;
1303 ev.window = c->window;
1304 ev.format = 32;
1305 ev.data.data32[1] = XCB_CURRENT_TIME;
1306 ev.type = WM_PROTOCOLS;
1307 ev.data.data32[0] = WM_DELETE_WINDOW;
1309 xcb_send_event(globalconf.connection, false, c->window,
1310 XCB_EVENT_MASK_NO_EVENT, (char *) &ev);
1312 else
1313 xcb_kill_client(globalconf.connection, c->window);
1316 /** Get all clients into a table.
1317 * \param L The Lua VM state.
1318 * \return The number of elements pushed on stack.
1319 * \luastack
1320 * \lparam An optional screen number.
1321 * \lreturn A table with all clients.
1323 static int
1324 luaA_client_get(lua_State *L)
1326 int i = 1, screen;
1328 screen = luaL_optnumber(L, 1, 0) - 1;
1330 lua_newtable(L);
1332 if(screen == -1)
1333 foreach(c, globalconf.clients)
1335 luaA_object_push(L, *c);
1336 lua_rawseti(L, -2, i++);
1338 else
1340 luaA_checkscreen(screen);
1341 foreach(c, globalconf.clients)
1342 if((*c)->screen == &globalconf.screens.tab[screen])
1344 luaA_object_push(L, *c);
1345 lua_rawseti(L, -2, i++);
1349 return 1;
1352 /** Check if a client is visible on its screen.
1353 * \param L The Lua VM state.
1354 * \return The number of elements pushed on stack.
1355 * \luastack
1356 * \lvalue A client.
1357 * \lreturn A boolean value, true if the client is visible, false otherwise.
1359 static int
1360 luaA_client_isvisible(lua_State *L)
1362 client_t *c = luaA_client_checkudata(L, 1);
1363 lua_pushboolean(L, client_isvisible(c, c->screen));
1364 return 1;
1367 /** Set client border width.
1368 * \param L The Lua VM state.
1369 * \param cidx The client index.
1370 * \param width The border width.
1372 void
1373 client_set_border_width(lua_State *L, int cidx, int width)
1375 client_t *c = luaA_client_checkudata(L, cidx);
1376 uint32_t w = width;
1378 if(width > 0 && (c->type == WINDOW_TYPE_DOCK
1379 || c->type == WINDOW_TYPE_SPLASH
1380 || c->type == WINDOW_TYPE_DESKTOP
1381 || c->fullscreen))
1382 return;
1384 if(width == c->border_width || width < 0)
1385 return;
1387 /* disallow change of border width if the client is fullscreen */
1388 if(c->fullscreen)
1389 return;
1391 /* Update geometry with the new border. */
1392 c->geometry.width -= 2 * c->border_width;
1393 c->geometry.height -= 2 * c->border_width;
1395 c->border_width = width;
1396 xcb_configure_window(globalconf.connection, c->window,
1397 XCB_CONFIG_WINDOW_BORDER_WIDTH, &w);
1399 c->geometry.width += 2 * c->border_width;
1400 c->geometry.height += 2 * c->border_width;
1402 /* Changing border size also affects the size of the titlebar. */
1403 titlebar_update_geometry(c);
1405 hook_property(c, "border_width");
1406 luaA_object_emit_signal(L, cidx, "property::border_width", 0);
1409 /** Set a client icon.
1410 * \param L The Lua VM state.
1411 * \param cidx The client index on the stack.
1412 * \param iidx The image index on the stack.
1414 void
1415 client_set_icon(lua_State *L, int cidx, int iidx)
1417 client_t *c = luaA_client_checkudata(L, cidx);
1418 /* convert index to absolute */
1419 cidx = luaA_absindex(L, cidx);
1420 iidx = luaA_absindex(L, iidx);
1421 luaA_checkudata(L, iidx, &image_class);
1422 luaA_object_unref_item(L, cidx, c->icon);
1423 c->icon = luaA_object_ref_item(L, cidx, iidx);
1424 luaA_object_emit_signal(L, cidx < iidx ? cidx : cidx - 1, "property::icon", 0);
1425 /* execute hook */
1426 hook_property(c, "icon");
1429 /** Kill a client.
1430 * \param L The Lua VM state.
1432 * \luastack
1433 * \lvalue A client.
1435 static int
1436 luaA_client_kill(lua_State *L)
1438 client_t *c = luaA_client_checkudata(L, 1);
1439 client_kill(c);
1440 return 0;
1443 /** Swap a client with another one.
1444 * \param L The Lua VM state.
1445 * \luastack
1446 * \lvalue A client.
1447 * \lparam A client to swap with.
1449 static int
1450 luaA_client_swap(lua_State *L)
1452 client_t *c = luaA_client_checkudata(L, 1);
1453 client_t *swap = luaA_client_checkudata(L, 2);
1455 if(c != swap)
1457 client_t **ref_c = NULL, **ref_swap = NULL;
1458 foreach(item, globalconf.clients)
1460 if(*item == c)
1461 ref_c = item;
1462 else if(*item == swap)
1463 ref_swap = item;
1464 if(ref_c && ref_swap)
1465 break;
1467 /* swap ! */
1468 *ref_c = swap;
1469 *ref_swap = c;
1471 /* Call hook to notify list change */
1472 if(globalconf.hooks.clients != LUA_REFNIL)
1473 luaA_dofunction_from_registry(L, globalconf.hooks.clients, 0, 0);
1475 luaA_class_emit_signal(globalconf.L, &client_class, "list", 0);
1478 return 0;
1481 /** Access or set the client tags.
1482 * \param L The Lua VM state.
1483 * \return The number of elements pushed on stack.
1484 * \lparam A table with tags to set, or none to get the current tags table.
1485 * \return The clients tag.
1487 static int
1488 luaA_client_tags(lua_State *L)
1490 client_t *c = luaA_client_checkudata(L, 1);
1491 tag_array_t *tags = &c->screen->tags;
1492 int j = 0;
1494 if(lua_gettop(L) == 2)
1496 luaA_checktable(L, 2);
1497 for(int i = 0; i < tags->len; i++)
1498 untag_client(c, tags->tab[i]);
1499 lua_pushnil(L);
1500 while(lua_next(L, 2))
1501 tag_client(c);
1502 lua_pop(L, 1);
1505 lua_newtable(L);
1506 foreach(tag, *tags)
1507 if(is_client_tagged(c, *tag))
1509 luaA_object_push(L, *tag);
1510 lua_rawseti(L, -2, ++j);
1513 return 1;
1516 /** Raise a client on top of others which are on the same layer.
1517 * \param L The Lua VM state.
1518 * \luastack
1519 * \lvalue A client.
1521 static int
1522 luaA_client_raise(lua_State *L)
1524 client_t *c = luaA_client_checkudata(L, 1);
1525 client_raise(c);
1526 return 0;
1529 /** Lower a client on bottom of others which are on the same layer.
1530 * \param L The Lua VM state.
1531 * \luastack
1532 * \lvalue A client.
1534 static int
1535 luaA_client_lower(lua_State *L)
1537 client_t *c = luaA_client_checkudata(L, 1);
1539 stack_client_push(c);
1541 /* Traverse all transient layers. */
1542 for(client_t *tc = c->transient_for; tc; tc = tc->transient_for)
1543 stack_client_push(tc);
1545 client_stack();
1547 return 0;
1550 /** Redraw a client by unmapping and mapping it quickly.
1551 * \param L The Lua VM state.
1553 * \luastack
1554 * \lvalue A client.
1556 static int
1557 luaA_client_redraw(lua_State *L)
1559 client_t *c = luaA_client_checkudata(L, 1);
1561 xcb_unmap_window(globalconf.connection, c->window);
1562 xcb_map_window(globalconf.connection, c->window);
1564 /* Set the focus on the current window if the redraw has been
1565 performed on the window where the pointer is currently on
1566 because after the unmapping/mapping, the focus is lost */
1567 if(globalconf.screen_focus->client_focus == c)
1569 client_unfocus(c);
1570 client_focus(c);
1573 return 0;
1576 /** Stop managing a client.
1577 * \param L The Lua VM state.
1578 * \return The number of elements pushed on stack.
1579 * \luastack
1580 * \lvalue A client.
1582 static int
1583 luaA_client_unmanage(lua_State *L)
1585 client_t *c = luaA_client_checkudata(L, 1);
1586 client_unmanage(c);
1587 return 0;
1590 /** Return client geometry.
1591 * \param L The Lua VM state.
1592 * \return The number of elements pushed on stack.
1593 * \luastack
1594 * \lparam A table with new coordinates, or none.
1595 * \lreturn A table with client coordinates.
1597 static int
1598 luaA_client_geometry(lua_State *L)
1600 client_t *c = luaA_client_checkudata(L, 1);
1602 if(lua_gettop(L) == 2)
1604 area_t geometry;
1606 luaA_checktable(L, 2);
1607 geometry.x = luaA_getopt_number(L, 2, "x", c->geometry.x);
1608 geometry.y = luaA_getopt_number(L, 2, "y", c->geometry.y);
1609 if(client_isfixed(c))
1611 geometry.width = c->geometry.width;
1612 geometry.height = c->geometry.height;
1614 else
1616 geometry.width = luaA_getopt_number(L, 2, "width", c->geometry.width);
1617 geometry.height = luaA_getopt_number(L, 2, "height", c->geometry.height);
1620 client_resize(c, geometry, c->size_hints_honor);
1623 return luaA_pusharea(L, c->geometry);
1626 /** Return client struts (reserved space at the edge of the screen).
1627 * \param L The Lua VM state.
1628 * \return The number of elements pushed on stack.
1629 * \luastack
1630 * \lparam A table with new strut values, or none.
1631 * \lreturn A table with strut values.
1633 static int
1634 luaA_client_struts(lua_State *L)
1636 client_t *c = luaA_client_checkudata(L, 1);
1638 if(lua_gettop(L) == 2)
1640 luaA_tostrut(L, 2, &c->strut);
1641 ewmh_update_strut(c->window, &c->strut);
1642 hook_property(c, "struts");
1643 luaA_object_emit_signal(L, 1, "property::struts", 0);
1644 screen_emit_signal(L, c->screen, "property::workarea", 0);
1647 return luaA_pushstrut(L, c->strut);
1650 static int
1651 luaA_client_set_screen(lua_State *L, client_t *c)
1653 if(globalconf.xinerama_is_active)
1655 int screen = luaL_checknumber(L, -1) - 1;
1656 luaA_checkscreen(screen);
1657 screen_client_moveto(c, &globalconf.screens.tab[screen], true);
1659 return 0;
1662 static int
1663 luaA_client_set_hidden(lua_State *L, client_t *c)
1665 bool b = luaA_checkboolean(L, -1);
1666 if(b != c->hidden)
1668 client_need_reban(c);
1669 c->hidden = b;
1670 client_need_reban(c);
1671 hook_property(c, "hidden");
1672 if(strut_has_value(&c->strut))
1673 screen_emit_signal(globalconf.L, c->screen, "property::workarea", 0);
1674 luaA_object_emit_signal(L, -3, "property::hidden", 0);
1676 return 0;
1679 static int
1680 luaA_client_set_minimized(lua_State *L, client_t *c)
1682 client_set_minimized(L, -3, luaA_checkboolean(L, -1));
1683 return 0;
1686 static int
1687 luaA_client_set_fullscreen(lua_State *L, client_t *c)
1689 client_set_fullscreen(L, -3, luaA_checkboolean(L, -1));
1690 return 0;
1693 static int
1694 luaA_client_set_modal(lua_State *L, client_t *c)
1696 client_set_modal(L, -3, luaA_checkboolean(L, -1));
1697 return 0;
1700 static int
1701 luaA_client_set_maximized_horizontal(lua_State *L, client_t *c)
1703 client_set_maximized_horizontal(L, -3, luaA_checkboolean(L, -1));
1704 return 0;
1707 static int
1708 luaA_client_set_maximized_vertical(lua_State *L, client_t *c)
1710 client_set_maximized_vertical(L, -3, luaA_checkboolean(L, -1));
1711 return 0;
1714 static int
1715 luaA_client_set_icon(lua_State *L, client_t *c)
1717 client_set_icon(L, -3, -1);
1718 return 0;
1721 static int
1722 luaA_client_set_opacity(lua_State *L, client_t *c)
1724 if(lua_isnil(L, -1))
1725 client_set_opacity(L, -3, -1);
1726 else
1727 client_set_opacity(L, -3, luaL_checknumber(L, -1));
1728 return 0;
1731 static int
1732 luaA_client_set_sticky(lua_State *L, client_t *c)
1734 client_set_sticky(L, -3, luaA_checkboolean(L, -1));
1735 return 0;
1738 static int
1739 luaA_client_set_size_hints_honor(lua_State *L, client_t *c)
1741 c->size_hints_honor = luaA_checkboolean(L, -1);
1742 hook_property(c, "size_hints_honor");
1743 luaA_object_emit_signal(L, -3, "property::size_hints_honor", 0);
1744 return 0;
1747 static int
1748 luaA_client_set_border_width(lua_State *L, client_t *c)
1750 client_set_border_width(L, -3, luaL_checknumber(L, -1));
1751 return 0;
1754 static int
1755 luaA_client_set_ontop(lua_State *L, client_t *c)
1757 client_set_ontop(L, -3, luaA_checkboolean(L, -1));
1758 return 0;
1761 static int
1762 luaA_client_set_below(lua_State *L, client_t *c)
1764 client_set_below(L, -3, luaA_checkboolean(L, -1));
1765 return 0;
1768 static int
1769 luaA_client_set_above(lua_State *L, client_t *c)
1771 client_set_above(L, -3, luaA_checkboolean(L, -1));
1772 return 0;
1775 static int
1776 luaA_client_set_urgent(lua_State *L, client_t *c)
1778 client_set_urgent(L, -3, luaA_checkboolean(L, -1));
1779 return 0;
1782 static int
1783 luaA_client_set_border_color(lua_State *L, client_t *c)
1785 size_t len;
1786 const char *buf;
1787 if((buf = luaL_checklstring(L, -1, &len))
1788 && xcolor_init_reply(xcolor_init_unchecked(&c->border_color, buf, len)))
1790 xcb_change_window_attributes(globalconf.connection, c->window,
1791 XCB_CW_BORDER_PIXEL, &c->border_color.pixel);
1792 luaA_object_emit_signal(L, -3, "property::border_color", 0);
1794 return 0;
1797 static int
1798 luaA_client_set_titlebar(lua_State *L, client_t *c)
1800 if(lua_isnil(L, -1))
1801 titlebar_client_detach(c);
1802 else
1803 titlebar_client_attach(c);
1804 return 0;
1807 static int
1808 luaA_client_set_skip_taskbar(lua_State *L, client_t *c)
1810 client_set_skip_taskbar(L, -3, luaA_checkboolean(L, -1));
1811 return 0;
1814 static int
1815 luaA_client_get_name(lua_State *L, client_t *c)
1817 lua_pushstring(L, c->name ? c->name : c->alt_name);
1818 return 1;
1821 static int
1822 luaA_client_get_icon_name(lua_State *L, client_t *c)
1824 lua_pushstring(L, c->icon_name ? c->icon_name : c->alt_icon_name);
1825 return 1;
1828 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, class, lua_pushstring)
1829 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, instance, lua_pushstring)
1830 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, machine, lua_pushstring)
1831 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, role, lua_pushstring)
1832 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, transient_for, luaA_object_push)
1833 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, skip_taskbar, lua_pushboolean)
1834 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, window, lua_pushnumber)
1835 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, leader_window, lua_pushnumber)
1836 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, group_window, lua_pushnumber)
1837 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, pid, lua_pushnumber)
1838 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, hidden, lua_pushboolean)
1839 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, minimized, lua_pushboolean)
1840 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, fullscreen, lua_pushboolean)
1841 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, modal, lua_pushboolean)
1842 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, ontop, lua_pushboolean)
1843 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, urgent, lua_pushboolean)
1844 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, above, lua_pushboolean)
1845 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, below, lua_pushboolean)
1846 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, sticky, lua_pushboolean)
1847 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, size_hints_honor, lua_pushboolean)
1848 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, maximized_horizontal, lua_pushboolean)
1849 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, maximized_vertical, lua_pushboolean)
1850 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, opacity, lua_pushnumber)
1851 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, border_width, lua_pushnumber)
1852 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, border_color, luaA_pushxcolor)
1854 static int
1855 luaA_client_get_content(lua_State *L, client_t *c)
1857 xcb_image_t *ximage = xcb_image_get(globalconf.connection,
1858 c->window,
1859 0, 0,
1860 c->geometries.internal.width,
1861 c->geometries.internal.height,
1862 ~0, XCB_IMAGE_FORMAT_Z_PIXMAP);
1863 int retval = 0;
1865 if(ximage)
1867 if(ximage->bpp >= 24)
1869 uint32_t *data = p_alloca(uint32_t, ximage->width * ximage->height);
1871 for(int y = 0; y < ximage->height; y++)
1872 for(int x = 0; x < ximage->width; x++)
1874 data[y * ximage->width + x] = xcb_image_get_pixel(ximage, x, y);
1875 data[y * ximage->width + x] |= 0xff000000; /* set alpha to 0xff */
1878 retval = image_new_from_argb32(ximage->width, ximage->height, data);
1880 xcb_image_destroy(ximage);
1883 return retval;
1886 static int
1887 luaA_client_get_type(lua_State *L, client_t *c)
1889 switch(c->type)
1891 case WINDOW_TYPE_DESKTOP:
1892 lua_pushliteral(L, "desktop");
1893 break;
1894 case WINDOW_TYPE_DOCK:
1895 lua_pushliteral(L, "dock");
1896 break;
1897 case WINDOW_TYPE_SPLASH:
1898 lua_pushliteral(L, "splash");
1899 break;
1900 case WINDOW_TYPE_DIALOG:
1901 lua_pushliteral(L, "dialog");
1902 break;
1903 case WINDOW_TYPE_MENU:
1904 lua_pushliteral(L, "menu");
1905 break;
1906 case WINDOW_TYPE_TOOLBAR:
1907 lua_pushliteral(L, "toolbar");
1908 break;
1909 case WINDOW_TYPE_UTILITY:
1910 lua_pushliteral(L, "utility");
1911 break;
1912 case WINDOW_TYPE_DROPDOWN_MENU:
1913 lua_pushliteral(L, "dropdown_menu");
1914 break;
1915 case WINDOW_TYPE_POPUP_MENU:
1916 lua_pushliteral(L, "popup_menu");
1917 break;
1918 case WINDOW_TYPE_TOOLTIP:
1919 lua_pushliteral(L, "tooltip");
1920 break;
1921 case WINDOW_TYPE_NOTIFICATION:
1922 lua_pushliteral(L, "notification");
1923 break;
1924 case WINDOW_TYPE_COMBO:
1925 lua_pushliteral(L, "combo");
1926 break;
1927 case WINDOW_TYPE_DND:
1928 lua_pushliteral(L, "dnd");
1929 break;
1930 case WINDOW_TYPE_NORMAL:
1931 lua_pushliteral(L, "normal");
1932 break;
1934 return 1;
1937 static int
1938 luaA_client_get_screen(lua_State *L, client_t *c)
1940 if(!c->screen)
1941 return 0;
1942 lua_pushnumber(L, 1 + screen_array_indexof(&globalconf.screens, c->screen));
1943 return 1;
1946 static int
1947 luaA_client_get_icon(lua_State *L, client_t *c)
1949 return luaA_object_push_item(L, -2, c->icon);
1952 static int
1953 luaA_client_get_titlebar(lua_State *L, client_t *c)
1955 return luaA_object_push(L, c->titlebar);
1958 static int
1959 luaA_client_get_size_hints(lua_State *L, client_t *c)
1961 const char *u_or_p = NULL;
1963 lua_createtable(L, 0, 1);
1965 if(c->size_hints.flags & XCB_SIZE_HINT_US_POSITION)
1966 u_or_p = "user_position";
1967 else if(c->size_hints.flags & XCB_SIZE_HINT_P_POSITION)
1968 u_or_p = "program_position";
1970 if(u_or_p)
1972 lua_createtable(L, 0, 2);
1973 lua_pushnumber(L, c->size_hints.x);
1974 lua_setfield(L, -2, "x");
1975 lua_pushnumber(L, c->size_hints.y);
1976 lua_setfield(L, -2, "y");
1977 lua_setfield(L, -2, u_or_p);
1978 u_or_p = NULL;
1981 if(c->size_hints.flags & XCB_SIZE_HINT_US_SIZE)
1982 u_or_p = "user_size";
1983 else if(c->size_hints.flags & XCB_SIZE_HINT_P_SIZE)
1984 u_or_p = "program_size";
1986 if(u_or_p)
1988 lua_createtable(L, 0, 2);
1989 lua_pushnumber(L, c->size_hints.width);
1990 lua_setfield(L, -2, "width");
1991 lua_pushnumber(L, c->size_hints.height);
1992 lua_setfield(L, -2, "height");
1993 lua_setfield(L, -2, u_or_p);
1996 if(c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)
1998 lua_pushnumber(L, c->size_hints.min_width);
1999 lua_setfield(L, -2, "min_width");
2000 lua_pushnumber(L, c->size_hints.min_height);
2001 lua_setfield(L, -2, "min_height");
2004 if(c->size_hints.flags & XCB_SIZE_HINT_P_MAX_SIZE)
2006 lua_pushnumber(L, c->size_hints.max_width);
2007 lua_setfield(L, -2, "max_width");
2008 lua_pushnumber(L, c->size_hints.max_height);
2009 lua_setfield(L, -2, "max_height");
2012 if(c->size_hints.flags & XCB_SIZE_HINT_P_RESIZE_INC)
2014 lua_pushnumber(L, c->size_hints.width_inc);
2015 lua_setfield(L, -2, "width_inc");
2016 lua_pushnumber(L, c->size_hints.height_inc);
2017 lua_setfield(L, -2, "height_inc");
2020 if(c->size_hints.flags & XCB_SIZE_HINT_P_ASPECT)
2022 lua_pushnumber(L, c->size_hints.min_aspect_num);
2023 lua_setfield(L, -2, "min_aspect_num");
2024 lua_pushnumber(L, c->size_hints.min_aspect_den);
2025 lua_setfield(L, -2, "min_aspect_den");
2026 lua_pushnumber(L, c->size_hints.max_aspect_num);
2027 lua_setfield(L, -2, "max_aspect_num");
2028 lua_pushnumber(L, c->size_hints.max_aspect_den);
2029 lua_setfield(L, -2, "max_aspect_den");
2032 if(c->size_hints.flags & XCB_SIZE_HINT_BASE_SIZE)
2034 lua_pushnumber(L, c->size_hints.base_width);
2035 lua_setfield(L, -2, "base_width");
2036 lua_pushnumber(L, c->size_hints.base_height);
2037 lua_setfield(L, -2, "base_height");
2040 if(c->size_hints.flags & XCB_SIZE_HINT_P_WIN_GRAVITY)
2042 switch(c->size_hints.win_gravity)
2044 default:
2045 lua_pushliteral(L, "north_west");
2046 break;
2047 case XCB_GRAVITY_NORTH:
2048 lua_pushliteral(L, "north");
2049 break;
2050 case XCB_GRAVITY_NORTH_EAST:
2051 lua_pushliteral(L, "north_east");
2052 break;
2053 case XCB_GRAVITY_WEST:
2054 lua_pushliteral(L, "west");
2055 break;
2056 case XCB_GRAVITY_CENTER:
2057 lua_pushliteral(L, "center");
2058 break;
2059 case XCB_GRAVITY_EAST:
2060 lua_pushliteral(L, "east");
2061 break;
2062 case XCB_GRAVITY_SOUTH_WEST:
2063 lua_pushliteral(L, "south_west");
2064 break;
2065 case XCB_GRAVITY_SOUTH:
2066 lua_pushliteral(L, "south");
2067 break;
2068 case XCB_GRAVITY_SOUTH_EAST:
2069 lua_pushliteral(L, "south_east");
2070 break;
2071 case XCB_GRAVITY_STATIC:
2072 lua_pushliteral(L, "static");
2073 break;
2075 lua_setfield(L, -2, "win_gravity");
2078 return 1;
2081 /** Get or set mouse buttons bindings for a client.
2082 * \param L The Lua VM state.
2083 * \return The number of element pushed on stack.
2084 * \luastack
2085 * \lvalue A client.
2086 * \lparam An array of mouse button bindings objects, or nothing.
2087 * \return The array of mouse button bindings objects of this client.
2089 static int
2090 luaA_client_buttons(lua_State *L)
2092 client_t *client = luaA_client_checkudata(L, 1);
2093 button_array_t *buttons = &client->buttons;
2095 if(lua_gettop(L) == 2)
2097 luaA_button_array_set(L, 1, 2, buttons);
2098 luaA_object_emit_signal(L, 1, "property::buttons", 0);
2099 window_buttons_grab(client->window, &client->buttons);
2102 return luaA_button_array_get(L, 1, buttons);
2105 /** Get or set keys bindings for a client.
2106 * \param L The Lua VM state.
2107 * \return The number of element pushed on stack.
2108 * \luastack
2109 * \lvalue A client.
2110 * \lparam An array of key bindings objects, or nothing.
2111 * \return The array of key bindings objects of this client.
2113 static int
2114 luaA_client_keys(lua_State *L)
2116 client_t *c = luaA_client_checkudata(L, 1);
2117 key_array_t *keys = &c->keys;
2119 if(lua_gettop(L) == 2)
2121 luaA_key_array_set(L, 1, 2, keys);
2122 luaA_object_emit_signal(L, 1, "property::keys", 0);
2123 xcb_ungrab_key(globalconf.connection, XCB_GRAB_ANY, c->window, XCB_BUTTON_MASK_ANY);
2124 window_grabkeys(c->window, keys);
2127 return luaA_key_array_get(L, 1, keys);
2130 /* Client module.
2131 * \param L The Lua VM state.
2132 * \return The number of pushed elements.
2134 static int
2135 luaA_client_module_index(lua_State *L)
2137 size_t len;
2138 const char *buf = luaL_checklstring(L, 2, &len);
2140 switch(a_tokenize(buf, len))
2142 case A_TK_FOCUS:
2143 return luaA_object_push(globalconf.L, globalconf.screen_focus->client_focus);
2144 break;
2145 default:
2146 return 0;
2150 /* Client module new index.
2151 * \param L The Lua VM state.
2152 * \return The number of pushed elements.
2154 static int
2155 luaA_client_module_newindex(lua_State *L)
2157 size_t len;
2158 const char *buf = luaL_checklstring(L, 2, &len);
2159 client_t *c;
2161 switch(a_tokenize(buf, len))
2163 case A_TK_FOCUS:
2164 c = luaA_client_checkudata(L, 3);
2165 client_focus(c);
2166 break;
2167 default:
2168 break;
2171 return 0;
2174 void
2175 client_class_setup(lua_State *L)
2177 static const struct luaL_reg client_methods[] =
2179 LUA_CLASS_METHODS(client)
2180 { "get", luaA_client_get },
2181 { "__index", luaA_client_module_index },
2182 { "__newindex", luaA_client_module_newindex },
2183 { NULL, NULL }
2186 static const struct luaL_reg client_meta[] =
2188 LUA_OBJECT_META(client)
2189 LUA_CLASS_META
2190 { "buttons", luaA_client_buttons },
2191 { "keys", luaA_client_keys },
2192 { "isvisible", luaA_client_isvisible },
2193 { "geometry", luaA_client_geometry },
2194 { "struts", luaA_client_struts },
2195 { "tags", luaA_client_tags },
2196 { "kill", luaA_client_kill },
2197 { "swap", luaA_client_swap },
2198 { "raise", luaA_client_raise },
2199 { "lower", luaA_client_lower },
2200 { "redraw", luaA_client_redraw },
2201 { "unmanage", luaA_client_unmanage },
2202 { "__gc", luaA_client_gc },
2203 { NULL, NULL }
2206 luaA_class_setup(L, &client_class, "client", (lua_class_allocator_t) client_new,
2207 luaA_class_index_miss_property, luaA_class_newindex_miss_property,
2208 client_methods, client_meta);
2209 luaA_class_add_property(&client_class, A_TK_NAME,
2210 NULL,
2211 (lua_class_propfunc_t) luaA_client_get_name,
2212 NULL);
2213 luaA_class_add_property(&client_class, A_TK_TRANSIENT_FOR,
2214 NULL,
2215 (lua_class_propfunc_t) luaA_client_get_transient_for,
2216 NULL);
2217 luaA_class_add_property(&client_class, A_TK_SKIP_TASKBAR,
2218 (lua_class_propfunc_t) luaA_client_set_skip_taskbar,
2219 (lua_class_propfunc_t) luaA_client_get_skip_taskbar,
2220 (lua_class_propfunc_t) luaA_client_set_skip_taskbar);
2221 luaA_class_add_property(&client_class, A_TK_CONTENT,
2222 NULL,
2223 (lua_class_propfunc_t) luaA_client_get_content,
2224 NULL);
2225 luaA_class_add_property(&client_class, A_TK_TYPE,
2226 NULL,
2227 (lua_class_propfunc_t) luaA_client_get_type,
2228 NULL);
2229 luaA_class_add_property(&client_class, A_TK_CLASS,
2230 NULL,
2231 (lua_class_propfunc_t) luaA_client_get_class,
2232 NULL);
2233 luaA_class_add_property(&client_class, A_TK_INSTANCE,
2234 NULL,
2235 (lua_class_propfunc_t) luaA_client_get_instance,
2236 NULL);
2237 luaA_class_add_property(&client_class, A_TK_ROLE,
2238 NULL,
2239 (lua_class_propfunc_t) luaA_client_get_role,
2240 NULL);
2241 luaA_class_add_property(&client_class, A_TK_PID,
2242 NULL,
2243 (lua_class_propfunc_t) luaA_client_get_pid,
2244 NULL);
2245 luaA_class_add_property(&client_class, A_TK_WINDOW,
2246 NULL,
2247 (lua_class_propfunc_t) luaA_client_get_window,
2248 NULL);
2249 luaA_class_add_property(&client_class, A_TK_LEADER_WINDOW,
2250 NULL,
2251 (lua_class_propfunc_t) luaA_client_get_leader_window,
2252 NULL);
2253 luaA_class_add_property(&client_class, A_TK_MACHINE,
2254 NULL,
2255 (lua_class_propfunc_t) luaA_client_get_machine,
2256 NULL);
2257 luaA_class_add_property(&client_class, A_TK_ICON_NAME,
2258 NULL,
2259 (lua_class_propfunc_t) luaA_client_get_icon_name,
2260 NULL);
2261 luaA_class_add_property(&client_class, A_TK_SCREEN,
2262 NULL,
2263 (lua_class_propfunc_t) luaA_client_get_screen,
2264 (lua_class_propfunc_t) luaA_client_set_screen);
2265 luaA_class_add_property(&client_class, A_TK_HIDDEN,
2266 (lua_class_propfunc_t) luaA_client_set_hidden,
2267 (lua_class_propfunc_t) luaA_client_get_hidden,
2268 (lua_class_propfunc_t) luaA_client_set_hidden);
2269 luaA_class_add_property(&client_class, A_TK_MINIMIZED,
2270 (lua_class_propfunc_t) luaA_client_set_minimized,
2271 (lua_class_propfunc_t) luaA_client_get_minimized,
2272 (lua_class_propfunc_t) luaA_client_set_minimized);
2273 luaA_class_add_property(&client_class, A_TK_FULLSCREEN,
2274 (lua_class_propfunc_t) luaA_client_set_fullscreen,
2275 (lua_class_propfunc_t) luaA_client_get_fullscreen,
2276 (lua_class_propfunc_t) luaA_client_set_fullscreen);
2277 luaA_class_add_property(&client_class, A_TK_MODAL,
2278 (lua_class_propfunc_t) luaA_client_set_modal,
2279 (lua_class_propfunc_t) luaA_client_get_modal,
2280 (lua_class_propfunc_t) luaA_client_set_modal);
2281 luaA_class_add_property(&client_class, A_TK_GROUP_WINDOW,
2282 NULL,
2283 (lua_class_propfunc_t) luaA_client_get_group_window,
2284 NULL);
2285 luaA_class_add_property(&client_class, A_TK_MAXIMIZED_HORIZONTAL,
2286 (lua_class_propfunc_t) luaA_client_set_maximized_horizontal,
2287 (lua_class_propfunc_t) luaA_client_get_maximized_horizontal,
2288 (lua_class_propfunc_t) luaA_client_set_maximized_horizontal);
2289 luaA_class_add_property(&client_class, A_TK_MAXIMIZED_VERTICAL,
2290 (lua_class_propfunc_t) luaA_client_set_maximized_vertical,
2291 (lua_class_propfunc_t) luaA_client_get_maximized_vertical,
2292 (lua_class_propfunc_t) luaA_client_set_maximized_vertical);
2293 luaA_class_add_property(&client_class, A_TK_ICON,
2294 (lua_class_propfunc_t) luaA_client_set_icon,
2295 (lua_class_propfunc_t) luaA_client_get_icon,
2296 (lua_class_propfunc_t) luaA_client_set_icon);
2297 luaA_class_add_property(&client_class, A_TK_OPACITY,
2298 (lua_class_propfunc_t) luaA_client_set_opacity,
2299 (lua_class_propfunc_t) luaA_client_get_opacity,
2300 (lua_class_propfunc_t) luaA_client_set_opacity);
2301 luaA_class_add_property(&client_class, A_TK_ONTOP,
2302 (lua_class_propfunc_t) luaA_client_set_ontop,
2303 (lua_class_propfunc_t) luaA_client_get_ontop,
2304 (lua_class_propfunc_t) luaA_client_set_ontop);
2305 luaA_class_add_property(&client_class, A_TK_ABOVE,
2306 (lua_class_propfunc_t) luaA_client_set_above,
2307 (lua_class_propfunc_t) luaA_client_get_above,
2308 (lua_class_propfunc_t) luaA_client_set_above);
2309 luaA_class_add_property(&client_class, A_TK_BELOW,
2310 (lua_class_propfunc_t) luaA_client_set_below,
2311 (lua_class_propfunc_t) luaA_client_get_below,
2312 (lua_class_propfunc_t) luaA_client_set_below);
2313 luaA_class_add_property(&client_class, A_TK_STICKY,
2314 (lua_class_propfunc_t) luaA_client_set_sticky,
2315 (lua_class_propfunc_t) luaA_client_get_sticky,
2316 (lua_class_propfunc_t) luaA_client_set_sticky);
2317 luaA_class_add_property(&client_class, A_TK_SIZE_HINTS_HONOR,
2318 (lua_class_propfunc_t) luaA_client_set_size_hints_honor,
2319 (lua_class_propfunc_t) luaA_client_get_size_hints_honor,
2320 (lua_class_propfunc_t) luaA_client_set_size_hints_honor);
2321 luaA_class_add_property(&client_class, A_TK_BORDER_WIDTH,
2322 (lua_class_propfunc_t) luaA_client_set_border_width,
2323 (lua_class_propfunc_t) luaA_client_get_border_width,
2324 (lua_class_propfunc_t) luaA_client_set_border_width);
2325 luaA_class_add_property(&client_class, A_TK_BORDER_COLOR,
2326 (lua_class_propfunc_t) luaA_client_set_border_color,
2327 (lua_class_propfunc_t) luaA_client_get_border_color,
2328 (lua_class_propfunc_t) luaA_client_set_border_color);
2329 luaA_class_add_property(&client_class, A_TK_TITLEBAR,
2330 (lua_class_propfunc_t) luaA_client_set_titlebar,
2331 (lua_class_propfunc_t) luaA_client_get_titlebar,
2332 (lua_class_propfunc_t) luaA_client_set_titlebar);
2333 luaA_class_add_property(&client_class, A_TK_URGENT,
2334 (lua_class_propfunc_t) luaA_client_set_urgent,
2335 (lua_class_propfunc_t) luaA_client_get_urgent,
2336 (lua_class_propfunc_t) luaA_client_set_urgent);
2337 luaA_class_add_property(&client_class, A_TK_SIZE_HINTS,
2338 NULL,
2339 (lua_class_propfunc_t) luaA_client_get_size_hints,
2340 NULL);
2343 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80