awful.menu: add keygrabber support to clients menu
[awesome.git] / client.c
blob4401b101ac2a6c797bea012b4319c27eaf8eaca8
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->machine);
57 p_delete(&c->class);
58 p_delete(&c->instance);
59 p_delete(&c->icon_name);
60 p_delete(&c->alt_icon_name);
61 p_delete(&c->name);
62 p_delete(&c->alt_name);
63 return luaA_object_gc(L);
66 /** Change the client opacity.
67 * \param L The Lua VM state.
68 * \param cidx The client index.
69 * \param opacity The opacity.
71 void
72 client_set_opacity(lua_State *L, int cidx, double opacity)
74 client_t *c = luaA_client_checkudata(L, cidx);
76 if(c->opacity != opacity)
78 c->opacity = opacity;
79 window_opacity_set(c->window, opacity);
80 luaA_object_emit_signal(L, cidx, "property::opacity", 0);
84 /** Change the clients urgency flag.
85 * \param L The Lua VM state.
86 * \param cidx The client index on the stack.
87 * \param urgent The new flag state.
89 void
90 client_set_urgent(lua_State *L, int cidx, bool urgent)
92 client_t *c = luaA_client_checkudata(L, cidx);
94 if(c->urgent != urgent)
96 xcb_get_property_cookie_t hints =
97 xcb_get_wm_hints_unchecked(globalconf.connection, c->window);
99 c->urgent = urgent;
100 ewmh_client_update_hints(c);
102 /* update ICCCM hints */
103 xcb_wm_hints_t wmh;
104 xcb_get_wm_hints_reply(globalconf.connection, hints, &wmh, NULL);
106 if(urgent)
107 wmh.flags |= XCB_WM_HINT_X_URGENCY;
108 else
109 wmh.flags &= ~XCB_WM_HINT_X_URGENCY;
111 xcb_set_wm_hints(globalconf.connection, c->window, &wmh);
113 hook_property(c, "urgent");
114 luaA_object_emit_signal(L, cidx, "property::urgent", 0);
118 void
119 client_set_group_window(lua_State *L, int cidx, xcb_window_t window)
121 client_t *c = luaA_client_checkudata(L, cidx);
123 if(c->group_window != window)
125 c->group_window = window;
126 luaA_object_emit_signal(L, cidx, "property::group_window", 0);
130 void
131 client_set_type(lua_State *L, int cidx, window_type_t type)
133 client_t *c = luaA_client_checkudata(L, cidx);
135 if(c->type != type)
137 c->type = type;
138 luaA_object_emit_signal(L, cidx, "property::type", 0);
142 void
143 client_set_pid(lua_State *L, int cidx, uint32_t pid)
145 client_t *c = luaA_client_checkudata(L, cidx);
147 if(c->pid != pid)
149 c->pid = pid;
150 luaA_object_emit_signal(L, cidx, "property::pid", 0);
154 void
155 client_set_icon_name(lua_State *L, int cidx, char *icon_name)
157 client_t *c = luaA_client_checkudata(L, cidx);
158 p_delete(&c->icon_name);
159 c->icon_name = icon_name;
160 luaA_object_emit_signal(L, cidx, "property::icon_name", 0);
161 hook_property(c, "icon_name");
164 void
165 client_set_alt_icon_name(lua_State *L, int cidx, char *icon_name)
167 client_t *c = luaA_client_checkudata(L, cidx);
168 p_delete(&c->alt_icon_name);
169 c->alt_icon_name = icon_name;
170 luaA_object_emit_signal(L, cidx, "property::icon_name", 0);
171 hook_property(c, "icon_name");
174 void
175 client_set_role(lua_State *L, int cidx, char *role)
177 client_t *c = luaA_client_checkudata(L, cidx);
178 p_delete(&c->role);
179 c->role = role;
180 luaA_object_emit_signal(L, cidx, "property::role", 0);
183 void
184 client_set_machine(lua_State *L, int cidx, char *machine)
186 client_t *c = luaA_client_checkudata(L, cidx);
187 p_delete(&c->machine);
188 c->machine = machine;
189 luaA_object_emit_signal(L, cidx, "property::machine", 0);
192 void
193 client_set_class_instance(lua_State *L, int cidx, const char *class, const char *instance)
195 client_t *c = luaA_client_checkudata(L, cidx);
196 p_delete(&c->class);
197 p_delete(&c->instance);
198 c->class = a_strdup(class);
199 c->instance = a_strdup(instance);
200 luaA_object_emit_signal(L, cidx, "property::class", 0);
201 luaA_object_emit_signal(L, cidx, "property::instance", 0);
204 void
205 client_set_transient_for(lua_State *L, int cidx, client_t *transient_for)
207 client_t *c = luaA_client_checkudata(L, cidx);
209 if(c->transient_for != transient_for)
211 c->transient_for = transient_for;
212 luaA_object_emit_signal(L, cidx, "property::transient_for", 0);
216 void
217 client_set_name(lua_State *L, int cidx, char *name)
219 client_t *c = luaA_client_checkudata(L, cidx);
220 p_delete(&c->name);
221 c->name = name;
222 hook_property(c, "name");
223 luaA_object_emit_signal(L, cidx, "property::name", 0);
226 void
227 client_set_alt_name(lua_State *L, int cidx, char *name)
229 client_t *c = luaA_client_checkudata(L, cidx);
230 p_delete(&c->alt_name);
231 c->alt_name = name;
232 hook_property(c, "name");
233 luaA_object_emit_signal(L, cidx, "property::name", 0);
236 /** Returns true if a client is tagged
237 * with one of the tags of the specified screen.
238 * \param c The client to check.
239 * \param screen Virtual screen.
240 * \return true if the client is visible, false otherwise.
242 bool
243 client_maybevisible(client_t *c, screen_t *screen)
245 if(screen && c->screen == screen)
247 if(c->sticky || c->type == WINDOW_TYPE_DESKTOP)
248 return true;
250 foreach(tag, screen->tags)
251 if(tag_get_selected(*tag) && is_client_tagged(c, *tag))
252 return true;
254 return false;
257 /** Get a client by its window.
258 * \param w The client window to find.
259 * \return A client pointer if found, NULL otherwise.
261 client_t *
262 client_getbywin(xcb_window_t w)
264 foreach(c, globalconf.clients)
265 if((*c)->window == w)
266 return *c;
268 return NULL;
271 /** Record that a client lost focus.
272 * \param c Client being unfocused
274 void
275 client_unfocus_update(client_t *c)
277 globalconf.screens.tab[c->phys_screen].client_focus = NULL;
278 ewmh_update_net_active_window(c->phys_screen);
280 /* Call hook */
281 if(globalconf.hooks.unfocus != LUA_REFNIL)
283 luaA_object_push(globalconf.L, c);
284 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.unfocus, 1, 0);
287 luaA_object_push(globalconf.L, c);
288 luaA_class_emit_signal(globalconf.L, &client_class, "unfocus", 1);
291 /** Unfocus a client.
292 * \param c The client.
294 void
295 client_unfocus(client_t *c)
298 xcb_window_t root_win = xutil_screen_get(globalconf.connection, c->phys_screen)->root;
299 /* Set focus on root window, so no events leak to the current window.
300 * This kind of inlines client_set_focus(), but a root window will never have
301 * the WM_TAKE_FOCUS protocol.
303 xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_PARENT,
304 root_win, XCB_CURRENT_TIME);
306 client_unfocus_update(c);
309 /** Check if client supports atom a protocol in WM_PROTOCOL.
310 * \param c The client.
311 * \param atom The protocol atom to check for.
312 * \return True if client has the atom in protocol, false otherwise.
314 bool
315 client_hasproto(client_t *c, xcb_atom_t atom)
317 for(uint32_t i = 0; i < c->protocols.atoms_len; i++)
318 if(c->protocols.atoms[i] == atom)
319 return true;
320 return false;
323 /** Sets focus on window - using xcb_set_input_focus or WM_TAKE_FOCUS
324 * \param c Client that should get focus
325 * \param set_input_focus Should we call xcb_set_input_focus
327 void
328 client_set_focus(client_t *c, bool set_input_focus)
330 bool takefocus = client_hasproto(c, WM_TAKE_FOCUS);
331 if(set_input_focus)
332 xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_PARENT,
333 c->window, XCB_CURRENT_TIME);
334 if(takefocus)
335 window_takefocus(c->window);
338 /** Prepare banning a client by running all needed lua events.
339 * \param c The client.
341 void client_ban_unfocus(client_t *c)
343 if(globalconf.screens.tab[c->phys_screen].prev_client_focus == c)
344 globalconf.screens.tab[c->phys_screen].prev_client_focus = NULL;
346 /* Wait until the last moment to take away the focus from the window. */
347 if(globalconf.screens.tab[c->phys_screen].client_focus == c)
348 client_unfocus(c);
351 /** Ban client and move it out of the viewport.
352 * \param c The client.
354 void
355 client_ban(client_t *c)
357 if(!c->isbanned)
359 xcb_unmap_window(globalconf.connection, c->window);
361 c->isbanned = true;
363 client_ban_unfocus(c);
367 /** This is part of The Bob Marley Algorithm: we ignore enter and leave window
368 * in certain cases, like map/unmap or move, so we don't get spurious events.
370 void
371 client_ignore_enterleave_events(void)
373 foreach(c, globalconf.clients)
374 xcb_change_window_attributes(globalconf.connection,
375 (*c)->window,
376 XCB_CW_EVENT_MASK,
377 (const uint32_t []) { CLIENT_SELECT_INPUT_EVENT_MASK & ~(XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW) });
380 void
381 client_restore_enterleave_events(void)
383 foreach(c, globalconf.clients)
384 xcb_change_window_attributes(globalconf.connection,
385 (*c)->window,
386 XCB_CW_EVENT_MASK,
387 (const uint32_t []) { CLIENT_SELECT_INPUT_EVENT_MASK });
390 /** Record that a client got focus.
391 * \param c The client.
393 void
394 client_focus_update(client_t *c)
396 if(!client_maybevisible(c, c->screen))
398 /* Focus previously focused client */
399 client_focus(globalconf.screen_focus->prev_client_focus);
400 return;
403 if(globalconf.screen_focus
404 && globalconf.screen_focus->client_focus)
406 if (globalconf.screen_focus->client_focus != c)
407 client_unfocus_update(globalconf.screen_focus->client_focus);
408 else
409 /* Already focused */
410 return;
412 luaA_object_push(globalconf.L, c);
413 client_set_minimized(globalconf.L, -1, false);
415 /* unban the client before focusing for consistency */
416 client_unban(c);
418 globalconf.screen_focus = &globalconf.screens.tab[c->phys_screen];
419 globalconf.screen_focus->prev_client_focus = c;
420 globalconf.screen_focus->client_focus = c;
422 /* according to EWMH, we have to remove the urgent state from a client */
423 client_set_urgent(globalconf.L, -1, false);
425 ewmh_update_net_active_window(c->phys_screen);
427 /* execute hook */
428 if(globalconf.hooks.focus != LUA_REFNIL)
430 luaA_object_push(globalconf.L, c);
431 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.focus, 1, 0);
434 luaA_object_push(globalconf.L, c);
435 luaA_class_emit_signal(globalconf.L, &client_class, "focus", 1);
438 /** Give focus to client, or to first client if client is NULL.
439 * \param c The client.
441 void
442 client_focus(client_t *c)
444 /* We have to set focus on first client */
445 if(!c && globalconf.clients.len && !(c = globalconf.clients.tab[0]))
446 return;
448 if(!client_maybevisible(c, c->screen))
449 return;
451 if (!c->nofocus)
452 client_focus_update(c);
454 client_set_focus(c, !c->nofocus);
457 /** Stack a window below.
458 * \param c The client.
459 * \param previous The previous window on the stack.
460 * \return The next-previous!
462 static xcb_window_t
463 client_stack_above(client_t *c, xcb_window_t previous)
465 uint32_t config_win_vals[2];
467 config_win_vals[0] = previous;
468 config_win_vals[1] = XCB_STACK_MODE_ABOVE;
470 xcb_configure_window(globalconf.connection, c->window,
471 XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
472 config_win_vals);
474 config_win_vals[0] = c->window;
476 if(c->titlebar)
478 xcb_configure_window(globalconf.connection,
479 c->titlebar->window,
480 XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
481 config_win_vals);
482 previous = c->titlebar->window;
484 else
485 previous = c->window;
487 /* stack transient window on top of their parents */
488 foreach(node, globalconf.stack)
489 if((*node)->transient_for == c)
490 previous = client_stack_above(*node, previous);
492 return previous;
495 /** Stacking layout layers */
496 typedef enum
498 /** This one is a special layer */
499 LAYER_IGNORE,
500 LAYER_DESKTOP,
501 LAYER_BELOW,
502 LAYER_NORMAL,
503 LAYER_ABOVE,
504 LAYER_FULLSCREEN,
505 LAYER_ONTOP,
506 /** This one only used for counting and is not a real layer */
507 LAYER_COUNT
508 } layer_t;
510 /** Get the real layer of a client according to its attribute (fullscreen, …)
511 * \param c The client.
512 * \return The real layer.
514 static layer_t
515 client_layer_translator(client_t *c)
517 /* first deal with user set attributes */
518 if(c->ontop)
519 return LAYER_ONTOP;
520 else if(c->fullscreen)
521 return LAYER_FULLSCREEN;
522 else if(c->above)
523 return LAYER_ABOVE;
524 else if(c->below)
525 return LAYER_BELOW;
527 /* check for transient attr */
528 if(c->transient_for)
529 return LAYER_IGNORE;
531 /* then deal with windows type */
532 switch(c->type)
534 case WINDOW_TYPE_DESKTOP:
535 return LAYER_DESKTOP;
536 default:
537 break;
540 return LAYER_NORMAL;
543 /** Restack clients.
544 * \todo It might be worth stopping to restack everyone and only stack `c'
545 * relatively to the first matching in the list.
547 void
548 client_stack_refresh()
550 uint32_t config_win_vals[2];
551 layer_t layer;
553 if (!globalconf.client_need_stack_refresh)
554 return;
555 globalconf.client_need_stack_refresh = false;
557 config_win_vals[0] = XCB_NONE;
558 config_win_vals[1] = XCB_STACK_MODE_ABOVE;
560 /* stack desktop windows */
561 for(layer = LAYER_DESKTOP; layer < LAYER_BELOW; layer++)
562 foreach(node, globalconf.stack)
563 if(client_layer_translator(*node) == layer)
564 config_win_vals[0] = client_stack_above(*node,
565 config_win_vals[0]);
567 /* first stack not ontop wibox window */
568 foreach(_sb, globalconf.wiboxes)
570 wibox_t *sb = *_sb;
571 if(!sb->ontop)
573 xcb_configure_window(globalconf.connection,
574 sb->window,
575 XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
576 config_win_vals);
577 config_win_vals[0] = sb->window;
581 /* then stack clients */
582 for(layer = LAYER_BELOW; layer < LAYER_COUNT; layer++)
583 foreach(node, globalconf.stack)
584 if(client_layer_translator(*node) == layer)
585 config_win_vals[0] = client_stack_above(*node,
586 config_win_vals[0]);
588 /* then stack ontop wibox window */
589 foreach(_sb, globalconf.wiboxes)
591 wibox_t *sb = *_sb;
592 if(sb->ontop)
594 xcb_configure_window(globalconf.connection,
595 sb->window,
596 XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
597 config_win_vals);
598 config_win_vals[0] = sb->window;
603 /** Manage a new client.
604 * \param w The window.
605 * \param wgeom Window geometry.
606 * \param phys_screen Physical screen number.
607 * \param startup True if we are managing at startup time.
609 void
610 client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen, bool startup)
612 const uint32_t select_input_val[] = { CLIENT_SELECT_INPUT_EVENT_MASK };
614 if(systray_iskdedockapp(w))
616 systray_request_handle(w, phys_screen, NULL);
617 return;
620 /* If this is a new client that just has been launched, then request its
621 * startup id. */
622 xcb_get_property_cookie_t startup_id_q = { 0 };
623 if(!startup)
624 startup_id_q = xcb_get_any_property(globalconf.connection,
625 false, w, _NET_STARTUP_ID, UINT_MAX);
627 xcb_change_window_attributes(globalconf.connection, w, XCB_CW_EVENT_MASK, select_input_val);
629 client_t *c = client_new(globalconf.L);
631 /* This cannot change, ever. */
632 c->phys_screen = phys_screen;
633 /* consider the window banned */
634 c->isbanned = true;
635 /* Store window */
636 c->window = w;
637 luaA_object_emit_signal(globalconf.L, -1, "property::window", 0);
639 /* Duplicate client and push it in client list */
640 lua_pushvalue(globalconf.L, -1);
641 client_array_push(&globalconf.clients, luaA_object_ref(globalconf.L, -1));
643 /* Set the right screen */
644 screen_client_moveto(c, screen_getbycoord(&globalconf.screens.tab[phys_screen], wgeom->x, wgeom->y), false);
646 /* Store initial geometry and emits signals so we inform that geometry have
647 * been set. */
648 #define HANDLE_GEOM(attr) \
649 c->geometry.attr = wgeom->attr; \
650 c->geometries.internal.attr = wgeom->attr; \
651 luaA_object_emit_signal(globalconf.L, -1, "property::" #attr, 0);
652 HANDLE_GEOM(x)
653 HANDLE_GEOM(y)
654 HANDLE_GEOM(width)
655 HANDLE_GEOM(height)
656 #undef HANDLE_GEOM
658 luaA_object_emit_signal(globalconf.L, -1, "property::geometry", 0);
660 /* Push client */
661 client_set_border_width(globalconf.L, -1, wgeom->border_width);
663 /* we honor size hints by default */
664 c->size_hints_honor = true;
665 luaA_object_emit_signal(globalconf.L, -1, "property::size_hints_honor", 0);
667 /* update hints */
668 property_update_wm_normal_hints(c, NULL);
669 property_update_wm_hints(c, NULL);
670 property_update_wm_transient_for(c, NULL);
671 property_update_wm_client_leader(c, NULL);
672 property_update_wm_client_machine(c, NULL);
673 property_update_wm_window_role(c, NULL);
674 property_update_net_wm_pid(c, NULL);
675 property_update_net_wm_icon(c, NULL);
677 /* get opacity */
678 client_set_opacity(globalconf.L, -1, window_opacity_get(c->window));
680 /* Then check clients hints */
681 ewmh_client_check_hints(c);
683 /* Push client in stack */
684 client_raise(c);
686 /* update window title */
687 property_update_wm_name(c, NULL);
688 property_update_net_wm_name(c, NULL);
689 property_update_wm_icon_name(c, NULL);
690 property_update_net_wm_icon_name(c, NULL);
691 property_update_wm_class(c, NULL);
692 property_update_wm_protocols(c, NULL);
694 /* update strut */
695 ewmh_process_client_strut(c, NULL);
697 ewmh_update_net_client_list(c->phys_screen);
699 /* Always stay in NORMAL_STATE. Even though iconified seems more
700 * appropriate sometimes. The only possible loss is that clients not using
701 * visibility events may continue to process data (when banned).
702 * Without any exposes or other events the cost should be fairly limited though.
704 * Some clients may expect the window to be unmapped when STATE_ICONIFIED.
705 * Two conflicting parts of the ICCCM v2.0 (section 4.1.4):
707 * "Normal -> Iconic - The client should send a ClientMessage event as described later in this section."
708 * (note no explicit mention of unmapping, while Normal->Widthdrawn does mention that)
710 * "Once a client's window has left the Withdrawn state, the window will be mapped
711 * if it is in the Normal state and the window will be unmapped if it is in the Iconic state."
713 * At this stage it's just safer to keep it in normal state and avoid confusion.
715 window_state_set(c->window, XCB_WM_STATE_NORMAL);
717 if(!startup)
719 /* Request our response */
720 xcb_get_property_reply_t *reply =
721 xcb_get_property_reply(globalconf.connection, startup_id_q, NULL);
722 /* Say spawn that a client has been started, with startup id as argument */
723 char *startup_id = xutil_get_text_property_from_reply(reply);
724 p_delete(&reply);
725 spawn_start_notify(c, startup_id);
726 p_delete(&startup_id);
729 /* Call hook to notify list change */
730 if(globalconf.hooks.clients != LUA_REFNIL)
731 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.clients, 0, 0);
733 luaA_class_emit_signal(globalconf.L, &client_class, "list", 0);
735 /* call hook */
736 if(globalconf.hooks.manage != LUA_REFNIL)
738 luaA_object_push(globalconf.L, c);
739 lua_pushboolean(globalconf.L, startup);
740 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.manage, 2, 0);
743 /* client is still on top of the stack; push startup value,
744 * and emit signals with 2 args */
745 lua_pushboolean(globalconf.L, startup);
746 luaA_class_emit_signal(globalconf.L, &client_class, "manage", 2);
749 /** Compute client geometry with respect to its geometry hints.
750 * \param c The client.
751 * \param geometry The geometry that the client might receive.
752 * \return The geometry the client must take respecting its hints.
754 area_t
755 client_geometry_hints(client_t *c, area_t geometry)
757 int32_t basew, baseh, minw, minh;
759 /* base size is substituted with min size if not specified */
760 if(c->size_hints.flags & XCB_SIZE_HINT_P_SIZE)
762 basew = c->size_hints.base_width;
763 baseh = c->size_hints.base_height;
765 else if(c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)
767 basew = c->size_hints.min_width;
768 baseh = c->size_hints.min_height;
770 else
771 basew = baseh = 0;
773 /* min size is substituted with base size if not specified */
774 if(c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)
776 minw = c->size_hints.min_width;
777 minh = c->size_hints.min_height;
779 else if(c->size_hints.flags & XCB_SIZE_HINT_P_SIZE)
781 minw = c->size_hints.base_width;
782 minh = c->size_hints.base_height;
784 else
785 minw = minh = 0;
787 if(c->size_hints.flags & XCB_SIZE_HINT_P_ASPECT
788 && c->size_hints.min_aspect_num > 0
789 && c->size_hints.min_aspect_den > 0
790 && geometry.height - baseh > 0
791 && geometry.width - basew > 0)
793 double dx = (double) (geometry.width - basew);
794 double dy = (double) (geometry.height - baseh);
795 double min = (double) c->size_hints.min_aspect_num / (double) c->size_hints.min_aspect_den;
796 double max = (double) c->size_hints.max_aspect_num / (double) c->size_hints.min_aspect_den;
797 double ratio = dx / dy;
798 if(max > 0 && min > 0 && ratio > 0)
800 if(ratio < min)
802 dy = (dx * min + dy) / (min * min + 1);
803 dx = dy * min;
804 geometry.width = (int) dx + basew;
805 geometry.height = (int) dy + baseh;
807 else if(ratio > max)
809 dy = (dx * min + dy) / (max * max + 1);
810 dx = dy * min;
811 geometry.width = (int) dx + basew;
812 geometry.height = (int) dy + baseh;
817 if(minw)
818 geometry.width = MAX(geometry.width, minw);
819 if(minh)
820 geometry.height = MAX(geometry.height, minh);
822 if(c->size_hints.flags & XCB_SIZE_HINT_P_MAX_SIZE)
824 if(c->size_hints.max_width)
825 geometry.width = MIN(geometry.width, c->size_hints.max_width);
826 if(c->size_hints.max_height)
827 geometry.height = MIN(geometry.height, c->size_hints.max_height);
830 if(c->size_hints.flags & (XCB_SIZE_HINT_P_RESIZE_INC | XCB_SIZE_HINT_BASE_SIZE)
831 && c->size_hints.width_inc && c->size_hints.height_inc)
833 uint16_t t1 = geometry.width, t2 = geometry.height;
834 unsigned_subtract(t1, basew);
835 unsigned_subtract(t2, baseh);
836 geometry.width -= t1 % c->size_hints.width_inc;
837 geometry.height -= t2 % c->size_hints.height_inc;
840 return geometry;
843 /** Resize client window.
844 * The sizes given as parameters are with titlebar and borders!
845 * \param c Client to resize.
846 * \param geometry New window geometry.
847 * \param hints Use size hints.
848 * \return true if an actual resize occurred.
850 bool
851 client_resize(client_t *c, area_t geometry, bool hints)
853 area_t geometry_internal;
854 area_t area;
856 /* offscreen appearance fixes */
857 area = display_area_get(c->phys_screen);
859 if(geometry.x > area.width)
860 geometry.x = area.width - geometry.width;
861 if(geometry.y > area.height)
862 geometry.y = area.height - geometry.height;
863 if(geometry.x + geometry.width < 0)
864 geometry.x = 0;
865 if(geometry.y + geometry.height < 0)
866 geometry.y = 0;
868 /* Real client geometry, please keep it contained to C code at the very least. */
869 geometry_internal = titlebar_geometry_remove(c->titlebar, c->border_width, geometry);
871 if(hints)
872 geometry_internal = client_geometry_hints(c, geometry_internal);
874 if(geometry_internal.width == 0 || geometry_internal.height == 0)
875 return false;
877 /* Also let client hints propagate to the "official" geometry. */
878 geometry = titlebar_geometry_add(c->titlebar, c->border_width, geometry_internal);
880 if(c->geometries.internal.x != geometry_internal.x
881 || c->geometries.internal.y != geometry_internal.y
882 || c->geometries.internal.width != geometry_internal.width
883 || c->geometries.internal.height != geometry_internal.height)
885 screen_t *new_screen = screen_getbycoord(c->screen,
886 geometry_internal.x, geometry_internal.y);
888 /* Values to configure a window is an array where values are
889 * stored according to 'value_mask' */
890 uint32_t values[4];
892 c->geometries.internal.x = values[0] = geometry_internal.x;
893 c->geometries.internal.y = values[1] = geometry_internal.y;
894 c->geometries.internal.width = values[2] = geometry_internal.width;
895 c->geometries.internal.height = values[3] = geometry_internal.height;
897 /* Also store geometry including border and titlebar. */
898 c->geometry = geometry;
900 titlebar_update_geometry(c);
902 /* Ignore all spurious enter/leave notify events */
903 client_ignore_enterleave_events();
905 xcb_configure_window(globalconf.connection, c->window,
906 XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y
907 | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
908 values);
910 client_restore_enterleave_events();
912 screen_client_moveto(c, new_screen, false);
914 /* execute hook */
915 hook_property(c, "geometry");
917 luaA_object_push(globalconf.L, c);
918 luaA_object_emit_signal(globalconf.L, -1, "property::geometry", 0);
919 /** \todo This need to be VERIFIED before it is emitted! */
920 luaA_object_emit_signal(globalconf.L, -1, "property::x", 0);
921 luaA_object_emit_signal(globalconf.L, -1, "property::y", 0);
922 luaA_object_emit_signal(globalconf.L, -1, "property::width", 0);
923 luaA_object_emit_signal(globalconf.L, -1, "property::height", 0);
924 lua_pop(globalconf.L, 1);
926 return true;
929 return false;
932 /** Set a client minimized, or not.
933 * \param L The Lua VM state.
934 * \param cidx The client index.
935 * \param s Set or not the client minimized.
937 void
938 client_set_minimized(lua_State *L, int cidx, bool s)
940 client_t *c = luaA_client_checkudata(L, cidx);
942 if(c->minimized != s)
944 c->minimized = s;
945 banning_need_update((c)->screen);
946 if(s)
947 window_state_set(c->window, XCB_WM_STATE_ICONIC);
948 else
949 window_state_set(c->window, XCB_WM_STATE_NORMAL);
950 ewmh_client_update_hints(c);
951 if(strut_has_value(&c->strut))
952 screen_emit_signal(globalconf.L, c->screen, "property::workarea", 0);
953 /* execute hook */
954 hook_property(c, "minimized");
955 luaA_object_emit_signal(L, cidx, "property::minimized", 0);
959 /** Set a client sticky, or not.
960 * \param L The Lua VM state.
961 * \param cidx The client index.
962 * \param s Set or not the client sticky.
964 void
965 client_set_sticky(lua_State *L, int cidx, bool s)
967 client_t *c = luaA_client_checkudata(L, cidx);
969 if(c->sticky != s)
971 c->sticky = s;
972 banning_need_update((c)->screen);
973 ewmh_client_update_hints(c);
974 hook_property(c, "sticky");
975 luaA_object_emit_signal(L, cidx, "property::sticky", 0);
979 /** Set a client fullscreen, or not.
980 * \param L The Lua VM state.
981 * \param cidx The client index.
982 * \param s Set or not the client fullscreen.
984 void
985 client_set_fullscreen(lua_State *L, int cidx, bool s)
987 client_t *c = luaA_client_checkudata(L, cidx);
989 if(c->fullscreen != s)
991 area_t geometry;
993 /* become fullscreen! */
994 if(s)
996 /* Make sure the current geometry is stored without titlebar. */
997 titlebar_ban(c->titlebar);
998 /* remove any max state */
999 client_set_maximized_horizontal(L, cidx, false);
1000 client_set_maximized_vertical(L, cidx, false);
1001 /* You can only be part of one of the special layers. */
1002 client_set_below(L, cidx, false);
1003 client_set_above(L, cidx, false);
1004 client_set_ontop(L, cidx, false);
1006 geometry = screen_area_get(c->screen, false);
1007 c->geometries.fullscreen = c->geometry;
1008 c->border_width_fs = c->border_width;
1009 client_set_border_width(L, cidx, 0);
1010 c->fullscreen = true;
1012 else
1014 geometry = c->geometries.fullscreen;
1015 c->fullscreen = false;
1016 client_set_border_width(L, cidx, c->border_width_fs);
1018 client_resize(c, geometry, false);
1019 client_stack();
1020 ewmh_client_update_hints(c);
1021 hook_property(c, "fullscreen");
1022 luaA_object_emit_signal(L, cidx, "property::fullscreen", 0);
1026 /** Set a client horizontally maximized.
1027 * \param L The Lua VM state.
1028 * \param cidx The client index.
1029 * \param s The maximized status.
1031 void
1032 client_set_maximized_horizontal(lua_State *L, int cidx, bool s)
1034 client_t *c = luaA_client_checkudata(L, cidx);
1036 if(c->maximized_horizontal != s)
1038 area_t geometry;
1040 if((c->maximized_horizontal = s))
1042 /* remove fullscreen mode */
1043 client_set_fullscreen(L, cidx, false);
1045 geometry = screen_area_get(c->screen, true);
1046 geometry.y = c->geometry.y;
1047 geometry.height = c->geometry.height;
1048 c->geometries.max.x = c->geometry.x;
1049 c->geometries.max.width = c->geometry.width;
1051 else
1053 geometry = c->geometry;
1054 geometry.x = c->geometries.max.x;
1055 geometry.width = c->geometries.max.width;
1058 client_resize(c, geometry, c->size_hints_honor);
1059 client_stack();
1060 ewmh_client_update_hints(c);
1061 hook_property(c, "maximized_horizontal");
1062 luaA_object_emit_signal(L, cidx, "property::maximized_horizontal", 0);
1066 /** Set a client vertically maximized.
1067 * \param L The Lua VM state.
1068 * \param cidx The client index.
1069 * \param s The maximized status.
1071 void
1072 client_set_maximized_vertical(lua_State *L, int cidx, bool s)
1074 client_t *c = luaA_client_checkudata(L, cidx);
1076 if(c->maximized_vertical != s)
1078 area_t geometry;
1080 if((c->maximized_vertical = s))
1082 /* remove fullscreen mode */
1083 client_set_fullscreen(L, cidx, false);
1085 geometry = screen_area_get(c->screen, true);
1086 geometry.x = c->geometry.x;
1087 geometry.width = c->geometry.width;
1088 c->geometries.max.y = c->geometry.y;
1089 c->geometries.max.height = c->geometry.height;
1091 else
1093 geometry = c->geometry;
1094 geometry.y = c->geometries.max.y;
1095 geometry.height = c->geometries.max.height;
1098 client_resize(c, geometry, c->size_hints_honor);
1099 client_stack();
1100 ewmh_client_update_hints(c);
1101 hook_property(c, "maximized_vertical");
1102 luaA_object_emit_signal(L, cidx, "property::maximized_vertical", 0);
1106 /** Set a client above, or not.
1107 * \param L The Lua VM state.
1108 * \param cidx The client index.
1109 * \param s Set or not the client above.
1111 void
1112 client_set_above(lua_State *L, int cidx, bool s)
1114 client_t *c = luaA_client_checkudata(L, cidx);
1116 if(c->above != s)
1118 /* You can only be part of one of the special layers. */
1119 if(s)
1121 client_set_below(L, cidx, false);
1122 client_set_ontop(L, cidx, false);
1123 client_set_fullscreen(L, cidx, false);
1125 c->above = s;
1126 client_stack();
1127 ewmh_client_update_hints(c);
1128 /* execute hook */
1129 hook_property(c, "above");
1130 luaA_object_emit_signal(L, cidx, "property::above", 0);
1134 /** Set a client below, or not.
1135 * \param L The Lua VM state.
1136 * \param cidx The client index.
1137 * \param s Set or not the client below.
1139 void
1140 client_set_below(lua_State *L, int cidx, bool s)
1142 client_t *c = luaA_client_checkudata(L, cidx);
1144 if(c->below != s)
1146 /* You can only be part of one of the special layers. */
1147 if(s)
1149 client_set_above(L, cidx, false);
1150 client_set_ontop(L, cidx, false);
1151 client_set_fullscreen(L, cidx, false);
1153 c->below = s;
1154 client_stack();
1155 ewmh_client_update_hints(c);
1156 /* execute hook */
1157 hook_property(c, "below");
1158 luaA_object_emit_signal(L, cidx, "property::below", 0);
1162 /** Set a client modal, or not.
1163 * \param L The Lua VM state.
1164 * \param cidx The client index.
1165 * \param s Set or not the client modal attribute.
1167 void
1168 client_set_modal(lua_State *L, int cidx, bool s)
1170 client_t *c = luaA_client_checkudata(L, cidx);
1172 if(c->modal != s)
1174 c->modal = s;
1175 client_stack();
1176 ewmh_client_update_hints(c);
1177 /* execute hook */
1178 hook_property(c, "modal");
1179 luaA_object_emit_signal(L, cidx, "property::modal", 0);
1183 /** Set a client ontop, or not.
1184 * \param L The Lua VM state.
1185 * \param cidx The client index.
1186 * \param s Set or not the client ontop attribute.
1188 void
1189 client_set_ontop(lua_State *L, int cidx, bool s)
1191 client_t *c = luaA_client_checkudata(L, cidx);
1193 if(c->ontop != s)
1195 /* You can only be part of one of the special layers. */
1196 if(s)
1198 client_set_above(L, cidx, false);
1199 client_set_below(L, cidx, false);
1200 client_set_fullscreen(L, cidx, false);
1202 c->ontop = s;
1203 client_stack();
1204 /* execute hook */
1205 hook_property(c, "ontop");
1206 luaA_object_emit_signal(L, cidx, "property::ontop", 0);
1210 /** Set a client skip taskbar attribute.
1211 * \param L Tha Lua VM state.
1212 * \param cidx The client index.
1213 * \param s Set or not the client skip taskbar attribute.
1215 void
1216 client_set_skip_taskbar(lua_State *L, int cidx, bool s)
1218 client_t *c = luaA_client_checkudata(L, cidx);
1220 if(c->skip_taskbar != s)
1222 c->skip_taskbar = s;
1223 ewmh_client_update_hints(c);
1224 luaA_object_emit_signal(L, cidx, "property::skip_taskbar", 0);
1228 /** Unban a client and move it back into the viewport.
1229 * \param c The client.
1231 void
1232 client_unban(client_t *c)
1234 if(c->isbanned)
1236 xcb_map_window(globalconf.connection, c->window);
1238 c->isbanned = false;
1242 /** Unmanage a client.
1243 * \param c The client.
1245 void
1246 client_unmanage(client_t *c)
1248 tag_array_t *tags = &c->screen->tags;
1250 /* Reset transient_for attributes of widows that maybe referring to us */
1251 foreach(_tc, globalconf.clients)
1253 client_t *tc = *_tc;
1254 if(tc->transient_for == c)
1255 tc->transient_for = NULL;
1258 if(globalconf.screens.tab[c->phys_screen].prev_client_focus == c)
1259 globalconf.screens.tab[c->phys_screen].prev_client_focus = NULL;
1261 if(globalconf.screens.tab[c->phys_screen].client_focus == c)
1262 client_unfocus(c);
1264 /* remove client from global list and everywhere else */
1265 foreach(elem, globalconf.clients)
1266 if(*elem == c)
1268 client_array_remove(&globalconf.clients, elem);
1269 break;
1271 stack_client_remove(c);
1272 for(int i = 0; i < tags->len; i++)
1273 untag_client(c, tags->tab[i]);
1275 /* call hook */
1276 if(globalconf.hooks.unmanage != LUA_REFNIL)
1278 luaA_object_push(globalconf.L, c);
1279 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.unmanage, 1, 0);
1282 luaA_object_push(globalconf.L, c);
1283 luaA_class_emit_signal(globalconf.L, &client_class, "unmanage", 1);
1285 /* Call hook to notify list change */
1286 if(globalconf.hooks.clients != LUA_REFNIL)
1287 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.clients, 0, 0);
1289 luaA_class_emit_signal(globalconf.L, &client_class, "list", 0);
1291 if(strut_has_value(&c->strut))
1292 screen_emit_signal(globalconf.L, c->screen, "property::workarea", 0);
1294 window_state_set(c->window, XCB_WM_STATE_WITHDRAWN);
1296 titlebar_client_detach(c);
1298 ewmh_update_net_client_list(c->phys_screen);
1300 /* set client as invalid */
1301 c->invalid = true;
1303 luaA_object_unref(globalconf.L, c);
1306 /** Kill a client via a WM_DELETE_WINDOW request or KillClient if not
1307 * supported.
1308 * \param c The client to kill.
1310 void
1311 client_kill(client_t *c)
1313 if(client_hasproto(c, WM_DELETE_WINDOW))
1315 xcb_client_message_event_t ev;
1317 /* Initialize all of event's fields first */
1318 p_clear(&ev, 1);
1320 ev.response_type = XCB_CLIENT_MESSAGE;
1321 ev.window = c->window;
1322 ev.format = 32;
1323 ev.data.data32[1] = XCB_CURRENT_TIME;
1324 ev.type = WM_PROTOCOLS;
1325 ev.data.data32[0] = WM_DELETE_WINDOW;
1327 xcb_send_event(globalconf.connection, false, c->window,
1328 XCB_EVENT_MASK_NO_EVENT, (char *) &ev);
1330 else
1331 xcb_kill_client(globalconf.connection, c->window);
1334 /** Get all clients into a table.
1335 * \param L The Lua VM state.
1336 * \return The number of elements pushed on stack.
1337 * \luastack
1338 * \lparam An optional screen number.
1339 * \lreturn A table with all clients.
1341 static int
1342 luaA_client_get(lua_State *L)
1344 int i = 1, screen;
1346 screen = luaL_optnumber(L, 1, 0) - 1;
1348 lua_newtable(L);
1350 if(screen == -1)
1351 foreach(c, globalconf.clients)
1353 luaA_object_push(L, *c);
1354 lua_rawseti(L, -2, i++);
1356 else
1358 luaA_checkscreen(screen);
1359 foreach(c, globalconf.clients)
1360 if((*c)->screen == &globalconf.screens.tab[screen])
1362 luaA_object_push(L, *c);
1363 lua_rawseti(L, -2, i++);
1367 return 1;
1370 /** Check if a client is visible on its screen.
1371 * \param L The Lua VM state.
1372 * \return The number of elements pushed on stack.
1373 * \luastack
1374 * \lvalue A client.
1375 * \lreturn A boolean value, true if the client is visible, false otherwise.
1377 static int
1378 luaA_client_isvisible(lua_State *L)
1380 client_t *c = luaA_client_checkudata(L, 1);
1381 lua_pushboolean(L, client_isvisible(c, c->screen));
1382 return 1;
1385 /** Set client border width.
1386 * \param L The Lua VM state.
1387 * \param cidx The client index.
1388 * \param width The border width.
1390 void
1391 client_set_border_width(lua_State *L, int cidx, int width)
1393 client_t *c = luaA_client_checkudata(L, cidx);
1394 uint32_t w = width;
1396 if(width > 0 && (c->type == WINDOW_TYPE_DOCK
1397 || c->type == WINDOW_TYPE_SPLASH
1398 || c->type == WINDOW_TYPE_DESKTOP
1399 || c->fullscreen))
1400 return;
1402 if(width == c->border_width || width < 0)
1403 return;
1405 /* disallow change of border width if the client is fullscreen */
1406 if(c->fullscreen)
1407 return;
1409 /* Update geometry with the new border. */
1410 c->geometry.width -= 2 * c->border_width;
1411 c->geometry.height -= 2 * c->border_width;
1413 c->border_width = width;
1414 xcb_configure_window(globalconf.connection, c->window,
1415 XCB_CONFIG_WINDOW_BORDER_WIDTH, &w);
1417 c->geometry.width += 2 * c->border_width;
1418 c->geometry.height += 2 * c->border_width;
1420 /* Changing border size also affects the size of the titlebar. */
1421 titlebar_update_geometry(c);
1423 hook_property(c, "border_width");
1424 luaA_object_emit_signal(L, cidx, "property::border_width", 0);
1427 /** Set a client icon.
1428 * \param L The Lua VM state.
1429 * \param cidx The client index on the stack.
1430 * \param iidx The image index on the stack.
1432 void
1433 client_set_icon(lua_State *L, int cidx, int iidx)
1435 client_t *c = luaA_client_checkudata(L, cidx);
1436 /* convert index to absolute */
1437 cidx = luaA_absindex(L, cidx);
1438 iidx = luaA_absindex(L, iidx);
1439 luaA_checkudata(L, iidx, &image_class);
1440 luaA_object_unref_item(L, cidx, c->icon);
1441 c->icon = luaA_object_ref_item(L, cidx, iidx);
1442 luaA_object_emit_signal(L, cidx < iidx ? cidx : cidx - 1, "property::icon", 0);
1443 /* execute hook */
1444 hook_property(c, "icon");
1447 /** Kill a client.
1448 * \param L The Lua VM state.
1450 * \luastack
1451 * \lvalue A client.
1453 static int
1454 luaA_client_kill(lua_State *L)
1456 client_t *c = luaA_client_checkudata(L, 1);
1457 client_kill(c);
1458 return 0;
1461 /** Swap a client with another one.
1462 * \param L The Lua VM state.
1463 * \luastack
1464 * \lvalue A client.
1465 * \lparam A client to swap with.
1467 static int
1468 luaA_client_swap(lua_State *L)
1470 client_t *c = luaA_client_checkudata(L, 1);
1471 client_t *swap = luaA_client_checkudata(L, 2);
1473 if(c != swap)
1475 client_t **ref_c = NULL, **ref_swap = NULL;
1476 foreach(item, globalconf.clients)
1478 if(*item == c)
1479 ref_c = item;
1480 else if(*item == swap)
1481 ref_swap = item;
1482 if(ref_c && ref_swap)
1483 break;
1485 /* swap ! */
1486 *ref_c = swap;
1487 *ref_swap = c;
1489 /* Call hook to notify list change */
1490 if(globalconf.hooks.clients != LUA_REFNIL)
1491 luaA_dofunction_from_registry(L, globalconf.hooks.clients, 0, 0);
1493 luaA_class_emit_signal(globalconf.L, &client_class, "list", 0);
1496 return 0;
1499 /** Access or set the client tags.
1500 * \param L The Lua VM state.
1501 * \return The number of elements pushed on stack.
1502 * \lparam A table with tags to set, or none to get the current tags table.
1503 * \return The clients tag.
1505 static int
1506 luaA_client_tags(lua_State *L)
1508 client_t *c = luaA_client_checkudata(L, 1);
1509 tag_array_t *tags = &c->screen->tags;
1510 int j = 0;
1512 if(lua_gettop(L) == 2)
1514 luaA_checktable(L, 2);
1515 for(int i = 0; i < tags->len; i++)
1516 untag_client(c, tags->tab[i]);
1517 lua_pushnil(L);
1518 while(lua_next(L, 2))
1519 tag_client(c);
1520 lua_pop(L, 1);
1523 lua_newtable(L);
1524 foreach(tag, *tags)
1525 if(is_client_tagged(c, *tag))
1527 luaA_object_push(L, *tag);
1528 lua_rawseti(L, -2, ++j);
1531 return 1;
1534 /** Raise a client on top of others which are on the same layer.
1535 * \param L The Lua VM state.
1536 * \luastack
1537 * \lvalue A client.
1539 static int
1540 luaA_client_raise(lua_State *L)
1542 client_t *c = luaA_client_checkudata(L, 1);
1543 client_raise(c);
1544 return 0;
1547 /** Lower a client on bottom of others which are on the same layer.
1548 * \param L The Lua VM state.
1549 * \luastack
1550 * \lvalue A client.
1552 static int
1553 luaA_client_lower(lua_State *L)
1555 client_t *c = luaA_client_checkudata(L, 1);
1557 stack_client_push(c);
1559 /* Traverse all transient layers. */
1560 for(client_t *tc = c->transient_for; tc; tc = tc->transient_for)
1561 stack_client_push(tc);
1563 client_stack();
1565 return 0;
1568 /** Redraw a client by unmapping and mapping it quickly.
1569 * \param L The Lua VM state.
1571 * \luastack
1572 * \lvalue A client.
1574 static int
1575 luaA_client_redraw(lua_State *L)
1577 client_t *c = luaA_client_checkudata(L, 1);
1579 xcb_unmap_window(globalconf.connection, c->window);
1580 xcb_map_window(globalconf.connection, c->window);
1582 /* Set the focus on the current window if the redraw has been
1583 performed on the window where the pointer is currently on
1584 because after the unmapping/mapping, the focus is lost */
1585 if(globalconf.screen_focus->client_focus == c)
1587 client_unfocus(c);
1588 client_focus(c);
1591 return 0;
1594 /** Stop managing a client.
1595 * \param L The Lua VM state.
1596 * \return The number of elements pushed on stack.
1597 * \luastack
1598 * \lvalue A client.
1600 static int
1601 luaA_client_unmanage(lua_State *L)
1603 client_t *c = luaA_client_checkudata(L, 1);
1604 client_unmanage(c);
1605 return 0;
1608 /** Return client geometry.
1609 * \param L The Lua VM state.
1610 * \return The number of elements pushed on stack.
1611 * \luastack
1612 * \lparam A table with new coordinates, or none.
1613 * \lreturn A table with client coordinates.
1615 static int
1616 luaA_client_geometry(lua_State *L)
1618 client_t *c = luaA_client_checkudata(L, 1);
1620 if(lua_gettop(L) == 2 && !lua_isnil(L, 2))
1622 area_t geometry;
1624 luaA_checktable(L, 2);
1625 geometry.x = luaA_getopt_number(L, 2, "x", c->geometry.x);
1626 geometry.y = luaA_getopt_number(L, 2, "y", c->geometry.y);
1627 if(client_isfixed(c))
1629 geometry.width = c->geometry.width;
1630 geometry.height = c->geometry.height;
1632 else
1634 geometry.width = luaA_getopt_number(L, 2, "width", c->geometry.width);
1635 geometry.height = luaA_getopt_number(L, 2, "height", c->geometry.height);
1638 client_resize(c, geometry, c->size_hints_honor);
1641 return luaA_pusharea(L, c->geometry);
1644 /** Return client struts (reserved space at the edge of the screen).
1645 * \param L The Lua VM state.
1646 * \return The number of elements pushed on stack.
1647 * \luastack
1648 * \lparam A table with new strut values, or none.
1649 * \lreturn A table with strut values.
1651 static int
1652 luaA_client_struts(lua_State *L)
1654 client_t *c = luaA_client_checkudata(L, 1);
1656 if(lua_gettop(L) == 2)
1658 luaA_tostrut(L, 2, &c->strut);
1659 ewmh_update_strut(c->window, &c->strut);
1660 hook_property(c, "struts");
1661 luaA_object_emit_signal(L, 1, "property::struts", 0);
1662 screen_emit_signal(L, c->screen, "property::workarea", 0);
1665 return luaA_pushstrut(L, c->strut);
1668 static int
1669 luaA_client_set_screen(lua_State *L, client_t *c)
1671 if(globalconf.xinerama_is_active)
1673 int screen = luaL_checknumber(L, -1) - 1;
1674 luaA_checkscreen(screen);
1675 screen_client_moveto(c, &globalconf.screens.tab[screen], true);
1677 return 0;
1680 static int
1681 luaA_client_set_hidden(lua_State *L, client_t *c)
1683 bool b = luaA_checkboolean(L, -1);
1684 if(b != c->hidden)
1686 c->hidden = b;
1687 banning_need_update((c)->screen);
1688 hook_property(c, "hidden");
1689 if(strut_has_value(&c->strut))
1690 screen_emit_signal(globalconf.L, c->screen, "property::workarea", 0);
1691 luaA_object_emit_signal(L, -3, "property::hidden", 0);
1693 return 0;
1696 static int
1697 luaA_client_set_minimized(lua_State *L, client_t *c)
1699 client_set_minimized(L, -3, luaA_checkboolean(L, -1));
1700 return 0;
1703 static int
1704 luaA_client_set_fullscreen(lua_State *L, client_t *c)
1706 client_set_fullscreen(L, -3, luaA_checkboolean(L, -1));
1707 return 0;
1710 static int
1711 luaA_client_set_modal(lua_State *L, client_t *c)
1713 client_set_modal(L, -3, luaA_checkboolean(L, -1));
1714 return 0;
1717 static int
1718 luaA_client_set_maximized_horizontal(lua_State *L, client_t *c)
1720 client_set_maximized_horizontal(L, -3, luaA_checkboolean(L, -1));
1721 return 0;
1724 static int
1725 luaA_client_set_maximized_vertical(lua_State *L, client_t *c)
1727 client_set_maximized_vertical(L, -3, luaA_checkboolean(L, -1));
1728 return 0;
1731 static int
1732 luaA_client_set_icon(lua_State *L, client_t *c)
1734 client_set_icon(L, -3, -1);
1735 return 0;
1738 static int
1739 luaA_client_set_opacity(lua_State *L, client_t *c)
1741 if(lua_isnil(L, -1))
1742 client_set_opacity(L, -3, -1);
1743 else
1744 client_set_opacity(L, -3, luaL_checknumber(L, -1));
1745 return 0;
1748 static int
1749 luaA_client_set_sticky(lua_State *L, client_t *c)
1751 client_set_sticky(L, -3, luaA_checkboolean(L, -1));
1752 return 0;
1755 static int
1756 luaA_client_set_size_hints_honor(lua_State *L, client_t *c)
1758 c->size_hints_honor = luaA_checkboolean(L, -1);
1759 hook_property(c, "size_hints_honor");
1760 luaA_object_emit_signal(L, -3, "property::size_hints_honor", 0);
1761 return 0;
1764 static int
1765 luaA_client_set_border_width(lua_State *L, client_t *c)
1767 client_set_border_width(L, -3, luaL_checknumber(L, -1));
1768 return 0;
1771 static int
1772 luaA_client_set_ontop(lua_State *L, client_t *c)
1774 client_set_ontop(L, -3, luaA_checkboolean(L, -1));
1775 return 0;
1778 static int
1779 luaA_client_set_below(lua_State *L, client_t *c)
1781 client_set_below(L, -3, luaA_checkboolean(L, -1));
1782 return 0;
1785 static int
1786 luaA_client_set_above(lua_State *L, client_t *c)
1788 client_set_above(L, -3, luaA_checkboolean(L, -1));
1789 return 0;
1792 static int
1793 luaA_client_set_urgent(lua_State *L, client_t *c)
1795 client_set_urgent(L, -3, luaA_checkboolean(L, -1));
1796 return 0;
1799 static int
1800 luaA_client_set_border_color(lua_State *L, client_t *c)
1802 size_t len;
1803 const char *buf;
1804 if((buf = luaL_checklstring(L, -1, &len))
1805 && xcolor_init_reply(xcolor_init_unchecked(&c->border_color, buf, len)))
1807 xcb_change_window_attributes(globalconf.connection, c->window,
1808 XCB_CW_BORDER_PIXEL, &c->border_color.pixel);
1809 luaA_object_emit_signal(L, -3, "property::border_color", 0);
1811 return 0;
1814 static int
1815 luaA_client_set_titlebar(lua_State *L, client_t *c)
1817 if(lua_isnil(L, -1))
1818 titlebar_client_detach(c);
1819 else
1820 titlebar_client_attach(c);
1821 return 0;
1824 static int
1825 luaA_client_set_skip_taskbar(lua_State *L, client_t *c)
1827 client_set_skip_taskbar(L, -3, luaA_checkboolean(L, -1));
1828 return 0;
1831 static int
1832 luaA_client_get_name(lua_State *L, client_t *c)
1834 lua_pushstring(L, c->name ? c->name : c->alt_name);
1835 return 1;
1838 static int
1839 luaA_client_get_icon_name(lua_State *L, client_t *c)
1841 lua_pushstring(L, c->icon_name ? c->icon_name : c->alt_icon_name);
1842 return 1;
1845 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, class, lua_pushstring)
1846 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, instance, lua_pushstring)
1847 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, machine, lua_pushstring)
1848 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, role, lua_pushstring)
1849 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, transient_for, luaA_object_push)
1850 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, skip_taskbar, lua_pushboolean)
1851 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, window, lua_pushnumber)
1852 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, leader_window, lua_pushnumber)
1853 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, group_window, lua_pushnumber)
1854 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, pid, lua_pushnumber)
1855 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, hidden, lua_pushboolean)
1856 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, minimized, lua_pushboolean)
1857 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, fullscreen, lua_pushboolean)
1858 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, modal, lua_pushboolean)
1859 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, ontop, lua_pushboolean)
1860 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, urgent, lua_pushboolean)
1861 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, above, lua_pushboolean)
1862 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, below, lua_pushboolean)
1863 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, sticky, lua_pushboolean)
1864 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, size_hints_honor, lua_pushboolean)
1865 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, maximized_horizontal, lua_pushboolean)
1866 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, maximized_vertical, lua_pushboolean)
1867 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, opacity, lua_pushnumber)
1868 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, border_width, lua_pushnumber)
1869 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, border_color, luaA_pushxcolor)
1871 static int
1872 luaA_client_get_content(lua_State *L, client_t *c)
1874 xcb_image_t *ximage = xcb_image_get(globalconf.connection,
1875 c->window,
1876 0, 0,
1877 c->geometries.internal.width,
1878 c->geometries.internal.height,
1879 ~0, XCB_IMAGE_FORMAT_Z_PIXMAP);
1880 int retval = 0;
1882 if(ximage)
1884 if(ximage->bpp >= 24)
1886 uint32_t *data = p_alloca(uint32_t, ximage->width * ximage->height);
1888 for(int y = 0; y < ximage->height; y++)
1889 for(int x = 0; x < ximage->width; x++)
1891 data[y * ximage->width + x] = xcb_image_get_pixel(ximage, x, y);
1892 data[y * ximage->width + x] |= 0xff000000; /* set alpha to 0xff */
1895 retval = image_new_from_argb32(ximage->width, ximage->height, data);
1897 xcb_image_destroy(ximage);
1900 return retval;
1903 static int
1904 luaA_client_get_type(lua_State *L, client_t *c)
1906 switch(c->type)
1908 case WINDOW_TYPE_DESKTOP:
1909 lua_pushliteral(L, "desktop");
1910 break;
1911 case WINDOW_TYPE_DOCK:
1912 lua_pushliteral(L, "dock");
1913 break;
1914 case WINDOW_TYPE_SPLASH:
1915 lua_pushliteral(L, "splash");
1916 break;
1917 case WINDOW_TYPE_DIALOG:
1918 lua_pushliteral(L, "dialog");
1919 break;
1920 case WINDOW_TYPE_MENU:
1921 lua_pushliteral(L, "menu");
1922 break;
1923 case WINDOW_TYPE_TOOLBAR:
1924 lua_pushliteral(L, "toolbar");
1925 break;
1926 case WINDOW_TYPE_UTILITY:
1927 lua_pushliteral(L, "utility");
1928 break;
1929 case WINDOW_TYPE_DROPDOWN_MENU:
1930 lua_pushliteral(L, "dropdown_menu");
1931 break;
1932 case WINDOW_TYPE_POPUP_MENU:
1933 lua_pushliteral(L, "popup_menu");
1934 break;
1935 case WINDOW_TYPE_TOOLTIP:
1936 lua_pushliteral(L, "tooltip");
1937 break;
1938 case WINDOW_TYPE_NOTIFICATION:
1939 lua_pushliteral(L, "notification");
1940 break;
1941 case WINDOW_TYPE_COMBO:
1942 lua_pushliteral(L, "combo");
1943 break;
1944 case WINDOW_TYPE_DND:
1945 lua_pushliteral(L, "dnd");
1946 break;
1947 case WINDOW_TYPE_NORMAL:
1948 lua_pushliteral(L, "normal");
1949 break;
1951 return 1;
1954 static int
1955 luaA_client_get_screen(lua_State *L, client_t *c)
1957 if(!c->screen)
1958 return 0;
1959 lua_pushnumber(L, 1 + screen_array_indexof(&globalconf.screens, c->screen));
1960 return 1;
1963 static int
1964 luaA_client_get_icon(lua_State *L, client_t *c)
1966 return luaA_object_push_item(L, -2, c->icon);
1969 static int
1970 luaA_client_get_titlebar(lua_State *L, client_t *c)
1972 return luaA_object_push(L, c->titlebar);
1975 static int
1976 luaA_client_get_size_hints(lua_State *L, client_t *c)
1978 const char *u_or_p = NULL;
1980 lua_createtable(L, 0, 1);
1982 if(c->size_hints.flags & XCB_SIZE_HINT_US_POSITION)
1983 u_or_p = "user_position";
1984 else if(c->size_hints.flags & XCB_SIZE_HINT_P_POSITION)
1985 u_or_p = "program_position";
1987 if(u_or_p)
1989 lua_createtable(L, 0, 2);
1990 lua_pushnumber(L, c->size_hints.x);
1991 lua_setfield(L, -2, "x");
1992 lua_pushnumber(L, c->size_hints.y);
1993 lua_setfield(L, -2, "y");
1994 lua_setfield(L, -2, u_or_p);
1995 u_or_p = NULL;
1998 if(c->size_hints.flags & XCB_SIZE_HINT_US_SIZE)
1999 u_or_p = "user_size";
2000 else if(c->size_hints.flags & XCB_SIZE_HINT_P_SIZE)
2001 u_or_p = "program_size";
2003 if(u_or_p)
2005 lua_createtable(L, 0, 2);
2006 lua_pushnumber(L, c->size_hints.width);
2007 lua_setfield(L, -2, "width");
2008 lua_pushnumber(L, c->size_hints.height);
2009 lua_setfield(L, -2, "height");
2010 lua_setfield(L, -2, u_or_p);
2013 if(c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)
2015 lua_pushnumber(L, c->size_hints.min_width);
2016 lua_setfield(L, -2, "min_width");
2017 lua_pushnumber(L, c->size_hints.min_height);
2018 lua_setfield(L, -2, "min_height");
2021 if(c->size_hints.flags & XCB_SIZE_HINT_P_MAX_SIZE)
2023 lua_pushnumber(L, c->size_hints.max_width);
2024 lua_setfield(L, -2, "max_width");
2025 lua_pushnumber(L, c->size_hints.max_height);
2026 lua_setfield(L, -2, "max_height");
2029 if(c->size_hints.flags & XCB_SIZE_HINT_P_RESIZE_INC)
2031 lua_pushnumber(L, c->size_hints.width_inc);
2032 lua_setfield(L, -2, "width_inc");
2033 lua_pushnumber(L, c->size_hints.height_inc);
2034 lua_setfield(L, -2, "height_inc");
2037 if(c->size_hints.flags & XCB_SIZE_HINT_P_ASPECT)
2039 lua_pushnumber(L, c->size_hints.min_aspect_num);
2040 lua_setfield(L, -2, "min_aspect_num");
2041 lua_pushnumber(L, c->size_hints.min_aspect_den);
2042 lua_setfield(L, -2, "min_aspect_den");
2043 lua_pushnumber(L, c->size_hints.max_aspect_num);
2044 lua_setfield(L, -2, "max_aspect_num");
2045 lua_pushnumber(L, c->size_hints.max_aspect_den);
2046 lua_setfield(L, -2, "max_aspect_den");
2049 if(c->size_hints.flags & XCB_SIZE_HINT_BASE_SIZE)
2051 lua_pushnumber(L, c->size_hints.base_width);
2052 lua_setfield(L, -2, "base_width");
2053 lua_pushnumber(L, c->size_hints.base_height);
2054 lua_setfield(L, -2, "base_height");
2057 if(c->size_hints.flags & XCB_SIZE_HINT_P_WIN_GRAVITY)
2059 switch(c->size_hints.win_gravity)
2061 default:
2062 lua_pushliteral(L, "north_west");
2063 break;
2064 case XCB_GRAVITY_NORTH:
2065 lua_pushliteral(L, "north");
2066 break;
2067 case XCB_GRAVITY_NORTH_EAST:
2068 lua_pushliteral(L, "north_east");
2069 break;
2070 case XCB_GRAVITY_WEST:
2071 lua_pushliteral(L, "west");
2072 break;
2073 case XCB_GRAVITY_CENTER:
2074 lua_pushliteral(L, "center");
2075 break;
2076 case XCB_GRAVITY_EAST:
2077 lua_pushliteral(L, "east");
2078 break;
2079 case XCB_GRAVITY_SOUTH_WEST:
2080 lua_pushliteral(L, "south_west");
2081 break;
2082 case XCB_GRAVITY_SOUTH:
2083 lua_pushliteral(L, "south");
2084 break;
2085 case XCB_GRAVITY_SOUTH_EAST:
2086 lua_pushliteral(L, "south_east");
2087 break;
2088 case XCB_GRAVITY_STATIC:
2089 lua_pushliteral(L, "static");
2090 break;
2092 lua_setfield(L, -2, "win_gravity");
2095 return 1;
2098 /** Get or set mouse buttons bindings for a client.
2099 * \param L The Lua VM state.
2100 * \return The number of element pushed on stack.
2101 * \luastack
2102 * \lvalue A client.
2103 * \lparam An array of mouse button bindings objects, or nothing.
2104 * \return The array of mouse button bindings objects of this client.
2106 static int
2107 luaA_client_buttons(lua_State *L)
2109 client_t *client = luaA_client_checkudata(L, 1);
2110 button_array_t *buttons = &client->buttons;
2112 if(lua_gettop(L) == 2)
2114 luaA_button_array_set(L, 1, 2, buttons);
2115 luaA_object_emit_signal(L, 1, "property::buttons", 0);
2116 window_buttons_grab(client->window, &client->buttons);
2119 return luaA_button_array_get(L, 1, buttons);
2122 /** Get or set keys bindings for a client.
2123 * \param L The Lua VM state.
2124 * \return The number of element pushed on stack.
2125 * \luastack
2126 * \lvalue A client.
2127 * \lparam An array of key bindings objects, or nothing.
2128 * \return The array of key bindings objects of this client.
2130 static int
2131 luaA_client_keys(lua_State *L)
2133 client_t *c = luaA_client_checkudata(L, 1);
2134 key_array_t *keys = &c->keys;
2136 if(lua_gettop(L) == 2)
2138 luaA_key_array_set(L, 1, 2, keys);
2139 luaA_object_emit_signal(L, 1, "property::keys", 0);
2140 xcb_ungrab_key(globalconf.connection, XCB_GRAB_ANY, c->window, XCB_BUTTON_MASK_ANY);
2141 window_grabkeys(c->window, keys);
2144 return luaA_key_array_get(L, 1, keys);
2147 /* Client module.
2148 * \param L The Lua VM state.
2149 * \return The number of pushed elements.
2151 static int
2152 luaA_client_module_index(lua_State *L)
2154 size_t len;
2155 const char *buf = luaL_checklstring(L, 2, &len);
2157 switch(a_tokenize(buf, len))
2159 case A_TK_FOCUS:
2160 return luaA_object_push(globalconf.L, globalconf.screen_focus->client_focus);
2161 break;
2162 default:
2163 return 0;
2167 /* Client module new index.
2168 * \param L The Lua VM state.
2169 * \return The number of pushed elements.
2171 static int
2172 luaA_client_module_newindex(lua_State *L)
2174 size_t len;
2175 const char *buf = luaL_checklstring(L, 2, &len);
2176 client_t *c;
2178 switch(a_tokenize(buf, len))
2180 case A_TK_FOCUS:
2181 c = luaA_client_checkudata(L, 3);
2182 client_focus(c);
2183 break;
2184 default:
2185 break;
2188 return 0;
2191 void
2192 client_class_setup(lua_State *L)
2194 static const struct luaL_reg client_methods[] =
2196 LUA_CLASS_METHODS(client)
2197 { "get", luaA_client_get },
2198 { "__index", luaA_client_module_index },
2199 { "__newindex", luaA_client_module_newindex },
2200 { NULL, NULL }
2203 static const struct luaL_reg client_meta[] =
2205 LUA_OBJECT_META(client)
2206 LUA_CLASS_META
2207 { "buttons", luaA_client_buttons },
2208 { "keys", luaA_client_keys },
2209 { "isvisible", luaA_client_isvisible },
2210 { "geometry", luaA_client_geometry },
2211 { "struts", luaA_client_struts },
2212 { "tags", luaA_client_tags },
2213 { "kill", luaA_client_kill },
2214 { "swap", luaA_client_swap },
2215 { "raise", luaA_client_raise },
2216 { "lower", luaA_client_lower },
2217 { "redraw", luaA_client_redraw },
2218 { "unmanage", luaA_client_unmanage },
2219 { "__gc", luaA_client_gc },
2220 { NULL, NULL }
2223 luaA_class_setup(L, &client_class, "client", (lua_class_allocator_t) client_new,
2224 luaA_class_index_miss_property, luaA_class_newindex_miss_property,
2225 client_methods, client_meta);
2226 luaA_class_add_property(&client_class, A_TK_NAME,
2227 NULL,
2228 (lua_class_propfunc_t) luaA_client_get_name,
2229 NULL);
2230 luaA_class_add_property(&client_class, A_TK_TRANSIENT_FOR,
2231 NULL,
2232 (lua_class_propfunc_t) luaA_client_get_transient_for,
2233 NULL);
2234 luaA_class_add_property(&client_class, A_TK_SKIP_TASKBAR,
2235 (lua_class_propfunc_t) luaA_client_set_skip_taskbar,
2236 (lua_class_propfunc_t) luaA_client_get_skip_taskbar,
2237 (lua_class_propfunc_t) luaA_client_set_skip_taskbar);
2238 luaA_class_add_property(&client_class, A_TK_CONTENT,
2239 NULL,
2240 (lua_class_propfunc_t) luaA_client_get_content,
2241 NULL);
2242 luaA_class_add_property(&client_class, A_TK_TYPE,
2243 NULL,
2244 (lua_class_propfunc_t) luaA_client_get_type,
2245 NULL);
2246 luaA_class_add_property(&client_class, A_TK_CLASS,
2247 NULL,
2248 (lua_class_propfunc_t) luaA_client_get_class,
2249 NULL);
2250 luaA_class_add_property(&client_class, A_TK_INSTANCE,
2251 NULL,
2252 (lua_class_propfunc_t) luaA_client_get_instance,
2253 NULL);
2254 luaA_class_add_property(&client_class, A_TK_ROLE,
2255 NULL,
2256 (lua_class_propfunc_t) luaA_client_get_role,
2257 NULL);
2258 luaA_class_add_property(&client_class, A_TK_PID,
2259 NULL,
2260 (lua_class_propfunc_t) luaA_client_get_pid,
2261 NULL);
2262 luaA_class_add_property(&client_class, A_TK_WINDOW,
2263 NULL,
2264 (lua_class_propfunc_t) luaA_client_get_window,
2265 NULL);
2266 luaA_class_add_property(&client_class, A_TK_LEADER_WINDOW,
2267 NULL,
2268 (lua_class_propfunc_t) luaA_client_get_leader_window,
2269 NULL);
2270 luaA_class_add_property(&client_class, A_TK_MACHINE,
2271 NULL,
2272 (lua_class_propfunc_t) luaA_client_get_machine,
2273 NULL);
2274 luaA_class_add_property(&client_class, A_TK_ICON_NAME,
2275 NULL,
2276 (lua_class_propfunc_t) luaA_client_get_icon_name,
2277 NULL);
2278 luaA_class_add_property(&client_class, A_TK_SCREEN,
2279 NULL,
2280 (lua_class_propfunc_t) luaA_client_get_screen,
2281 (lua_class_propfunc_t) luaA_client_set_screen);
2282 luaA_class_add_property(&client_class, A_TK_HIDDEN,
2283 (lua_class_propfunc_t) luaA_client_set_hidden,
2284 (lua_class_propfunc_t) luaA_client_get_hidden,
2285 (lua_class_propfunc_t) luaA_client_set_hidden);
2286 luaA_class_add_property(&client_class, A_TK_MINIMIZED,
2287 (lua_class_propfunc_t) luaA_client_set_minimized,
2288 (lua_class_propfunc_t) luaA_client_get_minimized,
2289 (lua_class_propfunc_t) luaA_client_set_minimized);
2290 luaA_class_add_property(&client_class, A_TK_FULLSCREEN,
2291 (lua_class_propfunc_t) luaA_client_set_fullscreen,
2292 (lua_class_propfunc_t) luaA_client_get_fullscreen,
2293 (lua_class_propfunc_t) luaA_client_set_fullscreen);
2294 luaA_class_add_property(&client_class, A_TK_MODAL,
2295 (lua_class_propfunc_t) luaA_client_set_modal,
2296 (lua_class_propfunc_t) luaA_client_get_modal,
2297 (lua_class_propfunc_t) luaA_client_set_modal);
2298 luaA_class_add_property(&client_class, A_TK_GROUP_WINDOW,
2299 NULL,
2300 (lua_class_propfunc_t) luaA_client_get_group_window,
2301 NULL);
2302 luaA_class_add_property(&client_class, A_TK_MAXIMIZED_HORIZONTAL,
2303 (lua_class_propfunc_t) luaA_client_set_maximized_horizontal,
2304 (lua_class_propfunc_t) luaA_client_get_maximized_horizontal,
2305 (lua_class_propfunc_t) luaA_client_set_maximized_horizontal);
2306 luaA_class_add_property(&client_class, A_TK_MAXIMIZED_VERTICAL,
2307 (lua_class_propfunc_t) luaA_client_set_maximized_vertical,
2308 (lua_class_propfunc_t) luaA_client_get_maximized_vertical,
2309 (lua_class_propfunc_t) luaA_client_set_maximized_vertical);
2310 luaA_class_add_property(&client_class, A_TK_ICON,
2311 (lua_class_propfunc_t) luaA_client_set_icon,
2312 (lua_class_propfunc_t) luaA_client_get_icon,
2313 (lua_class_propfunc_t) luaA_client_set_icon);
2314 luaA_class_add_property(&client_class, A_TK_OPACITY,
2315 (lua_class_propfunc_t) luaA_client_set_opacity,
2316 (lua_class_propfunc_t) luaA_client_get_opacity,
2317 (lua_class_propfunc_t) luaA_client_set_opacity);
2318 luaA_class_add_property(&client_class, A_TK_ONTOP,
2319 (lua_class_propfunc_t) luaA_client_set_ontop,
2320 (lua_class_propfunc_t) luaA_client_get_ontop,
2321 (lua_class_propfunc_t) luaA_client_set_ontop);
2322 luaA_class_add_property(&client_class, A_TK_ABOVE,
2323 (lua_class_propfunc_t) luaA_client_set_above,
2324 (lua_class_propfunc_t) luaA_client_get_above,
2325 (lua_class_propfunc_t) luaA_client_set_above);
2326 luaA_class_add_property(&client_class, A_TK_BELOW,
2327 (lua_class_propfunc_t) luaA_client_set_below,
2328 (lua_class_propfunc_t) luaA_client_get_below,
2329 (lua_class_propfunc_t) luaA_client_set_below);
2330 luaA_class_add_property(&client_class, A_TK_STICKY,
2331 (lua_class_propfunc_t) luaA_client_set_sticky,
2332 (lua_class_propfunc_t) luaA_client_get_sticky,
2333 (lua_class_propfunc_t) luaA_client_set_sticky);
2334 luaA_class_add_property(&client_class, A_TK_SIZE_HINTS_HONOR,
2335 (lua_class_propfunc_t) luaA_client_set_size_hints_honor,
2336 (lua_class_propfunc_t) luaA_client_get_size_hints_honor,
2337 (lua_class_propfunc_t) luaA_client_set_size_hints_honor);
2338 luaA_class_add_property(&client_class, A_TK_BORDER_WIDTH,
2339 (lua_class_propfunc_t) luaA_client_set_border_width,
2340 (lua_class_propfunc_t) luaA_client_get_border_width,
2341 (lua_class_propfunc_t) luaA_client_set_border_width);
2342 luaA_class_add_property(&client_class, A_TK_BORDER_COLOR,
2343 (lua_class_propfunc_t) luaA_client_set_border_color,
2344 (lua_class_propfunc_t) luaA_client_get_border_color,
2345 (lua_class_propfunc_t) luaA_client_set_border_color);
2346 luaA_class_add_property(&client_class, A_TK_TITLEBAR,
2347 (lua_class_propfunc_t) luaA_client_set_titlebar,
2348 (lua_class_propfunc_t) luaA_client_get_titlebar,
2349 (lua_class_propfunc_t) luaA_client_set_titlebar);
2350 luaA_class_add_property(&client_class, A_TK_URGENT,
2351 (lua_class_propfunc_t) luaA_client_set_urgent,
2352 (lua_class_propfunc_t) luaA_client_get_urgent,
2353 (lua_class_propfunc_t) luaA_client_set_urgent);
2354 luaA_class_add_property(&client_class, A_TK_SIZE_HINTS,
2355 NULL,
2356 (lua_class_propfunc_t) luaA_client_get_size_hints,
2357 NULL);
2360 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80