Make fullscreen stacking respect EWMH
[awesome.git] / client.c
blob49d0e915c8d5f990adf142a8c1dadefcb3e5a228
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_class_emit_signal(globalconf.L, &client_class, "focus", 1);
437 /** Give focus to client, or to first client if client is NULL.
438 * \param c The client.
440 void
441 client_focus(client_t *c)
443 /* We have to set focus on first client */
444 if(!c && globalconf.clients.len && !(c = globalconf.clients.tab[0]))
445 return;
447 if(!client_maybevisible(c, c->screen))
448 return;
450 if (!c->nofocus)
451 client_focus_update(c);
453 client_set_focus(c, !c->nofocus);
456 /** Stack a window below.
457 * \param c The client.
458 * \param previous The previous window on the stack.
459 * \return The next-previous!
461 static xcb_window_t
462 client_stack_above(client_t *c, xcb_window_t previous)
464 uint32_t config_win_vals[2];
466 config_win_vals[0] = previous;
467 config_win_vals[1] = XCB_STACK_MODE_ABOVE;
469 xcb_configure_window(globalconf.connection, c->window,
470 XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
471 config_win_vals);
473 config_win_vals[0] = c->window;
475 if(c->titlebar)
477 xcb_configure_window(globalconf.connection,
478 c->titlebar->window,
479 XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
480 config_win_vals);
481 previous = c->titlebar->window;
483 else
484 previous = c->window;
486 /* stack transient window on top of their parents */
487 foreach(node, globalconf.stack)
488 if((*node)->transient_for == c)
489 previous = client_stack_above(*node, previous);
491 return previous;
494 /** Stacking layout layers */
495 typedef enum
497 /** This one is a special layer */
498 LAYER_IGNORE,
499 LAYER_DESKTOP,
500 LAYER_BELOW,
501 LAYER_NORMAL,
502 LAYER_ABOVE,
503 LAYER_FULLSCREEN,
504 LAYER_ONTOP,
505 /** This one only used for counting and is not a real layer */
506 LAYER_COUNT
507 } layer_t;
509 /** Get the real layer of a client according to its attribute (fullscreen, …)
510 * \param c The client.
511 * \return The real layer.
513 static layer_t
514 client_layer_translator(client_t *c)
516 /* first deal with user set attributes */
517 if(c->ontop)
518 return LAYER_ONTOP;
519 else if(c->fullscreen && globalconf.screen_focus->client_focus == c)
520 return LAYER_FULLSCREEN;
521 else if(c->above)
522 return LAYER_ABOVE;
523 else if(c->below)
524 return LAYER_BELOW;
526 /* check for transient attr */
527 if(c->transient_for)
528 return LAYER_IGNORE;
530 /* then deal with windows type */
531 switch(c->type)
533 case WINDOW_TYPE_DESKTOP:
534 return LAYER_DESKTOP;
535 default:
536 break;
539 return LAYER_NORMAL;
542 /** Restack clients.
543 * \todo It might be worth stopping to restack everyone and only stack `c'
544 * relatively to the first matching in the list.
546 void
547 client_stack_refresh()
549 uint32_t config_win_vals[2];
550 layer_t layer;
552 if (!globalconf.client_need_stack_refresh)
553 return;
554 globalconf.client_need_stack_refresh = false;
556 config_win_vals[0] = XCB_NONE;
557 config_win_vals[1] = XCB_STACK_MODE_ABOVE;
559 /* stack desktop windows */
560 for(layer = LAYER_DESKTOP; layer < LAYER_BELOW; layer++)
561 foreach(node, globalconf.stack)
562 if(client_layer_translator(*node) == layer)
563 config_win_vals[0] = client_stack_above(*node,
564 config_win_vals[0]);
566 /* first stack not ontop wibox window */
567 foreach(_sb, globalconf.wiboxes)
569 wibox_t *sb = *_sb;
570 if(!sb->ontop)
572 xcb_configure_window(globalconf.connection,
573 sb->window,
574 XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
575 config_win_vals);
576 config_win_vals[0] = sb->window;
580 /* then stack clients */
581 for(layer = LAYER_BELOW; layer < LAYER_COUNT; layer++)
582 foreach(node, globalconf.stack)
583 if(client_layer_translator(*node) == layer)
584 config_win_vals[0] = client_stack_above(*node,
585 config_win_vals[0]);
587 /* then stack ontop wibox window */
588 foreach(_sb, globalconf.wiboxes)
590 wibox_t *sb = *_sb;
591 if(sb->ontop)
593 xcb_configure_window(globalconf.connection,
594 sb->window,
595 XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
596 config_win_vals);
597 config_win_vals[0] = sb->window;
602 /** Manage a new client.
603 * \param w The window.
604 * \param wgeom Window geometry.
605 * \param phys_screen Physical screen number.
606 * \param startup True if we are managing at startup time.
608 void
609 client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen, bool startup)
611 const uint32_t select_input_val[] = { CLIENT_SELECT_INPUT_EVENT_MASK };
613 if(systray_iskdedockapp(w))
615 systray_request_handle(w, phys_screen, NULL);
616 return;
619 /* If this is a new client that just has been launched, then request its
620 * startup id. */
621 xcb_get_property_cookie_t startup_id_q = { 0 };
622 if(!startup)
623 startup_id_q = xcb_get_any_property(globalconf.connection,
624 false, w, _NET_STARTUP_ID, UINT_MAX);
626 xcb_change_window_attributes(globalconf.connection, w, XCB_CW_EVENT_MASK, select_input_val);
628 /* Make sure the window is automatically mapped if awesome exits or dies. */
629 xcb_change_save_set(globalconf.connection, XCB_SET_MODE_INSERT, w);
631 /* Move this window to the bottom of the stack. Without this we would force
632 * other windows which will be above this one to redraw themselves because
633 * this window occludes them for a tiny moment. The next stack_refresh()
634 * will fix this up and move the window to its correct place. */
635 xcb_configure_window(globalconf.connection, w,
636 XCB_CONFIG_WINDOW_STACK_MODE,
637 (uint32_t[]) { XCB_STACK_MODE_BELOW});
639 client_t *c = client_new(globalconf.L);
641 /* This cannot change, ever. */
642 c->phys_screen = phys_screen;
643 /* consider the window banned */
644 c->isbanned = true;
645 /* Store window */
646 c->window = w;
647 luaA_object_emit_signal(globalconf.L, -1, "property::window", 0);
649 /* Duplicate client and push it in client list */
650 lua_pushvalue(globalconf.L, -1);
651 client_array_push(&globalconf.clients, luaA_object_ref(globalconf.L, -1));
653 /* Set the right screen */
654 screen_client_moveto(c, screen_getbycoord(&globalconf.screens.tab[phys_screen], wgeom->x, wgeom->y), false);
656 /* Store initial geometry and emits signals so we inform that geometry have
657 * been set. */
658 #define HANDLE_GEOM(attr) \
659 c->geometry.attr = wgeom->attr; \
660 c->geometries.internal.attr = wgeom->attr; \
661 luaA_object_emit_signal(globalconf.L, -1, "property::" #attr, 0);
662 HANDLE_GEOM(x)
663 HANDLE_GEOM(y)
664 HANDLE_GEOM(width)
665 HANDLE_GEOM(height)
666 #undef HANDLE_GEOM
668 luaA_object_emit_signal(globalconf.L, -1, "property::geometry", 0);
670 /* Push client */
671 client_set_border_width(globalconf.L, -1, wgeom->border_width);
673 /* we honor size hints by default */
674 c->size_hints_honor = true;
675 luaA_object_emit_signal(globalconf.L, -1, "property::size_hints_honor", 0);
677 /* update hints */
678 property_update_wm_normal_hints(c, NULL);
679 property_update_wm_hints(c, NULL);
680 property_update_wm_transient_for(c, NULL);
681 property_update_wm_client_leader(c, NULL);
682 property_update_wm_client_machine(c, NULL);
683 property_update_wm_window_role(c, NULL);
684 property_update_net_wm_pid(c, NULL);
685 property_update_net_wm_icon(c, NULL);
687 /* get opacity */
688 client_set_opacity(globalconf.L, -1, window_opacity_get(c->window));
690 /* Then check clients hints */
691 ewmh_client_check_hints(c);
693 /* Push client in stack */
694 client_raise(c);
696 /* update window title */
697 property_update_wm_name(c, NULL);
698 property_update_net_wm_name(c, NULL);
699 property_update_wm_icon_name(c, NULL);
700 property_update_net_wm_icon_name(c, NULL);
701 property_update_wm_class(c, NULL);
702 property_update_wm_protocols(c, NULL);
704 /* update strut */
705 ewmh_process_client_strut(c, NULL);
707 ewmh_update_net_client_list(c->phys_screen);
709 /* Always stay in NORMAL_STATE. Even though iconified seems more
710 * appropriate sometimes. The only possible loss is that clients not using
711 * visibility events may continue to process data (when banned).
712 * Without any exposes or other events the cost should be fairly limited though.
714 * Some clients may expect the window to be unmapped when STATE_ICONIFIED.
715 * Two conflicting parts of the ICCCM v2.0 (section 4.1.4):
717 * "Normal -> Iconic - The client should send a ClientMessage event as described later in this section."
718 * (note no explicit mention of unmapping, while Normal->Widthdrawn does mention that)
720 * "Once a client's window has left the Withdrawn state, the window will be mapped
721 * if it is in the Normal state and the window will be unmapped if it is in the Iconic state."
723 * At this stage it's just safer to keep it in normal state and avoid confusion.
725 window_state_set(c->window, XCB_WM_STATE_NORMAL);
727 if(!startup)
729 /* Request our response */
730 xcb_get_property_reply_t *reply =
731 xcb_get_property_reply(globalconf.connection, startup_id_q, NULL);
732 /* Say spawn that a client has been started, with startup id as argument */
733 char *startup_id = xutil_get_text_property_from_reply(reply);
734 p_delete(&reply);
735 spawn_start_notify(c, startup_id);
736 p_delete(&startup_id);
739 /* Call hook to notify list change */
740 if(globalconf.hooks.clients != LUA_REFNIL)
741 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.clients, 0, 0);
743 luaA_class_emit_signal(globalconf.L, &client_class, "list", 0);
745 /* call hook */
746 if(globalconf.hooks.manage != LUA_REFNIL)
748 luaA_object_push(globalconf.L, c);
749 lua_pushboolean(globalconf.L, startup);
750 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.manage, 2, 0);
753 /* client is still on top of the stack; push startup value,
754 * and emit signals with 2 args */
755 lua_pushboolean(globalconf.L, startup);
756 luaA_class_emit_signal(globalconf.L, &client_class, "manage", 2);
759 /** Compute client geometry with respect to its geometry hints.
760 * \param c The client.
761 * \param geometry The geometry that the client might receive.
762 * \return The geometry the client must take respecting its hints.
764 area_t
765 client_geometry_hints(client_t *c, area_t geometry)
767 int32_t basew, baseh, minw, minh;
768 int32_t real_basew = 0, real_baseh = 0;
770 /* base size is substituted with min size if not specified */
771 if(c->size_hints.flags & XCB_SIZE_HINT_P_SIZE)
773 basew = c->size_hints.base_width;
774 baseh = c->size_hints.base_height;
775 real_basew = basew;
776 real_baseh = baseh;
778 else if(c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)
780 basew = c->size_hints.min_width;
781 baseh = c->size_hints.min_height;
783 else
784 basew = baseh = 0;
786 /* min size is substituted with base size if not specified */
787 if(c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)
789 minw = c->size_hints.min_width;
790 minh = c->size_hints.min_height;
792 else if(c->size_hints.flags & XCB_SIZE_HINT_P_SIZE)
794 minw = c->size_hints.base_width;
795 minh = c->size_hints.base_height;
797 else
798 minw = minh = 0;
800 if(c->size_hints.flags & XCB_SIZE_HINT_P_ASPECT
801 && c->size_hints.min_aspect_den > 0
802 && c->size_hints.max_aspect_den > 0
803 && geometry.height - real_baseh > 0
804 && geometry.width - real_basew > 0)
806 /* ICCCM mandates:
807 * If a base size is provided along with the aspect ratio fields, the
808 * base size should be subtracted from the window size prior to checking
809 * that the aspect ratio falls in range. If a base size is not provided,
810 * nothing should be subtracted from the window size. (The minimum size
811 * is not to be used in place of the base size for this purpose.) */
812 double dx = (double) (geometry.width - real_basew);
813 double dy = (double) (geometry.height - real_baseh);
814 double min = (double) c->size_hints.min_aspect_num / (double) c->size_hints.min_aspect_den;
815 double max = (double) c->size_hints.max_aspect_num / (double) c->size_hints.max_aspect_den;
816 double ratio = dx / dy;
817 if(max > 0 && min > 0 && ratio > 0)
819 if(ratio < min)
821 /* dx is lower than allowed, make dy lower to compensate this
822 * (+ 0.5 to force proper rounding). */
823 dy = dx / min + 0.5;
824 geometry.width = (int) dx + real_basew;
825 geometry.height = (int) dy + real_baseh;
827 else if(ratio > max)
829 /* dx is too high, lower it (+0.5 for proper rounding) */
830 dx = dy * max + 0.5;
831 geometry.width = (int) dx + real_basew;
832 geometry.height = (int) dy + real_baseh;
837 if(minw)
838 geometry.width = MAX(geometry.width, minw);
839 if(minh)
840 geometry.height = MAX(geometry.height, minh);
842 if(c->size_hints.flags & XCB_SIZE_HINT_P_MAX_SIZE)
844 if(c->size_hints.max_width)
845 geometry.width = MIN(geometry.width, c->size_hints.max_width);
846 if(c->size_hints.max_height)
847 geometry.height = MIN(geometry.height, c->size_hints.max_height);
850 if(c->size_hints.flags & (XCB_SIZE_HINT_P_RESIZE_INC | XCB_SIZE_HINT_BASE_SIZE)
851 && c->size_hints.width_inc && c->size_hints.height_inc)
853 uint16_t t1 = geometry.width, t2 = geometry.height;
854 unsigned_subtract(t1, basew);
855 unsigned_subtract(t2, baseh);
856 geometry.width -= t1 % c->size_hints.width_inc;
857 geometry.height -= t2 % c->size_hints.height_inc;
860 return geometry;
863 /** Resize client window.
864 * The sizes given as parameters are with titlebar and borders!
865 * \param c Client to resize.
866 * \param geometry New window geometry.
867 * \param hints Use size hints.
868 * \return true if an actual resize occurred.
870 bool
871 client_resize(client_t *c, area_t geometry, bool hints)
873 area_t geometry_internal;
874 area_t area;
876 /* offscreen appearance fixes */
877 area = display_area_get(c->phys_screen);
879 if(geometry.x > area.width)
880 geometry.x = area.width - geometry.width;
881 if(geometry.y > area.height)
882 geometry.y = area.height - geometry.height;
883 if(geometry.x + geometry.width < 0)
884 geometry.x = 0;
885 if(geometry.y + geometry.height < 0)
886 geometry.y = 0;
888 /* Real client geometry, please keep it contained to C code at the very least. */
889 geometry_internal = titlebar_geometry_remove(c->titlebar, c->border_width, geometry);
891 if(hints && !c->fullscreen)
892 geometry_internal = client_geometry_hints(c, geometry_internal);
894 if(geometry_internal.width == 0 || geometry_internal.height == 0)
895 return false;
897 /* Also let client hints propagate to the "official" geometry. */
898 geometry = titlebar_geometry_add(c->titlebar, c->border_width, geometry_internal);
900 if(c->geometries.internal.x != geometry_internal.x
901 || c->geometries.internal.y != geometry_internal.y
902 || c->geometries.internal.width != geometry_internal.width
903 || c->geometries.internal.height != geometry_internal.height)
905 screen_t *new_screen = screen_getbycoord(c->screen,
906 geometry_internal.x, geometry_internal.y);
908 /* Values to configure a window is an array where values are
909 * stored according to 'value_mask' */
910 uint32_t values[4];
912 c->geometries.internal.x = values[0] = geometry_internal.x;
913 c->geometries.internal.y = values[1] = geometry_internal.y;
914 c->geometries.internal.width = values[2] = geometry_internal.width;
915 c->geometries.internal.height = values[3] = geometry_internal.height;
917 /* Also store geometry including border and titlebar. */
918 c->geometry = geometry;
920 titlebar_update_geometry(c);
922 /* Ignore all spurious enter/leave notify events */
923 client_ignore_enterleave_events();
925 xcb_configure_window(globalconf.connection, c->window,
926 XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y
927 | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
928 values);
930 client_restore_enterleave_events();
932 screen_client_moveto(c, new_screen, false);
934 /* execute hook */
935 hook_property(c, "geometry");
937 luaA_object_push(globalconf.L, c);
938 luaA_object_emit_signal(globalconf.L, -1, "property::geometry", 0);
939 /** \todo This need to be VERIFIED before it is emitted! */
940 luaA_object_emit_signal(globalconf.L, -1, "property::x", 0);
941 luaA_object_emit_signal(globalconf.L, -1, "property::y", 0);
942 luaA_object_emit_signal(globalconf.L, -1, "property::width", 0);
943 luaA_object_emit_signal(globalconf.L, -1, "property::height", 0);
944 lua_pop(globalconf.L, 1);
946 return true;
949 return false;
952 /** Set a client minimized, or not.
953 * \param L The Lua VM state.
954 * \param cidx The client index.
955 * \param s Set or not the client minimized.
957 void
958 client_set_minimized(lua_State *L, int cidx, bool s)
960 client_t *c = luaA_client_checkudata(L, cidx);
962 if(c->minimized != s)
964 c->minimized = s;
965 banning_need_update((c)->screen);
966 if(s)
967 window_state_set(c->window, XCB_WM_STATE_ICONIC);
968 else
969 window_state_set(c->window, XCB_WM_STATE_NORMAL);
970 ewmh_client_update_hints(c);
971 if(strut_has_value(&c->strut))
972 screen_emit_signal(globalconf.L, c->screen, "property::workarea", 0);
973 /* execute hook */
974 hook_property(c, "minimized");
975 luaA_object_emit_signal(L, cidx, "property::minimized", 0);
979 /** Set a client sticky, or not.
980 * \param L The Lua VM state.
981 * \param cidx The client index.
982 * \param s Set or not the client sticky.
984 void
985 client_set_sticky(lua_State *L, int cidx, bool s)
987 client_t *c = luaA_client_checkudata(L, cidx);
989 if(c->sticky != s)
991 c->sticky = s;
992 banning_need_update((c)->screen);
993 ewmh_client_update_hints(c);
994 hook_property(c, "sticky");
995 luaA_object_emit_signal(L, cidx, "property::sticky", 0);
999 /** Set a client fullscreen, or not.
1000 * \param L The Lua VM state.
1001 * \param cidx The client index.
1002 * \param s Set or not the client fullscreen.
1004 void
1005 client_set_fullscreen(lua_State *L, int cidx, bool s)
1007 client_t *c = luaA_client_checkudata(L, cidx);
1009 if(c->fullscreen != s)
1011 area_t geometry;
1013 /* become fullscreen! */
1014 if(s)
1016 /* Make sure the current geometry is stored without titlebar. */
1017 titlebar_ban(c->titlebar);
1018 /* remove any max state */
1019 client_set_maximized_horizontal(L, cidx, false);
1020 client_set_maximized_vertical(L, cidx, false);
1021 /* You can only be part of one of the special layers. */
1022 client_set_below(L, cidx, false);
1023 client_set_above(L, cidx, false);
1024 client_set_ontop(L, cidx, false);
1026 geometry = screen_area_get(c->screen, false);
1027 c->geometries.fullscreen = c->geometry;
1028 c->border_width_fs = c->border_width;
1029 client_set_border_width(L, cidx, 0);
1030 c->fullscreen = true;
1032 else
1034 geometry = c->geometries.fullscreen;
1035 c->fullscreen = false;
1036 client_set_border_width(L, cidx, c->border_width_fs);
1038 client_resize(c, geometry, false);
1039 client_stack();
1040 ewmh_client_update_hints(c);
1041 hook_property(c, "fullscreen");
1042 luaA_object_emit_signal(L, cidx, "property::fullscreen", 0);
1046 /** Set a client horizontally maximized.
1047 * \param L The Lua VM state.
1048 * \param cidx The client index.
1049 * \param s The maximized status.
1051 void
1052 client_set_maximized_horizontal(lua_State *L, int cidx, bool s)
1054 client_t *c = luaA_client_checkudata(L, cidx);
1056 if(c->maximized_horizontal != s)
1058 area_t geometry;
1060 if((c->maximized_horizontal = s))
1062 /* remove fullscreen mode */
1063 client_set_fullscreen(L, cidx, false);
1065 geometry = screen_area_get(c->screen, true);
1066 geometry.y = c->geometry.y;
1067 geometry.height = c->geometry.height;
1068 c->geometries.max.x = c->geometry.x;
1069 c->geometries.max.width = c->geometry.width;
1071 else
1073 geometry = c->geometry;
1074 geometry.x = c->geometries.max.x;
1075 geometry.width = c->geometries.max.width;
1078 client_resize(c, geometry, c->size_hints_honor);
1079 client_stack();
1080 ewmh_client_update_hints(c);
1081 hook_property(c, "maximized_horizontal");
1082 luaA_object_emit_signal(L, cidx, "property::maximized_horizontal", 0);
1086 /** Set a client vertically maximized.
1087 * \param L The Lua VM state.
1088 * \param cidx The client index.
1089 * \param s The maximized status.
1091 void
1092 client_set_maximized_vertical(lua_State *L, int cidx, bool s)
1094 client_t *c = luaA_client_checkudata(L, cidx);
1096 if(c->maximized_vertical != s)
1098 area_t geometry;
1100 if((c->maximized_vertical = s))
1102 /* remove fullscreen mode */
1103 client_set_fullscreen(L, cidx, false);
1105 geometry = screen_area_get(c->screen, true);
1106 geometry.x = c->geometry.x;
1107 geometry.width = c->geometry.width;
1108 c->geometries.max.y = c->geometry.y;
1109 c->geometries.max.height = c->geometry.height;
1111 else
1113 geometry = c->geometry;
1114 geometry.y = c->geometries.max.y;
1115 geometry.height = c->geometries.max.height;
1118 client_resize(c, geometry, c->size_hints_honor);
1119 client_stack();
1120 ewmh_client_update_hints(c);
1121 hook_property(c, "maximized_vertical");
1122 luaA_object_emit_signal(L, cidx, "property::maximized_vertical", 0);
1126 /** Set a client above, or not.
1127 * \param L The Lua VM state.
1128 * \param cidx The client index.
1129 * \param s Set or not the client above.
1131 void
1132 client_set_above(lua_State *L, int cidx, bool s)
1134 client_t *c = luaA_client_checkudata(L, cidx);
1136 if(c->above != s)
1138 /* You can only be part of one of the special layers. */
1139 if(s)
1141 client_set_below(L, cidx, false);
1142 client_set_ontop(L, cidx, false);
1143 client_set_fullscreen(L, cidx, false);
1145 c->above = s;
1146 client_stack();
1147 ewmh_client_update_hints(c);
1148 /* execute hook */
1149 hook_property(c, "above");
1150 luaA_object_emit_signal(L, cidx, "property::above", 0);
1154 /** Set a client below, or not.
1155 * \param L The Lua VM state.
1156 * \param cidx The client index.
1157 * \param s Set or not the client below.
1159 void
1160 client_set_below(lua_State *L, int cidx, bool s)
1162 client_t *c = luaA_client_checkudata(L, cidx);
1164 if(c->below != s)
1166 /* You can only be part of one of the special layers. */
1167 if(s)
1169 client_set_above(L, cidx, false);
1170 client_set_ontop(L, cidx, false);
1171 client_set_fullscreen(L, cidx, false);
1173 c->below = s;
1174 client_stack();
1175 ewmh_client_update_hints(c);
1176 /* execute hook */
1177 hook_property(c, "below");
1178 luaA_object_emit_signal(L, cidx, "property::below", 0);
1182 /** Set a client modal, or not.
1183 * \param L The Lua VM state.
1184 * \param cidx The client index.
1185 * \param s Set or not the client modal attribute.
1187 void
1188 client_set_modal(lua_State *L, int cidx, bool s)
1190 client_t *c = luaA_client_checkudata(L, cidx);
1192 if(c->modal != s)
1194 c->modal = s;
1195 client_stack();
1196 ewmh_client_update_hints(c);
1197 /* execute hook */
1198 hook_property(c, "modal");
1199 luaA_object_emit_signal(L, cidx, "property::modal", 0);
1203 /** Set a client ontop, or not.
1204 * \param L The Lua VM state.
1205 * \param cidx The client index.
1206 * \param s Set or not the client ontop attribute.
1208 void
1209 client_set_ontop(lua_State *L, int cidx, bool s)
1211 client_t *c = luaA_client_checkudata(L, cidx);
1213 if(c->ontop != s)
1215 /* You can only be part of one of the special layers. */
1216 if(s)
1218 client_set_above(L, cidx, false);
1219 client_set_below(L, cidx, false);
1220 client_set_fullscreen(L, cidx, false);
1222 c->ontop = s;
1223 client_stack();
1224 /* execute hook */
1225 hook_property(c, "ontop");
1226 luaA_object_emit_signal(L, cidx, "property::ontop", 0);
1230 /** Set a client skip taskbar attribute.
1231 * \param L Tha Lua VM state.
1232 * \param cidx The client index.
1233 * \param s Set or not the client skip taskbar attribute.
1235 void
1236 client_set_skip_taskbar(lua_State *L, int cidx, bool s)
1238 client_t *c = luaA_client_checkudata(L, cidx);
1240 if(c->skip_taskbar != s)
1242 c->skip_taskbar = s;
1243 ewmh_client_update_hints(c);
1244 luaA_object_emit_signal(L, cidx, "property::skip_taskbar", 0);
1248 /** Unban a client and move it back into the viewport.
1249 * \param c The client.
1251 void
1252 client_unban(client_t *c)
1254 if(c->isbanned)
1256 xcb_map_window(globalconf.connection, c->window);
1258 c->isbanned = false;
1262 /** Unmanage a client.
1263 * \param c The client.
1265 void
1266 client_unmanage(client_t *c)
1268 tag_array_t *tags = &c->screen->tags;
1270 /* Reset transient_for attributes of widows that maybe referring to us */
1271 foreach(_tc, globalconf.clients)
1273 client_t *tc = *_tc;
1274 if(tc->transient_for == c)
1275 tc->transient_for = NULL;
1278 if(globalconf.screens.tab[c->phys_screen].prev_client_focus == c)
1279 globalconf.screens.tab[c->phys_screen].prev_client_focus = NULL;
1281 if(globalconf.screens.tab[c->phys_screen].client_focus == c)
1282 client_unfocus(c);
1284 /* remove client from global list and everywhere else */
1285 foreach(elem, globalconf.clients)
1286 if(*elem == c)
1288 client_array_remove(&globalconf.clients, elem);
1289 break;
1291 stack_client_remove(c);
1292 for(int i = 0; i < tags->len; i++)
1293 untag_client(c, tags->tab[i]);
1295 /* call hook */
1296 if(globalconf.hooks.unmanage != LUA_REFNIL)
1298 luaA_object_push(globalconf.L, c);
1299 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.unmanage, 1, 0);
1302 luaA_object_push(globalconf.L, c);
1303 luaA_class_emit_signal(globalconf.L, &client_class, "unmanage", 1);
1305 /* Call hook to notify list change */
1306 if(globalconf.hooks.clients != LUA_REFNIL)
1307 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.clients, 0, 0);
1309 luaA_class_emit_signal(globalconf.L, &client_class, "list", 0);
1311 if(strut_has_value(&c->strut))
1312 screen_emit_signal(globalconf.L, c->screen, "property::workarea", 0);
1314 window_state_set(c->window, XCB_WM_STATE_WITHDRAWN);
1316 titlebar_client_detach(c);
1318 ewmh_update_net_client_list(c->phys_screen);
1320 /* set client as invalid */
1321 c->invalid = true;
1323 luaA_object_unref(globalconf.L, c);
1326 /** Kill a client via a WM_DELETE_WINDOW request or KillClient if not
1327 * supported.
1328 * \param c The client to kill.
1330 void
1331 client_kill(client_t *c)
1333 if(client_hasproto(c, WM_DELETE_WINDOW))
1335 xcb_client_message_event_t ev;
1337 /* Initialize all of event's fields first */
1338 p_clear(&ev, 1);
1340 ev.response_type = XCB_CLIENT_MESSAGE;
1341 ev.window = c->window;
1342 ev.format = 32;
1343 ev.data.data32[1] = XCB_CURRENT_TIME;
1344 ev.type = WM_PROTOCOLS;
1345 ev.data.data32[0] = WM_DELETE_WINDOW;
1347 xcb_send_event(globalconf.connection, false, c->window,
1348 XCB_EVENT_MASK_NO_EVENT, (char *) &ev);
1350 else
1351 xcb_kill_client(globalconf.connection, c->window);
1354 /** Get all clients into a table.
1355 * \param L The Lua VM state.
1356 * \return The number of elements pushed on stack.
1357 * \luastack
1358 * \lparam An optional screen number.
1359 * \lreturn A table with all clients.
1361 static int
1362 luaA_client_get(lua_State *L)
1364 int i = 1, screen;
1366 screen = luaL_optnumber(L, 1, 0) - 1;
1368 lua_newtable(L);
1370 if(screen == -1)
1371 foreach(c, globalconf.clients)
1373 luaA_object_push(L, *c);
1374 lua_rawseti(L, -2, i++);
1376 else
1378 luaA_checkscreen(screen);
1379 foreach(c, globalconf.clients)
1380 if((*c)->screen == &globalconf.screens.tab[screen])
1382 luaA_object_push(L, *c);
1383 lua_rawseti(L, -2, i++);
1387 return 1;
1390 /** Check if a client is visible on its screen.
1391 * \param L The Lua VM state.
1392 * \return The number of elements pushed on stack.
1393 * \luastack
1394 * \lvalue A client.
1395 * \lreturn A boolean value, true if the client is visible, false otherwise.
1397 static int
1398 luaA_client_isvisible(lua_State *L)
1400 client_t *c = luaA_client_checkudata(L, 1);
1401 lua_pushboolean(L, client_isvisible(c, c->screen));
1402 return 1;
1405 /** Set client border width.
1406 * \param L The Lua VM state.
1407 * \param cidx The client index.
1408 * \param width The border width.
1410 void
1411 client_set_border_width(lua_State *L, int cidx, int width)
1413 client_t *c = luaA_client_checkudata(L, cidx);
1414 uint32_t w = width;
1416 if(width > 0 && (c->type == WINDOW_TYPE_DOCK
1417 || c->type == WINDOW_TYPE_SPLASH
1418 || c->type == WINDOW_TYPE_DESKTOP
1419 || c->fullscreen))
1420 return;
1422 if(width == c->border_width || width < 0)
1423 return;
1425 /* disallow change of border width if the client is fullscreen */
1426 if(c->fullscreen)
1427 return;
1429 /* Update geometry with the new border. */
1430 c->geometry.width -= 2 * c->border_width;
1431 c->geometry.height -= 2 * c->border_width;
1433 c->border_width = width;
1434 xcb_configure_window(globalconf.connection, c->window,
1435 XCB_CONFIG_WINDOW_BORDER_WIDTH, &w);
1437 c->geometry.width += 2 * c->border_width;
1438 c->geometry.height += 2 * c->border_width;
1440 /* Changing border size also affects the size of the titlebar. */
1441 titlebar_update_geometry(c);
1443 hook_property(c, "border_width");
1444 luaA_object_emit_signal(L, cidx, "property::border_width", 0);
1447 /** Set a client icon.
1448 * \param L The Lua VM state.
1449 * \param cidx The client index on the stack.
1450 * \param iidx The image index on the stack.
1452 void
1453 client_set_icon(lua_State *L, int cidx, int iidx)
1455 client_t *c = luaA_client_checkudata(L, cidx);
1456 /* convert index to absolute */
1457 cidx = luaA_absindex(L, cidx);
1458 iidx = luaA_absindex(L, iidx);
1459 luaA_checkudata(L, iidx, &image_class);
1460 luaA_object_unref_item(L, cidx, c->icon);
1461 c->icon = luaA_object_ref_item(L, cidx, iidx);
1462 luaA_object_emit_signal(L, cidx < iidx ? cidx : cidx - 1, "property::icon", 0);
1463 /* execute hook */
1464 hook_property(c, "icon");
1467 /** Kill a client.
1468 * \param L The Lua VM state.
1470 * \luastack
1471 * \lvalue A client.
1473 static int
1474 luaA_client_kill(lua_State *L)
1476 client_t *c = luaA_client_checkudata(L, 1);
1477 client_kill(c);
1478 return 0;
1481 /** Swap a client with another one.
1482 * \param L The Lua VM state.
1483 * \luastack
1484 * \lvalue A client.
1485 * \lparam A client to swap with.
1487 static int
1488 luaA_client_swap(lua_State *L)
1490 client_t *c = luaA_client_checkudata(L, 1);
1491 client_t *swap = luaA_client_checkudata(L, 2);
1493 if(c != swap)
1495 client_t **ref_c = NULL, **ref_swap = NULL;
1496 foreach(item, globalconf.clients)
1498 if(*item == c)
1499 ref_c = item;
1500 else if(*item == swap)
1501 ref_swap = item;
1502 if(ref_c && ref_swap)
1503 break;
1505 /* swap ! */
1506 *ref_c = swap;
1507 *ref_swap = c;
1509 /* Call hook to notify list change */
1510 if(globalconf.hooks.clients != LUA_REFNIL)
1511 luaA_dofunction_from_registry(L, globalconf.hooks.clients, 0, 0);
1513 luaA_class_emit_signal(globalconf.L, &client_class, "list", 0);
1516 return 0;
1519 /** Access or set the client tags.
1520 * \param L The Lua VM state.
1521 * \return The number of elements pushed on stack.
1522 * \lparam A table with tags to set, or none to get the current tags table.
1523 * \return The clients tag.
1525 static int
1526 luaA_client_tags(lua_State *L)
1528 client_t *c = luaA_client_checkudata(L, 1);
1529 tag_array_t *tags = &c->screen->tags;
1530 int j = 0;
1532 if(lua_gettop(L) == 2)
1534 luaA_checktable(L, 2);
1535 for(int i = 0; i < tags->len; i++)
1536 untag_client(c, tags->tab[i]);
1537 lua_pushnil(L);
1538 while(lua_next(L, 2))
1539 tag_client(c);
1540 lua_pop(L, 1);
1543 lua_newtable(L);
1544 foreach(tag, *tags)
1545 if(is_client_tagged(c, *tag))
1547 luaA_object_push(L, *tag);
1548 lua_rawseti(L, -2, ++j);
1551 return 1;
1554 /** Raise a client on top of others which are on the same layer.
1555 * \param L The Lua VM state.
1556 * \luastack
1557 * \lvalue A client.
1559 static int
1560 luaA_client_raise(lua_State *L)
1562 client_t *c = luaA_client_checkudata(L, 1);
1563 client_raise(c);
1564 return 0;
1567 /** Lower a client on bottom of others which are on the same layer.
1568 * \param L The Lua VM state.
1569 * \luastack
1570 * \lvalue A client.
1572 static int
1573 luaA_client_lower(lua_State *L)
1575 client_t *c = luaA_client_checkudata(L, 1);
1577 stack_client_push(c);
1579 /* Traverse all transient layers. */
1580 for(client_t *tc = c->transient_for; tc; tc = tc->transient_for)
1581 stack_client_push(tc);
1583 client_stack();
1585 return 0;
1588 /** Redraw a client by unmapping and mapping it quickly.
1589 * \param L The Lua VM state.
1591 * \luastack
1592 * \lvalue A client.
1594 static int
1595 luaA_client_redraw(lua_State *L)
1597 client_t *c = luaA_client_checkudata(L, 1);
1599 xcb_unmap_window(globalconf.connection, c->window);
1600 xcb_map_window(globalconf.connection, c->window);
1602 /* Set the focus on the current window if the redraw has been
1603 performed on the window where the pointer is currently on
1604 because after the unmapping/mapping, the focus is lost */
1605 if(globalconf.screen_focus->client_focus == c)
1607 client_unfocus(c);
1608 client_focus(c);
1611 return 0;
1614 /** Stop managing a client.
1615 * \param L The Lua VM state.
1616 * \return The number of elements pushed on stack.
1617 * \luastack
1618 * \lvalue A client.
1620 static int
1621 luaA_client_unmanage(lua_State *L)
1623 client_t *c = luaA_client_checkudata(L, 1);
1624 client_unmanage(c);
1625 return 0;
1628 /** Return client geometry.
1629 * \param L The Lua VM state.
1630 * \return The number of elements pushed on stack.
1631 * \luastack
1632 * \lparam A table with new coordinates, or none.
1633 * \lreturn A table with client coordinates.
1635 static int
1636 luaA_client_geometry(lua_State *L)
1638 client_t *c = luaA_client_checkudata(L, 1);
1640 if(lua_gettop(L) == 2 && !lua_isnil(L, 2))
1642 area_t geometry;
1644 luaA_checktable(L, 2);
1645 geometry.x = luaA_getopt_number(L, 2, "x", c->geometry.x);
1646 geometry.y = luaA_getopt_number(L, 2, "y", c->geometry.y);
1647 if(client_isfixed(c))
1649 geometry.width = c->geometry.width;
1650 geometry.height = c->geometry.height;
1652 else
1654 geometry.width = luaA_getopt_number(L, 2, "width", c->geometry.width);
1655 geometry.height = luaA_getopt_number(L, 2, "height", c->geometry.height);
1658 client_resize(c, geometry, c->size_hints_honor);
1661 return luaA_pusharea(L, c->geometry);
1664 /** Return client struts (reserved space at the edge of the screen).
1665 * \param L The Lua VM state.
1666 * \return The number of elements pushed on stack.
1667 * \luastack
1668 * \lparam A table with new strut values, or none.
1669 * \lreturn A table with strut values.
1671 static int
1672 luaA_client_struts(lua_State *L)
1674 client_t *c = luaA_client_checkudata(L, 1);
1676 if(lua_gettop(L) == 2)
1678 luaA_tostrut(L, 2, &c->strut);
1679 ewmh_update_strut(c->window, &c->strut);
1680 hook_property(c, "struts");
1681 luaA_object_emit_signal(L, 1, "property::struts", 0);
1682 screen_emit_signal(L, c->screen, "property::workarea", 0);
1685 return luaA_pushstrut(L, c->strut);
1688 static int
1689 luaA_client_set_screen(lua_State *L, client_t *c)
1691 if(globalconf.xinerama_is_active)
1693 int screen = luaL_checknumber(L, -1) - 1;
1694 luaA_checkscreen(screen);
1695 screen_client_moveto(c, &globalconf.screens.tab[screen], true);
1697 return 0;
1700 static int
1701 luaA_client_set_hidden(lua_State *L, client_t *c)
1703 bool b = luaA_checkboolean(L, -1);
1704 if(b != c->hidden)
1706 c->hidden = b;
1707 banning_need_update((c)->screen);
1708 hook_property(c, "hidden");
1709 if(strut_has_value(&c->strut))
1710 screen_emit_signal(globalconf.L, c->screen, "property::workarea", 0);
1711 luaA_object_emit_signal(L, -3, "property::hidden", 0);
1713 return 0;
1716 static int
1717 luaA_client_set_minimized(lua_State *L, client_t *c)
1719 client_set_minimized(L, -3, luaA_checkboolean(L, -1));
1720 return 0;
1723 static int
1724 luaA_client_set_fullscreen(lua_State *L, client_t *c)
1726 client_set_fullscreen(L, -3, luaA_checkboolean(L, -1));
1727 return 0;
1730 static int
1731 luaA_client_set_modal(lua_State *L, client_t *c)
1733 client_set_modal(L, -3, luaA_checkboolean(L, -1));
1734 return 0;
1737 static int
1738 luaA_client_set_maximized_horizontal(lua_State *L, client_t *c)
1740 client_set_maximized_horizontal(L, -3, luaA_checkboolean(L, -1));
1741 return 0;
1744 static int
1745 luaA_client_set_maximized_vertical(lua_State *L, client_t *c)
1747 client_set_maximized_vertical(L, -3, luaA_checkboolean(L, -1));
1748 return 0;
1751 static int
1752 luaA_client_set_icon(lua_State *L, client_t *c)
1754 client_set_icon(L, -3, -1);
1755 return 0;
1758 static int
1759 luaA_client_set_opacity(lua_State *L, client_t *c)
1761 if(lua_isnil(L, -1))
1762 client_set_opacity(L, -3, -1);
1763 else
1764 client_set_opacity(L, -3, luaL_checknumber(L, -1));
1765 return 0;
1768 static int
1769 luaA_client_set_sticky(lua_State *L, client_t *c)
1771 client_set_sticky(L, -3, luaA_checkboolean(L, -1));
1772 return 0;
1775 static int
1776 luaA_client_set_size_hints_honor(lua_State *L, client_t *c)
1778 c->size_hints_honor = luaA_checkboolean(L, -1);
1779 hook_property(c, "size_hints_honor");
1780 luaA_object_emit_signal(L, -3, "property::size_hints_honor", 0);
1781 return 0;
1784 static int
1785 luaA_client_set_border_width(lua_State *L, client_t *c)
1787 client_set_border_width(L, -3, luaL_checknumber(L, -1));
1788 return 0;
1791 static int
1792 luaA_client_set_ontop(lua_State *L, client_t *c)
1794 client_set_ontop(L, -3, luaA_checkboolean(L, -1));
1795 return 0;
1798 static int
1799 luaA_client_set_below(lua_State *L, client_t *c)
1801 client_set_below(L, -3, luaA_checkboolean(L, -1));
1802 return 0;
1805 static int
1806 luaA_client_set_above(lua_State *L, client_t *c)
1808 client_set_above(L, -3, luaA_checkboolean(L, -1));
1809 return 0;
1812 static int
1813 luaA_client_set_urgent(lua_State *L, client_t *c)
1815 client_set_urgent(L, -3, luaA_checkboolean(L, -1));
1816 return 0;
1819 static int
1820 luaA_client_set_border_color(lua_State *L, client_t *c)
1822 size_t len;
1823 const char *buf;
1824 if((buf = luaL_checklstring(L, -1, &len))
1825 && xcolor_init_reply(xcolor_init_unchecked(&c->border_color, buf, len)))
1827 xcb_change_window_attributes(globalconf.connection, c->window,
1828 XCB_CW_BORDER_PIXEL, &c->border_color.pixel);
1829 luaA_object_emit_signal(L, -3, "property::border_color", 0);
1831 return 0;
1834 static int
1835 luaA_client_set_titlebar(lua_State *L, client_t *c)
1837 if(lua_isnil(L, -1))
1838 titlebar_client_detach(c);
1839 else
1840 titlebar_client_attach(c);
1841 return 0;
1844 static int
1845 luaA_client_set_skip_taskbar(lua_State *L, client_t *c)
1847 client_set_skip_taskbar(L, -3, luaA_checkboolean(L, -1));
1848 return 0;
1851 static int
1852 luaA_client_get_name(lua_State *L, client_t *c)
1854 lua_pushstring(L, c->name ? c->name : c->alt_name);
1855 return 1;
1858 static int
1859 luaA_client_get_icon_name(lua_State *L, client_t *c)
1861 lua_pushstring(L, c->icon_name ? c->icon_name : c->alt_icon_name);
1862 return 1;
1865 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, class, lua_pushstring)
1866 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, instance, lua_pushstring)
1867 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, machine, lua_pushstring)
1868 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, role, lua_pushstring)
1869 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, transient_for, luaA_object_push)
1870 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, skip_taskbar, lua_pushboolean)
1871 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, window, lua_pushnumber)
1872 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, leader_window, lua_pushnumber)
1873 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, group_window, lua_pushnumber)
1874 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, pid, lua_pushnumber)
1875 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, hidden, lua_pushboolean)
1876 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, minimized, lua_pushboolean)
1877 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, fullscreen, lua_pushboolean)
1878 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, modal, lua_pushboolean)
1879 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, ontop, lua_pushboolean)
1880 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, urgent, lua_pushboolean)
1881 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, above, lua_pushboolean)
1882 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, below, lua_pushboolean)
1883 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, sticky, lua_pushboolean)
1884 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, size_hints_honor, lua_pushboolean)
1885 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, maximized_horizontal, lua_pushboolean)
1886 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, maximized_vertical, lua_pushboolean)
1887 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, opacity, lua_pushnumber)
1888 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, border_width, lua_pushnumber)
1889 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, border_color, luaA_pushxcolor)
1891 static int
1892 luaA_client_get_content(lua_State *L, client_t *c)
1894 xcb_image_t *ximage = xcb_image_get(globalconf.connection,
1895 c->window,
1896 0, 0,
1897 c->geometries.internal.width,
1898 c->geometries.internal.height,
1899 ~0, XCB_IMAGE_FORMAT_Z_PIXMAP);
1900 int retval = 0;
1902 if(ximage)
1904 if(ximage->bpp >= 24)
1906 uint32_t *data = p_alloca(uint32_t, ximage->width * ximage->height);
1908 for(int y = 0; y < ximage->height; y++)
1909 for(int x = 0; x < ximage->width; x++)
1911 data[y * ximage->width + x] = xcb_image_get_pixel(ximage, x, y);
1912 data[y * ximage->width + x] |= 0xff000000; /* set alpha to 0xff */
1915 retval = image_new_from_argb32(ximage->width, ximage->height, data);
1917 xcb_image_destroy(ximage);
1920 return retval;
1923 static int
1924 luaA_client_get_type(lua_State *L, client_t *c)
1926 switch(c->type)
1928 case WINDOW_TYPE_DESKTOP:
1929 lua_pushliteral(L, "desktop");
1930 break;
1931 case WINDOW_TYPE_DOCK:
1932 lua_pushliteral(L, "dock");
1933 break;
1934 case WINDOW_TYPE_SPLASH:
1935 lua_pushliteral(L, "splash");
1936 break;
1937 case WINDOW_TYPE_DIALOG:
1938 lua_pushliteral(L, "dialog");
1939 break;
1940 case WINDOW_TYPE_MENU:
1941 lua_pushliteral(L, "menu");
1942 break;
1943 case WINDOW_TYPE_TOOLBAR:
1944 lua_pushliteral(L, "toolbar");
1945 break;
1946 case WINDOW_TYPE_UTILITY:
1947 lua_pushliteral(L, "utility");
1948 break;
1949 case WINDOW_TYPE_DROPDOWN_MENU:
1950 lua_pushliteral(L, "dropdown_menu");
1951 break;
1952 case WINDOW_TYPE_POPUP_MENU:
1953 lua_pushliteral(L, "popup_menu");
1954 break;
1955 case WINDOW_TYPE_TOOLTIP:
1956 lua_pushliteral(L, "tooltip");
1957 break;
1958 case WINDOW_TYPE_NOTIFICATION:
1959 lua_pushliteral(L, "notification");
1960 break;
1961 case WINDOW_TYPE_COMBO:
1962 lua_pushliteral(L, "combo");
1963 break;
1964 case WINDOW_TYPE_DND:
1965 lua_pushliteral(L, "dnd");
1966 break;
1967 case WINDOW_TYPE_NORMAL:
1968 lua_pushliteral(L, "normal");
1969 break;
1971 return 1;
1974 static int
1975 luaA_client_get_screen(lua_State *L, client_t *c)
1977 if(!c->screen)
1978 return 0;
1979 lua_pushnumber(L, 1 + screen_array_indexof(&globalconf.screens, c->screen));
1980 return 1;
1983 static int
1984 luaA_client_get_icon(lua_State *L, client_t *c)
1986 return luaA_object_push_item(L, -2, c->icon);
1989 static int
1990 luaA_client_get_titlebar(lua_State *L, client_t *c)
1992 return luaA_object_push(L, c->titlebar);
1995 static int
1996 luaA_client_get_size_hints(lua_State *L, client_t *c)
1998 const char *u_or_p = NULL;
2000 lua_createtable(L, 0, 1);
2002 if(c->size_hints.flags & XCB_SIZE_HINT_US_POSITION)
2003 u_or_p = "user_position";
2004 else if(c->size_hints.flags & XCB_SIZE_HINT_P_POSITION)
2005 u_or_p = "program_position";
2007 if(u_or_p)
2009 lua_createtable(L, 0, 2);
2010 lua_pushnumber(L, c->size_hints.x);
2011 lua_setfield(L, -2, "x");
2012 lua_pushnumber(L, c->size_hints.y);
2013 lua_setfield(L, -2, "y");
2014 lua_setfield(L, -2, u_or_p);
2015 u_or_p = NULL;
2018 if(c->size_hints.flags & XCB_SIZE_HINT_US_SIZE)
2019 u_or_p = "user_size";
2020 else if(c->size_hints.flags & XCB_SIZE_HINT_P_SIZE)
2021 u_or_p = "program_size";
2023 if(u_or_p)
2025 lua_createtable(L, 0, 2);
2026 lua_pushnumber(L, c->size_hints.width);
2027 lua_setfield(L, -2, "width");
2028 lua_pushnumber(L, c->size_hints.height);
2029 lua_setfield(L, -2, "height");
2030 lua_setfield(L, -2, u_or_p);
2033 if(c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)
2035 lua_pushnumber(L, c->size_hints.min_width);
2036 lua_setfield(L, -2, "min_width");
2037 lua_pushnumber(L, c->size_hints.min_height);
2038 lua_setfield(L, -2, "min_height");
2041 if(c->size_hints.flags & XCB_SIZE_HINT_P_MAX_SIZE)
2043 lua_pushnumber(L, c->size_hints.max_width);
2044 lua_setfield(L, -2, "max_width");
2045 lua_pushnumber(L, c->size_hints.max_height);
2046 lua_setfield(L, -2, "max_height");
2049 if(c->size_hints.flags & XCB_SIZE_HINT_P_RESIZE_INC)
2051 lua_pushnumber(L, c->size_hints.width_inc);
2052 lua_setfield(L, -2, "width_inc");
2053 lua_pushnumber(L, c->size_hints.height_inc);
2054 lua_setfield(L, -2, "height_inc");
2057 if(c->size_hints.flags & XCB_SIZE_HINT_P_ASPECT)
2059 lua_pushnumber(L, c->size_hints.min_aspect_num);
2060 lua_setfield(L, -2, "min_aspect_num");
2061 lua_pushnumber(L, c->size_hints.min_aspect_den);
2062 lua_setfield(L, -2, "min_aspect_den");
2063 lua_pushnumber(L, c->size_hints.max_aspect_num);
2064 lua_setfield(L, -2, "max_aspect_num");
2065 lua_pushnumber(L, c->size_hints.max_aspect_den);
2066 lua_setfield(L, -2, "max_aspect_den");
2069 if(c->size_hints.flags & XCB_SIZE_HINT_BASE_SIZE)
2071 lua_pushnumber(L, c->size_hints.base_width);
2072 lua_setfield(L, -2, "base_width");
2073 lua_pushnumber(L, c->size_hints.base_height);
2074 lua_setfield(L, -2, "base_height");
2077 if(c->size_hints.flags & XCB_SIZE_HINT_P_WIN_GRAVITY)
2079 switch(c->size_hints.win_gravity)
2081 default:
2082 lua_pushliteral(L, "north_west");
2083 break;
2084 case XCB_GRAVITY_NORTH:
2085 lua_pushliteral(L, "north");
2086 break;
2087 case XCB_GRAVITY_NORTH_EAST:
2088 lua_pushliteral(L, "north_east");
2089 break;
2090 case XCB_GRAVITY_WEST:
2091 lua_pushliteral(L, "west");
2092 break;
2093 case XCB_GRAVITY_CENTER:
2094 lua_pushliteral(L, "center");
2095 break;
2096 case XCB_GRAVITY_EAST:
2097 lua_pushliteral(L, "east");
2098 break;
2099 case XCB_GRAVITY_SOUTH_WEST:
2100 lua_pushliteral(L, "south_west");
2101 break;
2102 case XCB_GRAVITY_SOUTH:
2103 lua_pushliteral(L, "south");
2104 break;
2105 case XCB_GRAVITY_SOUTH_EAST:
2106 lua_pushliteral(L, "south_east");
2107 break;
2108 case XCB_GRAVITY_STATIC:
2109 lua_pushliteral(L, "static");
2110 break;
2112 lua_setfield(L, -2, "win_gravity");
2115 return 1;
2118 /** Get or set mouse buttons bindings for a client.
2119 * \param L The Lua VM state.
2120 * \return The number of element pushed on stack.
2121 * \luastack
2122 * \lvalue A client.
2123 * \lparam An array of mouse button bindings objects, or nothing.
2124 * \return The array of mouse button bindings objects of this client.
2126 static int
2127 luaA_client_buttons(lua_State *L)
2129 client_t *client = luaA_client_checkudata(L, 1);
2130 button_array_t *buttons = &client->buttons;
2132 if(lua_gettop(L) == 2)
2134 luaA_button_array_set(L, 1, 2, buttons);
2135 luaA_object_emit_signal(L, 1, "property::buttons", 0);
2136 window_buttons_grab(client->window, &client->buttons);
2139 return luaA_button_array_get(L, 1, buttons);
2142 /** Get or set keys bindings for a client.
2143 * \param L The Lua VM state.
2144 * \return The number of element pushed on stack.
2145 * \luastack
2146 * \lvalue A client.
2147 * \lparam An array of key bindings objects, or nothing.
2148 * \return The array of key bindings objects of this client.
2150 static int
2151 luaA_client_keys(lua_State *L)
2153 client_t *c = luaA_client_checkudata(L, 1);
2154 key_array_t *keys = &c->keys;
2156 if(lua_gettop(L) == 2)
2158 luaA_key_array_set(L, 1, 2, keys);
2159 luaA_object_emit_signal(L, 1, "property::keys", 0);
2160 xcb_ungrab_key(globalconf.connection, XCB_GRAB_ANY, c->window, XCB_BUTTON_MASK_ANY);
2161 window_grabkeys(c->window, keys);
2164 return luaA_key_array_get(L, 1, keys);
2167 /* Client module.
2168 * \param L The Lua VM state.
2169 * \return The number of pushed elements.
2171 static int
2172 luaA_client_module_index(lua_State *L)
2174 size_t len;
2175 const char *buf = luaL_checklstring(L, 2, &len);
2177 switch(a_tokenize(buf, len))
2179 case A_TK_FOCUS:
2180 return luaA_object_push(globalconf.L, globalconf.screen_focus->client_focus);
2181 break;
2182 default:
2183 return 0;
2187 /* Client module new index.
2188 * \param L The Lua VM state.
2189 * \return The number of pushed elements.
2191 static int
2192 luaA_client_module_newindex(lua_State *L)
2194 size_t len;
2195 const char *buf = luaL_checklstring(L, 2, &len);
2196 client_t *c;
2198 switch(a_tokenize(buf, len))
2200 case A_TK_FOCUS:
2201 c = luaA_client_checkudata(L, 3);
2202 client_focus(c);
2203 break;
2204 default:
2205 break;
2208 return 0;
2211 void
2212 client_class_setup(lua_State *L)
2214 static const struct luaL_reg client_methods[] =
2216 LUA_CLASS_METHODS(client)
2217 { "get", luaA_client_get },
2218 { "__index", luaA_client_module_index },
2219 { "__newindex", luaA_client_module_newindex },
2220 { NULL, NULL }
2223 static const struct luaL_reg client_meta[] =
2225 LUA_OBJECT_META(client)
2226 LUA_CLASS_META
2227 { "buttons", luaA_client_buttons },
2228 { "keys", luaA_client_keys },
2229 { "isvisible", luaA_client_isvisible },
2230 { "geometry", luaA_client_geometry },
2231 { "struts", luaA_client_struts },
2232 { "tags", luaA_client_tags },
2233 { "kill", luaA_client_kill },
2234 { "swap", luaA_client_swap },
2235 { "raise", luaA_client_raise },
2236 { "lower", luaA_client_lower },
2237 { "redraw", luaA_client_redraw },
2238 { "unmanage", luaA_client_unmanage },
2239 { "__gc", luaA_client_gc },
2240 { NULL, NULL }
2243 luaA_class_setup(L, &client_class, "client", (lua_class_allocator_t) client_new,
2244 luaA_class_index_miss_property, luaA_class_newindex_miss_property,
2245 client_methods, client_meta);
2246 luaA_class_add_property(&client_class, A_TK_NAME,
2247 NULL,
2248 (lua_class_propfunc_t) luaA_client_get_name,
2249 NULL);
2250 luaA_class_add_property(&client_class, A_TK_TRANSIENT_FOR,
2251 NULL,
2252 (lua_class_propfunc_t) luaA_client_get_transient_for,
2253 NULL);
2254 luaA_class_add_property(&client_class, A_TK_SKIP_TASKBAR,
2255 (lua_class_propfunc_t) luaA_client_set_skip_taskbar,
2256 (lua_class_propfunc_t) luaA_client_get_skip_taskbar,
2257 (lua_class_propfunc_t) luaA_client_set_skip_taskbar);
2258 luaA_class_add_property(&client_class, A_TK_CONTENT,
2259 NULL,
2260 (lua_class_propfunc_t) luaA_client_get_content,
2261 NULL);
2262 luaA_class_add_property(&client_class, A_TK_TYPE,
2263 NULL,
2264 (lua_class_propfunc_t) luaA_client_get_type,
2265 NULL);
2266 luaA_class_add_property(&client_class, A_TK_CLASS,
2267 NULL,
2268 (lua_class_propfunc_t) luaA_client_get_class,
2269 NULL);
2270 luaA_class_add_property(&client_class, A_TK_INSTANCE,
2271 NULL,
2272 (lua_class_propfunc_t) luaA_client_get_instance,
2273 NULL);
2274 luaA_class_add_property(&client_class, A_TK_ROLE,
2275 NULL,
2276 (lua_class_propfunc_t) luaA_client_get_role,
2277 NULL);
2278 luaA_class_add_property(&client_class, A_TK_PID,
2279 NULL,
2280 (lua_class_propfunc_t) luaA_client_get_pid,
2281 NULL);
2282 luaA_class_add_property(&client_class, A_TK_WINDOW,
2283 NULL,
2284 (lua_class_propfunc_t) luaA_client_get_window,
2285 NULL);
2286 luaA_class_add_property(&client_class, A_TK_LEADER_WINDOW,
2287 NULL,
2288 (lua_class_propfunc_t) luaA_client_get_leader_window,
2289 NULL);
2290 luaA_class_add_property(&client_class, A_TK_MACHINE,
2291 NULL,
2292 (lua_class_propfunc_t) luaA_client_get_machine,
2293 NULL);
2294 luaA_class_add_property(&client_class, A_TK_ICON_NAME,
2295 NULL,
2296 (lua_class_propfunc_t) luaA_client_get_icon_name,
2297 NULL);
2298 luaA_class_add_property(&client_class, A_TK_SCREEN,
2299 NULL,
2300 (lua_class_propfunc_t) luaA_client_get_screen,
2301 (lua_class_propfunc_t) luaA_client_set_screen);
2302 luaA_class_add_property(&client_class, A_TK_HIDDEN,
2303 (lua_class_propfunc_t) luaA_client_set_hidden,
2304 (lua_class_propfunc_t) luaA_client_get_hidden,
2305 (lua_class_propfunc_t) luaA_client_set_hidden);
2306 luaA_class_add_property(&client_class, A_TK_MINIMIZED,
2307 (lua_class_propfunc_t) luaA_client_set_minimized,
2308 (lua_class_propfunc_t) luaA_client_get_minimized,
2309 (lua_class_propfunc_t) luaA_client_set_minimized);
2310 luaA_class_add_property(&client_class, A_TK_FULLSCREEN,
2311 (lua_class_propfunc_t) luaA_client_set_fullscreen,
2312 (lua_class_propfunc_t) luaA_client_get_fullscreen,
2313 (lua_class_propfunc_t) luaA_client_set_fullscreen);
2314 luaA_class_add_property(&client_class, A_TK_MODAL,
2315 (lua_class_propfunc_t) luaA_client_set_modal,
2316 (lua_class_propfunc_t) luaA_client_get_modal,
2317 (lua_class_propfunc_t) luaA_client_set_modal);
2318 luaA_class_add_property(&client_class, A_TK_GROUP_WINDOW,
2319 NULL,
2320 (lua_class_propfunc_t) luaA_client_get_group_window,
2321 NULL);
2322 luaA_class_add_property(&client_class, A_TK_MAXIMIZED_HORIZONTAL,
2323 (lua_class_propfunc_t) luaA_client_set_maximized_horizontal,
2324 (lua_class_propfunc_t) luaA_client_get_maximized_horizontal,
2325 (lua_class_propfunc_t) luaA_client_set_maximized_horizontal);
2326 luaA_class_add_property(&client_class, A_TK_MAXIMIZED_VERTICAL,
2327 (lua_class_propfunc_t) luaA_client_set_maximized_vertical,
2328 (lua_class_propfunc_t) luaA_client_get_maximized_vertical,
2329 (lua_class_propfunc_t) luaA_client_set_maximized_vertical);
2330 luaA_class_add_property(&client_class, A_TK_ICON,
2331 (lua_class_propfunc_t) luaA_client_set_icon,
2332 (lua_class_propfunc_t) luaA_client_get_icon,
2333 (lua_class_propfunc_t) luaA_client_set_icon);
2334 luaA_class_add_property(&client_class, A_TK_OPACITY,
2335 (lua_class_propfunc_t) luaA_client_set_opacity,
2336 (lua_class_propfunc_t) luaA_client_get_opacity,
2337 (lua_class_propfunc_t) luaA_client_set_opacity);
2338 luaA_class_add_property(&client_class, A_TK_ONTOP,
2339 (lua_class_propfunc_t) luaA_client_set_ontop,
2340 (lua_class_propfunc_t) luaA_client_get_ontop,
2341 (lua_class_propfunc_t) luaA_client_set_ontop);
2342 luaA_class_add_property(&client_class, A_TK_ABOVE,
2343 (lua_class_propfunc_t) luaA_client_set_above,
2344 (lua_class_propfunc_t) luaA_client_get_above,
2345 (lua_class_propfunc_t) luaA_client_set_above);
2346 luaA_class_add_property(&client_class, A_TK_BELOW,
2347 (lua_class_propfunc_t) luaA_client_set_below,
2348 (lua_class_propfunc_t) luaA_client_get_below,
2349 (lua_class_propfunc_t) luaA_client_set_below);
2350 luaA_class_add_property(&client_class, A_TK_STICKY,
2351 (lua_class_propfunc_t) luaA_client_set_sticky,
2352 (lua_class_propfunc_t) luaA_client_get_sticky,
2353 (lua_class_propfunc_t) luaA_client_set_sticky);
2354 luaA_class_add_property(&client_class, A_TK_SIZE_HINTS_HONOR,
2355 (lua_class_propfunc_t) luaA_client_set_size_hints_honor,
2356 (lua_class_propfunc_t) luaA_client_get_size_hints_honor,
2357 (lua_class_propfunc_t) luaA_client_set_size_hints_honor);
2358 luaA_class_add_property(&client_class, A_TK_BORDER_WIDTH,
2359 (lua_class_propfunc_t) luaA_client_set_border_width,
2360 (lua_class_propfunc_t) luaA_client_get_border_width,
2361 (lua_class_propfunc_t) luaA_client_set_border_width);
2362 luaA_class_add_property(&client_class, A_TK_BORDER_COLOR,
2363 (lua_class_propfunc_t) luaA_client_set_border_color,
2364 (lua_class_propfunc_t) luaA_client_get_border_color,
2365 (lua_class_propfunc_t) luaA_client_set_border_color);
2366 luaA_class_add_property(&client_class, A_TK_TITLEBAR,
2367 (lua_class_propfunc_t) luaA_client_set_titlebar,
2368 (lua_class_propfunc_t) luaA_client_get_titlebar,
2369 (lua_class_propfunc_t) luaA_client_set_titlebar);
2370 luaA_class_add_property(&client_class, A_TK_URGENT,
2371 (lua_class_propfunc_t) luaA_client_set_urgent,
2372 (lua_class_propfunc_t) luaA_client_get_urgent,
2373 (lua_class_propfunc_t) luaA_client_set_urgent);
2374 luaA_class_add_property(&client_class, A_TK_SIZE_HINTS,
2375 NULL,
2376 (lua_class_propfunc_t) luaA_client_get_size_hints,
2377 NULL);
2380 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80