luaobject: change function push method in signal emit
[awesome.git] / client.c
blob1fd1074d0edb205fd83d2e05290a979bbaacb649
1 /*
2 * client.c - client management
4 * Copyright © 2007-2009 Julien Danjou <julien@danjou.info>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <xcb/xcb_atom.h>
23 #include <xcb/xcb_image.h>
25 #include "tag.h"
26 #include "ewmh.h"
27 #include "screen.h"
28 #include "titlebar.h"
29 #include "systray.h"
30 #include "property.h"
31 #include "spawn.h"
32 #include "luaa.h"
33 #include "common/atoms.h"
34 #include "common/xutil.h"
36 client_t *
37 luaA_client_checkudata(lua_State *L, int ud)
39 client_t *c = luaA_checkudata(L, ud, &client_class);
40 if(c->invalid)
41 luaL_error(L, "client is invalid\n");
42 return c;
45 /** Collect a client.
46 * \param L The Lua VM state.
47 * \return The number of element pushed on stack.
49 static int
50 luaA_client_gc(lua_State *L)
52 client_t *c = luaA_checkudata(L, 1, &client_class);
53 button_array_wipe(&c->buttons);
54 key_array_wipe(&c->keys);
55 xcb_get_wm_protocols_reply_wipe(&c->protocols);
56 p_delete(&c->class);
57 p_delete(&c->startup_id);
58 p_delete(&c->instance);
59 p_delete(&c->icon_name);
60 p_delete(&c->name);
61 return luaA_object_gc(L);
64 /** Change the client opacity.
65 * \param L The Lua VM state.
66 * \param cidx The client index.
67 * \param opacity The opacity.
69 void
70 client_set_opacity(lua_State *L, int cidx, double opacity)
72 client_t *c = luaA_client_checkudata(L, cidx);
74 if(c->opacity != opacity)
76 c->opacity = opacity;
77 window_opacity_set(c->window, opacity);
78 luaA_object_emit_signal(L, cidx, "property::opacity", 0);
82 /** Change the clients urgency flag.
83 * \param L The Lua VM state.
84 * \param cidx The client index on the stack.
85 * \param urgent The new flag state.
87 void
88 client_set_urgent(lua_State *L, int cidx, bool urgent)
90 client_t *c = luaA_client_checkudata(L, cidx);
92 if(c->urgent != urgent)
94 xcb_get_property_cookie_t hints =
95 xcb_get_wm_hints_unchecked(globalconf.connection, c->window);
97 c->urgent = urgent;
98 ewmh_client_update_hints(c);
100 /* update ICCCM hints */
101 xcb_wm_hints_t wmh;
102 xcb_get_wm_hints_reply(globalconf.connection, hints, &wmh, NULL);
104 if(urgent)
105 wmh.flags |= XCB_WM_HINT_X_URGENCY;
106 else
107 wmh.flags &= ~XCB_WM_HINT_X_URGENCY;
109 xcb_set_wm_hints(globalconf.connection, c->window, &wmh);
111 hook_property(c, "urgent");
112 luaA_object_emit_signal(L, cidx, "property::urgent", 0);
116 void
117 client_set_group_window(lua_State *L, int cidx, xcb_window_t window)
119 client_t *c = luaA_client_checkudata(L, cidx);
121 if(c->group_window != window)
123 c->group_window = window;
124 luaA_object_emit_signal(L, cidx, "property::group_window", 0);
128 void
129 client_set_type(lua_State *L, int cidx, window_type_t type)
131 client_t *c = luaA_client_checkudata(L, cidx);
133 if(c->type != type)
135 c->type = type;
136 luaA_object_emit_signal(L, cidx, "property::type", 0);
140 void
141 client_set_pid(lua_State *L, int cidx, uint32_t pid)
143 client_t *c = luaA_client_checkudata(L, cidx);
145 if(c->pid != pid)
147 c->pid = pid;
148 luaA_object_emit_signal(L, cidx, "property::pid", 0);
152 void
153 client_set_icon_name(lua_State *L, int cidx, const char *icon_name)
155 client_t *c = luaA_client_checkudata(L, cidx);
156 p_delete(&c->icon_name);
157 c->icon_name = a_strdup(icon_name);
158 luaA_object_emit_signal(L, cidx, "property::icon_name", 0);
159 hook_property(c, "icon_name");
162 void
163 client_set_role(lua_State *L, int cidx, const char *role)
165 client_t *c = luaA_client_checkudata(L, cidx);
166 p_delete(&c->role);
167 luaA_object_emit_signal(L, cidx, "property::role", 0);
168 c->role = a_strdup(role);
171 void
172 client_set_machine(lua_State *L, int cidx, const char *machine)
174 client_t *c = luaA_client_checkudata(L, cidx);
175 p_delete(&c->machine);
176 c->machine = a_strdup(machine);
177 luaA_object_emit_signal(L, cidx, "property::machine", 0);
180 void
181 client_set_class_instance(lua_State *L, int cidx, const char *class, const char *instance)
183 client_t *c = luaA_client_checkudata(L, cidx);
184 p_delete(&c->class);
185 p_delete(&c->instance);
186 c->class = a_strdup(class);
187 c->instance = a_strdup(instance);
188 luaA_object_emit_signal(L, cidx, "property::class", 0);
189 luaA_object_emit_signal(L, cidx, "property::instance", 0);
192 void
193 client_set_transient_for(lua_State *L, int cidx, client_t *transient_for)
195 client_t *c = luaA_client_checkudata(L, cidx);
197 if(c->transient_for != transient_for)
199 c->transient_for = transient_for;
200 luaA_object_emit_signal(L, cidx, "property::transient_for", 0);
204 void
205 client_set_name(lua_State *L, int cidx, const char *name)
207 client_t *c = luaA_client_checkudata(L, cidx);
208 p_delete(&c->name);
209 c->name = a_strdup(name);
210 hook_property(c, "name");
211 luaA_object_emit_signal(L, cidx, "property::name", 0);
214 /** Returns true if a client is tagged
215 * with one of the tags of the specified screen.
216 * \param c The client to check.
217 * \param screen Virtual screen.
218 * \return true if the client is visible, false otherwise.
220 bool
221 client_maybevisible(client_t *c, screen_t *screen)
223 if(c->screen == screen)
225 if(c->sticky || c->type == WINDOW_TYPE_DESKTOP)
226 return true;
228 foreach(tag, screen->tags)
229 if(tag_get_selected(*tag) && is_client_tagged(c, *tag))
230 return true;
232 return false;
235 /** Get a client by its window.
236 * \param w The client window to find.
237 * \return A client pointer if found, NULL otherwise.
239 client_t *
240 client_getbywin(xcb_window_t w)
242 foreach(c, globalconf.clients)
243 if((*c)->window == w)
244 return *c;
246 return NULL;
249 /** Record that a client lost focus.
250 * \param c Client being unfocused
252 void
253 client_unfocus_update(client_t *c)
255 globalconf.screens.tab[c->phys_screen].client_focus = NULL;
256 ewmh_update_net_active_window(c->phys_screen);
258 /* Call hook */
259 if(globalconf.hooks.unfocus != LUA_REFNIL)
261 luaA_object_push(globalconf.L, c);
262 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.unfocus, 1, 0);
265 luaA_object_push(globalconf.L, c);
266 luaA_class_emit_signal(globalconf.L, &client_class, "unfocus", 1);
269 /** Unfocus a client.
270 * \param c The client.
272 void
273 client_unfocus(client_t *c)
276 xcb_window_t root_win = xutil_screen_get(globalconf.connection, c->phys_screen)->root;
277 /* Set focus on root window, so no events leak to the current window.
278 * This kind of inlines client_set_focus(), but a root window will never have
279 * the WM_TAKE_FOCUS protocol.
281 xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_PARENT,
282 root_win, XCB_CURRENT_TIME);
284 client_unfocus_update(c);
287 /** Check if client supports protocol a protocole in WM_PROTOCOL.
288 * \param c The client.
289 * \param atom The protocol atom to check for.
290 * \return True if client has the atom in protocol, false otherwise.
292 bool
293 client_hasproto(client_t *c, xcb_atom_t atom)
295 uint32_t i;
297 for(i = 0; i < c->protocols.atoms_len; i++)
298 if(c->protocols.atoms[i] == atom)
299 return true;
300 return false;
303 /** Sets focus on window - using xcb_set_input_focus or WM_TAKE_FOCUS
304 * \param c Client that should get focus
305 * \param set_input_focus Should we call xcb_set_input_focus
307 void
308 client_set_focus(client_t *c, bool set_input_focus)
310 bool takefocus = client_hasproto(c, WM_TAKE_FOCUS);
311 if(set_input_focus)
312 xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_PARENT,
313 c->window, XCB_CURRENT_TIME);
314 if(takefocus)
315 window_takefocus(c->window);
318 /** Ban client and move it out of the viewport.
319 * \param c The client.
321 void
322 client_ban(client_t *c)
324 if(!c->isbanned)
326 xcb_unmap_window(globalconf.connection, c->window);
328 c->isbanned = true;
330 if(globalconf.screens.tab[c->phys_screen].prev_client_focus == c)
331 globalconf.screens.tab[c->phys_screen].prev_client_focus = NULL;
333 /* Wait until the last moment to take away the focus from the window. */
334 if(globalconf.screens.tab[c->phys_screen].client_focus == c)
335 client_unfocus(c);
339 /** This is part of The Bob Marley Algorithmm: we ignore enter and leave window
340 * in certain cases, like map/unmap or move, so we don't get spurious events.
342 void
343 client_ignore_enterleave_events(void)
345 foreach(c, globalconf.clients)
346 xcb_change_window_attributes(globalconf.connection,
347 (*c)->window,
348 XCB_CW_EVENT_MASK,
349 (const uint32_t []) { CLIENT_SELECT_INPUT_EVENT_MASK & ~(XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW) });
352 void
353 client_restore_enterleave_events(void)
355 foreach(c, globalconf.clients)
356 xcb_change_window_attributes(globalconf.connection,
357 (*c)->window,
358 XCB_CW_EVENT_MASK,
359 (const uint32_t []) { CLIENT_SELECT_INPUT_EVENT_MASK });
362 /** Record that a client got focus.
363 * \param c The client.
365 void
366 client_focus_update(client_t *c)
368 if(!client_maybevisible(c, c->screen))
370 /* Focus previously focused client */
371 client_focus(globalconf.screen_focus->prev_client_focus);
372 return;
375 if(globalconf.screen_focus
376 && globalconf.screen_focus->client_focus)
378 if (globalconf.screen_focus->client_focus != c)
379 client_unfocus_update(globalconf.screen_focus->client_focus);
380 else
381 /* Already focused */
382 return;
384 luaA_object_push(globalconf.L, c);
385 client_set_minimized(globalconf.L, -1, false);
387 /* unban the client before focusing for consistency */
388 client_unban(c);
390 globalconf.screen_focus = &globalconf.screens.tab[c->phys_screen];
391 globalconf.screen_focus->prev_client_focus = c;
392 globalconf.screen_focus->client_focus = c;
394 /* according to EWMH, we have to remove the urgent state from a client */
395 client_set_urgent(globalconf.L, -1, false);
397 ewmh_update_net_active_window(c->phys_screen);
399 /* execute hook */
400 if(globalconf.hooks.focus != LUA_REFNIL)
402 luaA_object_push(globalconf.L, c);
403 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.focus, 1, 0);
406 luaA_object_push(globalconf.L, c);
407 luaA_class_emit_signal(globalconf.L, &client_class, "focus", 1);
410 /** Give focus to client, or to first client if client is NULL.
411 * \param c The client.
413 void
414 client_focus(client_t *c)
416 /* We have to set focus on first client */
417 if(!c && globalconf.clients.len && !(c = globalconf.clients.tab[0]))
418 return;
420 if(!client_maybevisible(c, c->screen))
421 return;
423 if (!c->nofocus)
424 client_focus_update(c);
426 client_set_focus(c, !c->nofocus);
429 /** Stack a window below.
430 * \param c The client.
431 * \param previous The previous window on the stack.
432 * \return The next-previous!
434 static xcb_window_t
435 client_stack_above(client_t *c, xcb_window_t previous)
437 uint32_t config_win_vals[2];
439 config_win_vals[0] = previous;
440 config_win_vals[1] = XCB_STACK_MODE_ABOVE;
442 xcb_configure_window(globalconf.connection, c->window,
443 XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
444 config_win_vals);
446 config_win_vals[0] = c->window;
448 if(c->titlebar)
450 xcb_configure_window(globalconf.connection,
451 c->titlebar->window,
452 XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
453 config_win_vals);
454 previous = c->titlebar->window;
456 else
457 previous = c->window;
459 /* stack transient window on top of their parents */
460 foreach(node, globalconf.stack)
461 if((*node)->transient_for == c)
462 previous = client_stack_above(*node, previous);
464 return previous;
467 /** Stacking layout layers */
468 typedef enum
470 /** This one is a special layer */
471 LAYER_IGNORE,
472 LAYER_DESKTOP,
473 LAYER_BELOW,
474 LAYER_NORMAL,
475 LAYER_ABOVE,
476 LAYER_FULLSCREEN,
477 LAYER_ONTOP,
478 /** This one only used for counting and is not a real layer */
479 LAYER_COUNT
480 } layer_t;
482 /** Get the real layer of a client according to its attribute (fullscreen, …)
483 * \param c The client.
484 * \return The real layer.
486 static layer_t
487 client_layer_translator(client_t *c)
489 /* first deal with user set attributes */
490 if(c->ontop)
491 return LAYER_ONTOP;
492 else if(c->fullscreen)
493 return LAYER_FULLSCREEN;
494 else if(c->above)
495 return LAYER_ABOVE;
496 else if(c->below)
497 return LAYER_BELOW;
499 /* check for transient attr */
500 if(c->transient_for)
501 return LAYER_IGNORE;
503 /* then deal with windows type */
504 switch(c->type)
506 case WINDOW_TYPE_DESKTOP:
507 return LAYER_DESKTOP;
508 default:
509 break;
512 return LAYER_NORMAL;
515 /** Restack clients.
516 * \todo It might be worth stopping to restack everyone and only stack `c'
517 * relatively to the first matching in the list.
519 void
520 client_stack_refresh()
522 uint32_t config_win_vals[2];
523 layer_t layer;
525 if (!globalconf.client_need_stack_refresh)
526 return;
527 globalconf.client_need_stack_refresh = false;
529 config_win_vals[0] = XCB_NONE;
530 config_win_vals[1] = XCB_STACK_MODE_ABOVE;
532 /* stack desktop windows */
533 for(layer = LAYER_DESKTOP; layer < LAYER_BELOW; layer++)
534 foreach(node, globalconf.stack)
535 if(client_layer_translator(*node) == layer)
536 config_win_vals[0] = client_stack_above(*node,
537 config_win_vals[0]);
539 /* first stack not ontop wibox window */
540 foreach(_sb, globalconf.wiboxes)
542 wibox_t *sb = *_sb;
543 if(!sb->ontop)
545 xcb_configure_window(globalconf.connection,
546 sb->window,
547 XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
548 config_win_vals);
549 config_win_vals[0] = sb->window;
553 /* then stack clients */
554 for(layer = LAYER_BELOW; layer < LAYER_COUNT; layer++)
555 foreach(node, globalconf.stack)
556 if(client_layer_translator(*node) == layer)
557 config_win_vals[0] = client_stack_above(*node,
558 config_win_vals[0]);
560 /* then stack ontop wibox window */
561 foreach(_sb, globalconf.wiboxes)
563 wibox_t *sb = *_sb;
564 if(sb->ontop)
566 xcb_configure_window(globalconf.connection,
567 sb->window,
568 XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
569 config_win_vals);
570 config_win_vals[0] = sb->window;
575 /** Manage a new client.
576 * \param w The window.
577 * \param wgeom Window geometry.
578 * \param phys_screen Physical screen number.
579 * \param startup True if we are managing at startup time.
581 void
582 client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen, bool startup)
584 screen_t *screen;
585 const uint32_t select_input_val[] = { CLIENT_SELECT_INPUT_EVENT_MASK };
587 if(systray_iskdedockapp(w))
589 systray_request_handle(w, phys_screen, NULL);
590 return;
593 xcb_change_window_attributes(globalconf.connection, w, XCB_CW_EVENT_MASK, select_input_val);
595 client_t *c = client_new(globalconf.L);
596 /* Push client in client list */
597 client_array_push(&globalconf.clients, luaA_object_ref(globalconf.L, -1));
600 screen = c->screen = screen_getbycoord(&globalconf.screens.tab[phys_screen],
601 wgeom->x, wgeom->y);
603 c->phys_screen = phys_screen;
605 /* consider the window banned */
606 c->isbanned = true;
608 /* Initial values */
609 c->window = w;
610 c->geometry.x = wgeom->x;
611 c->geometry.y = wgeom->y;
612 /* Border will be added later. */
613 c->geometry.width = wgeom->width;
614 c->geometry.height = wgeom->height;
615 /* Also set internal geometry (client_ban() needs it). */
616 c->geometries.internal.x = wgeom->x;
617 c->geometries.internal.y = wgeom->y;
618 c->geometries.internal.width = wgeom->width;
619 c->geometries.internal.height = wgeom->height;
621 /* Push client */
622 luaA_object_push(globalconf.L, c);
623 client_set_border_width(globalconf.L, -1, wgeom->border_width);
624 lua_pop(globalconf.L, 1);
626 /* we honor size hints by default */
627 c->size_hints_honor = true;
629 /* update hints */
630 property_update_wm_normal_hints(c, NULL);
631 property_update_wm_hints(c, NULL);
632 property_update_wm_transient_for(c, NULL);
633 property_update_wm_client_leader(c, NULL);
634 property_update_wm_client_machine(c);
635 property_update_wm_window_role(c);
636 property_update_net_wm_pid(c, NULL);
637 property_update_net_wm_icon(c, NULL);
639 /* get opacity */
640 c->opacity = window_opacity_get(c->window);
642 /* Then check clients hints */
643 ewmh_client_check_hints(c);
645 /* move client to screen, but do not tag it */
646 screen_client_moveto(c, screen, false, true);
648 /* Push client in stack */
649 client_raise(c);
651 /* update window title */
652 property_update_wm_name(c);
653 property_update_wm_icon_name(c);
654 property_update_wm_class(c, NULL);
655 property_update_wm_protocols(c);
657 xutil_text_prop_get(globalconf.connection, c->window, _NET_STARTUP_ID, &c->startup_id, NULL);
659 /* update strut */
660 ewmh_process_client_strut(c, NULL);
662 ewmh_update_net_client_list(c->phys_screen);
664 /* Always stay in NORMAL_STATE. Even though iconified seems more
665 * appropriate sometimes. The only possible loss is that clients not using
666 * visibility events may continue to proces data (when banned).
667 * Without any exposes or other events the cost should be fairly limited though.
669 * Some clients may expect the window to be unmapped when STATE_ICONIFIED.
670 * Two conflicting parts of the ICCCM v2.0 (section 4.1.4):
672 * "Normal -> Iconic - The client should send a ClientMessage event as described later in this section."
673 * (note no explicit mention of unmapping, while Normal->Widthdrawn does mention that)
675 * "Once a client's window has left the Withdrawn state, the window will be mapped
676 * if it is in the Normal state and the window will be unmapped if it is in the Iconic state."
678 * At this stage it's just safer to keep it in normal state and avoid confusion.
680 window_state_set(c->window, XCB_WM_STATE_NORMAL);
682 if(!startup)
683 spawn_start_notify(c);
685 /* Call hook to notify list change */
686 if(globalconf.hooks.clients != LUA_REFNIL)
687 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.clients, 0, 0);
689 luaA_class_emit_signal(globalconf.L, &client_class, "list", 0);
691 /* call hook */
692 if(globalconf.hooks.manage != LUA_REFNIL)
694 luaA_object_push(globalconf.L, c);
695 lua_pushboolean(globalconf.L, startup);
696 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.manage, 2, 0);
699 luaA_object_push(globalconf.L, c);
700 lua_pushboolean(globalconf.L, startup);
701 luaA_class_emit_signal(globalconf.L, &client_class, "manage", 2);
704 /** Compute client geometry with respect to its geometry hints.
705 * \param c The client.
706 * \param geometry The geometry that the client might receive.
707 * \return The geometry the client must take respecting its hints.
709 area_t
710 client_geometry_hints(client_t *c, area_t geometry)
712 int32_t basew, baseh, minw, minh;
714 /* base size is substituted with min size if not specified */
715 if(c->size_hints.flags & XCB_SIZE_HINT_P_SIZE)
717 basew = c->size_hints.base_width;
718 baseh = c->size_hints.base_height;
720 else if(c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)
722 basew = c->size_hints.min_width;
723 baseh = c->size_hints.min_height;
725 else
726 basew = baseh = 0;
728 /* min size is substituted with base size if not specified */
729 if(c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)
731 minw = c->size_hints.min_width;
732 minh = c->size_hints.min_height;
734 else if(c->size_hints.flags & XCB_SIZE_HINT_P_SIZE)
736 minw = c->size_hints.base_width;
737 minh = c->size_hints.base_height;
739 else
740 minw = minh = 0;
742 if(c->size_hints.flags & XCB_SIZE_HINT_P_ASPECT
743 && c->size_hints.min_aspect_num > 0
744 && c->size_hints.min_aspect_den > 0
745 && geometry.height - baseh > 0
746 && geometry.width - basew > 0)
748 double dx = (double) (geometry.width - basew);
749 double dy = (double) (geometry.height - baseh);
750 double min = (double) c->size_hints.min_aspect_num / (double) c->size_hints.min_aspect_den;
751 double max = (double) c->size_hints.max_aspect_num / (double) c->size_hints.min_aspect_den;
752 double ratio = dx / dy;
753 if(max > 0 && min > 0 && ratio > 0)
755 if(ratio < min)
757 dy = (dx * min + dy) / (min * min + 1);
758 dx = dy * min;
759 geometry.width = (int) dx + basew;
760 geometry.height = (int) dy + baseh;
762 else if(ratio > max)
764 dy = (dx * min + dy) / (max * max + 1);
765 dx = dy * min;
766 geometry.width = (int) dx + basew;
767 geometry.height = (int) dy + baseh;
772 if(minw)
773 geometry.width = MAX(geometry.width, minw);
774 if(minh)
775 geometry.height = MAX(geometry.height, minh);
777 if(c->size_hints.flags & XCB_SIZE_HINT_P_MAX_SIZE)
779 if(c->size_hints.max_width)
780 geometry.width = MIN(geometry.width, c->size_hints.max_width);
781 if(c->size_hints.max_height)
782 geometry.height = MIN(geometry.height, c->size_hints.max_height);
785 if(c->size_hints.flags & (XCB_SIZE_HINT_P_RESIZE_INC | XCB_SIZE_HINT_BASE_SIZE)
786 && c->size_hints.width_inc && c->size_hints.height_inc)
788 uint16_t t1 = geometry.width, t2 = geometry.height;
789 unsigned_subtract(t1, basew);
790 unsigned_subtract(t2, baseh);
791 geometry.width -= t1 % c->size_hints.width_inc;
792 geometry.height -= t2 % c->size_hints.height_inc;
795 return geometry;
798 /** Resize client window.
799 * The sizse given as parameters are with titlebar and borders!
800 * \param c Client to resize.
801 * \param geometry New window geometry.
802 * \param hints Use size hints.
803 * \return true if an actual resize occurred.
805 bool
806 client_resize(client_t *c, area_t geometry, bool hints)
808 area_t geometry_internal;
809 area_t area;
811 /* offscreen appearance fixes */
812 area = display_area_get(c->phys_screen);
814 if(geometry.x > area.width)
815 geometry.x = area.width - geometry.width;
816 if(geometry.y > area.height)
817 geometry.y = area.height - geometry.height;
818 if(geometry.x + geometry.width < 0)
819 geometry.x = 0;
820 if(geometry.y + geometry.height < 0)
821 geometry.y = 0;
823 /* Real client geometry, please keep it contained to C code at the very least. */
824 geometry_internal = titlebar_geometry_remove(c->titlebar, c->border_width, geometry);
826 if(hints)
827 geometry_internal = client_geometry_hints(c, geometry_internal);
829 if(geometry_internal.width == 0 || geometry_internal.height == 0)
830 return false;
832 /* Also let client hints propegate to the "official" geometry. */
833 geometry = titlebar_geometry_add(c->titlebar, c->border_width, geometry_internal);
835 if(c->geometries.internal.x != geometry_internal.x
836 || c->geometries.internal.y != geometry_internal.y
837 || c->geometries.internal.width != geometry_internal.width
838 || c->geometries.internal.height != geometry_internal.height)
840 screen_t *new_screen = screen_getbycoord(c->screen,
841 geometry_internal.x, geometry_internal.y);
843 /* Values to configure a window is an array where values are
844 * stored according to 'value_mask' */
845 uint32_t values[4];
847 c->geometries.internal.x = values[0] = geometry_internal.x;
848 c->geometries.internal.y = values[1] = geometry_internal.y;
849 c->geometries.internal.width = values[2] = geometry_internal.width;
850 c->geometries.internal.height = values[3] = geometry_internal.height;
852 /* Also store geometry including border and titlebar. */
853 c->geometry = geometry;
855 titlebar_update_geometry(c);
857 /* Ignore all spurious enter/leave notify events */
858 client_ignore_enterleave_events();
860 xcb_configure_window(globalconf.connection, c->window,
861 XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y
862 | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
863 values);
865 client_restore_enterleave_events();
867 screen_client_moveto(c, new_screen, true, false);
869 /* execute hook */
870 hook_property(c, "geometry");
872 return true;
875 return false;
878 /** Set a client minimized, or not.
879 * \param L The Lua VM state.
880 * \param cidx The client index.
881 * \param s Set or not the client minimized.
883 void
884 client_set_minimized(lua_State *L, int cidx, bool s)
886 client_t *c = luaA_client_checkudata(L, cidx);
888 if(c->minimized != s)
890 client_need_reban(c);
891 c->minimized = s;
892 client_need_reban(c);
893 if(s)
894 window_state_set(c->window, XCB_WM_STATE_ICONIC);
895 else
896 window_state_set(c->window, XCB_WM_STATE_NORMAL);
897 ewmh_client_update_hints(c);
898 /* execute hook */
899 hook_property(c, "minimized");
900 luaA_object_emit_signal(L, cidx, "property::minimized", 0);
904 /** Set a client sticky, or not.
905 * \param L The Lua VM state.
906 * \param cidx The client index.
907 * \param s Set or not the client sticky.
909 void
910 client_set_sticky(lua_State *L, int cidx, bool s)
912 client_t *c = luaA_client_checkudata(L, cidx);
914 if(c->sticky != s)
916 client_need_reban(c);
917 c->sticky = s;
918 client_need_reban(c);
919 ewmh_client_update_hints(c);
920 hook_property(c, "sticky");
921 luaA_object_emit_signal(L, cidx, "property::sticky", 0);
925 /** Set a client fullscreen, or not.
926 * \param L The Lua VM state.
927 * \param cidx The client index.
928 * \param s Set or not the client fullscreen.
930 void
931 client_set_fullscreen(lua_State *L, int cidx, bool s)
933 client_t *c = luaA_client_checkudata(L, cidx);
935 if(c->fullscreen != s)
937 area_t geometry;
939 /* Make sure the current geometry is stored without titlebar. */
940 if(s)
941 titlebar_ban(c->titlebar);
943 /* become fullscreen! */
944 if((c->fullscreen = s))
946 /* remove any max state */
947 client_set_maximized_horizontal(L, cidx, false);
948 client_set_maximized_vertical(L, cidx, false);
949 /* You can only be part of one of the special layers. */
950 client_set_below(L, cidx, false);
951 client_set_above(L, cidx, false);
952 client_set_ontop(L, cidx, false);
954 geometry = screen_area_get(c->screen, false);
955 c->geometries.fullscreen = c->geometry;
956 c->border_width_fs = c->border_width;
957 client_set_border_width(L, cidx, 0);
959 else
961 geometry = c->geometries.fullscreen;
962 client_set_border_width(L, cidx, c->border_width_fs);
964 client_resize(c, geometry, false);
965 client_stack();
966 ewmh_client_update_hints(c);
967 hook_property(c, "fullscreen");
968 luaA_object_emit_signal(L, cidx, "property::fullscreen", 0);
972 /** Set a client horizontally maximized.
973 * \param L The Lua VM state.
974 * \param cidx The client index.
975 * \param s The maximized status.
977 void
978 client_set_maximized_horizontal(lua_State *L, int cidx, bool s)
980 client_t *c = luaA_client_checkudata(L, cidx);
982 if(c->maximized_horizontal != s)
984 area_t geometry;
986 if((c->maximized_horizontal = s))
988 /* remove fullscreen mode */
989 client_set_fullscreen(L, cidx, false);
991 geometry = screen_area_get(c->screen, true);
992 geometry.y = c->geometry.y;
993 geometry.height = c->geometry.height;
994 c->geometries.max.x = c->geometry.x;
995 c->geometries.max.width = c->geometry.width;
997 else
999 geometry = c->geometry;
1000 geometry.x = c->geometries.max.x;
1001 geometry.width = c->geometries.max.width;
1004 client_resize(c, geometry, c->size_hints_honor);
1005 client_stack();
1006 ewmh_client_update_hints(c);
1007 hook_property(c, "maximized_horizontal");
1008 luaA_object_emit_signal(L, cidx, "property::maximized_horizontal", 0);
1012 /** Set a client vertically maximized.
1013 * \param L The Lua VM state.
1014 * \param cidx The client index.
1015 * \param s The maximized status.
1017 void
1018 client_set_maximized_vertical(lua_State *L, int cidx, bool s)
1020 client_t *c = luaA_client_checkudata(L, cidx);
1022 if(c->maximized_vertical != s)
1024 area_t geometry;
1026 if((c->maximized_vertical = s))
1028 /* remove fullscreen mode */
1029 client_set_fullscreen(L, cidx, false);
1031 geometry = screen_area_get(c->screen, true);
1032 geometry.x = c->geometry.x;
1033 geometry.width = c->geometry.width;
1034 c->geometries.max.y = c->geometry.y;
1035 c->geometries.max.height = c->geometry.height;
1037 else
1039 geometry = c->geometry;
1040 geometry.y = c->geometries.max.y;
1041 geometry.height = c->geometries.max.height;
1044 client_resize(c, geometry, c->size_hints_honor);
1045 client_stack();
1046 ewmh_client_update_hints(c);
1047 hook_property(c, "maximized_vertical");
1048 luaA_object_emit_signal(L, cidx, "property::maximized_vertical", 0);
1052 /** Set a client above, or not.
1053 * \param L The Lua VM state.
1054 * \param cidx The client index.
1055 * \param s Set or not the client above.
1057 void
1058 client_set_above(lua_State *L, int cidx, bool s)
1060 client_t *c = luaA_client_checkudata(L, cidx);
1062 if(c->above != s)
1064 /* You can only be part of one of the special layers. */
1065 if(s)
1067 client_set_below(L, cidx, false);
1068 client_set_ontop(L, cidx, false);
1069 client_set_fullscreen(L, cidx, false);
1071 c->above = s;
1072 client_stack();
1073 ewmh_client_update_hints(c);
1074 /* execute hook */
1075 hook_property(c, "above");
1076 luaA_object_emit_signal(L, cidx, "property::above", 0);
1080 /** Set a client below, or not.
1081 * \param L The Lua VM state.
1082 * \param cidx The client index.
1083 * \param s Set or not the client below.
1085 void
1086 client_set_below(lua_State *L, int cidx, bool s)
1088 client_t *c = luaA_client_checkudata(L, cidx);
1090 if(c->below != s)
1092 /* You can only be part of one of the special layers. */
1093 if(s)
1095 client_set_above(L, cidx, false);
1096 client_set_ontop(L, cidx, false);
1097 client_set_fullscreen(L, cidx, false);
1099 c->below = s;
1100 client_stack();
1101 ewmh_client_update_hints(c);
1102 /* execute hook */
1103 hook_property(c, "below");
1104 luaA_object_emit_signal(L, cidx, "property::below", 0);
1108 /** Set a client modal, or not.
1109 * \param L The Lua VM state.
1110 * \param cidx The client index.
1111 * \param s Set or not the client modal attribute.
1113 void
1114 client_set_modal(lua_State *L, int cidx, bool s)
1116 client_t *c = luaA_client_checkudata(L, cidx);
1118 if(c->modal != s)
1120 c->modal = s;
1121 client_stack();
1122 ewmh_client_update_hints(c);
1123 /* execute hook */
1124 hook_property(c, "modal");
1125 luaA_object_emit_signal(L, cidx, "property::modal", 0);
1129 /** Set a client ontop, or not.
1130 * \param L The Lua VM state.
1131 * \param cidx The client index.
1132 * \param s Set or not the client ontop attribute.
1134 void
1135 client_set_ontop(lua_State *L, int cidx, bool s)
1137 client_t *c = luaA_client_checkudata(L, cidx);
1139 if(c->ontop != s)
1141 /* You can only be part of one of the special layers. */
1142 if(s)
1144 client_set_above(L, cidx, false);
1145 client_set_below(L, cidx, false);
1146 client_set_fullscreen(L, cidx, false);
1148 c->ontop = s;
1149 client_stack();
1150 /* execute hook */
1151 hook_property(c, "ontop");
1152 luaA_object_emit_signal(L, cidx, "property::ontop", 0);
1156 /** Set a client skip taskbar attribute.
1157 * \param L Tha Lua VM state.
1158 * \param cidx The client index.
1159 * \param s Set or not the client skip taskbar attribute.
1161 void
1162 client_set_skip_taskbar(lua_State *L, int cidx, bool s)
1164 client_t *c = luaA_client_checkudata(L, cidx);
1166 if(c->skip_taskbar != s)
1168 c->skip_taskbar = s;
1169 luaA_object_emit_signal(L, cidx, "property::skip_taskbar", 0);
1173 /** Unban a client and move it back into the viewport.
1174 * \param c The client.
1176 void
1177 client_unban(client_t *c)
1179 if(c->isbanned)
1181 xcb_map_window(globalconf.connection, c->window);
1183 c->isbanned = false;
1187 /** Unmanage a client.
1188 * \param c The client.
1190 void
1191 client_unmanage(client_t *c)
1193 tag_array_t *tags = &c->screen->tags;
1195 /* Reset transient_for attributes of widows that maybe refering to us */
1196 foreach(_tc, globalconf.clients)
1198 client_t *tc = *_tc;
1199 if(tc->transient_for == c)
1200 tc->transient_for = NULL;
1203 if(globalconf.screens.tab[c->phys_screen].prev_client_focus == c)
1204 globalconf.screens.tab[c->phys_screen].prev_client_focus = NULL;
1206 if(globalconf.screens.tab[c->phys_screen].client_focus == c)
1207 client_unfocus(c);
1209 /* remove client from global list and everywhere else */
1210 foreach(elem, globalconf.clients)
1211 if(*elem == c)
1213 client_array_remove(&globalconf.clients, elem);
1214 break;
1216 stack_client_remove(c);
1217 for(int i = 0; i < tags->len; i++)
1218 untag_client(c, tags->tab[i]);
1220 /* call hook */
1221 if(globalconf.hooks.unmanage != LUA_REFNIL)
1223 luaA_object_push(globalconf.L, c);
1224 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.unmanage, 1, 0);
1227 luaA_object_push(globalconf.L, c);
1228 luaA_class_emit_signal(globalconf.L, &client_class, "unmanage", 1);
1230 /* Call hook to notify list change */
1231 if(globalconf.hooks.clients != LUA_REFNIL)
1232 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.clients, 0, 0);
1234 luaA_class_emit_signal(globalconf.L, &client_class, "list", 0);
1236 window_state_set(c->window, XCB_WM_STATE_WITHDRAWN);
1238 titlebar_client_detach(c);
1240 ewmh_update_net_client_list(c->phys_screen);
1242 /* set client as invalid */
1243 c->invalid = true;
1245 luaA_object_unref(globalconf.L, c);
1248 /** Kill a client via a WM_DELETE_WINDOW request or KillClient if not
1249 * supported.
1250 * \param c The client to kill.
1252 void
1253 client_kill(client_t *c)
1255 if(client_hasproto(c, WM_DELETE_WINDOW))
1257 xcb_client_message_event_t ev;
1259 /* Initialize all of event's fields first */
1260 p_clear(&ev, 1);
1262 ev.response_type = XCB_CLIENT_MESSAGE;
1263 ev.window = c->window;
1264 ev.format = 32;
1265 ev.data.data32[1] = XCB_CURRENT_TIME;
1266 ev.type = WM_PROTOCOLS;
1267 ev.data.data32[0] = WM_DELETE_WINDOW;
1269 xcb_send_event(globalconf.connection, false, c->window,
1270 XCB_EVENT_MASK_NO_EVENT, (char *) &ev);
1272 else
1273 xcb_kill_client(globalconf.connection, c->window);
1276 /** Get all clients into a table.
1277 * \param L The Lua VM state.
1278 * \return The number of elements pushed on stack.
1279 * \luastack
1280 * \lparam An optional screen nunmber.
1281 * \lreturn A table with all clients.
1283 static int
1284 luaA_client_get(lua_State *L)
1286 int i = 1, screen;
1288 screen = luaL_optnumber(L, 1, 0) - 1;
1290 lua_newtable(L);
1292 if(screen == -1)
1293 foreach(c, globalconf.clients)
1295 luaA_object_push(L, *c);
1296 lua_rawseti(L, -2, i++);
1298 else
1300 luaA_checkscreen(screen);
1301 foreach(c, globalconf.clients)
1302 if((*c)->screen == &globalconf.screens.tab[screen])
1304 luaA_object_push(L, *c);
1305 lua_rawseti(L, -2, i++);
1309 return 1;
1312 /** Check if a client is visible on its screen.
1313 * \param L The Lua VM state.
1314 * \return The number of elements pushed on stack.
1315 * \luastack
1316 * \lvalue A client.
1317 * \lreturn A boolean value, true if the client is visible, false otherwise.
1319 static int
1320 luaA_client_isvisible(lua_State *L)
1322 client_t *c = luaA_client_checkudata(L, 1);
1323 lua_pushboolean(L, client_isvisible(c, c->screen));
1324 return 1;
1327 /** Set client border width.
1328 * \param L The Lua VM state.
1329 * \param cidx The client index.
1330 * \param width The border width.
1332 void
1333 client_set_border_width(lua_State *L, int cidx, int width)
1335 client_t *c = luaA_client_checkudata(L, cidx);
1336 uint32_t w = width;
1338 if(width > 0 && (c->type == WINDOW_TYPE_DOCK
1339 || c->type == WINDOW_TYPE_SPLASH
1340 || c->type == WINDOW_TYPE_DESKTOP
1341 || c->fullscreen))
1342 return;
1344 if(width == c->border_width || width < 0)
1345 return;
1347 /* Update geometry with the new border. */
1348 c->geometry.width -= 2 * c->border_width;
1349 c->geometry.height -= 2 * c->border_width;
1351 c->border_width = width;
1352 xcb_configure_window(globalconf.connection, c->window,
1353 XCB_CONFIG_WINDOW_BORDER_WIDTH, &w);
1355 c->geometry.width += 2 * c->border_width;
1356 c->geometry.height += 2 * c->border_width;
1358 /* Changing border size also affects the size of the titlebar. */
1359 titlebar_update_geometry(c);
1361 hook_property(c, "border_width");
1362 luaA_object_emit_signal(L, cidx, "property::border_width", 0);
1365 /** Set a client icon.
1366 * \param L The Lua VM state.
1367 * \param cidx The client index on the stack.
1368 * \para iidx The image index on the stack.
1370 void
1371 client_set_icon(lua_State *L, int cidx, int iidx)
1373 client_t *c = luaA_client_checkudata(L, cidx);
1374 luaA_checkudata(L, iidx, &image_class);
1375 luaA_object_unref_item(L, cidx, c->icon);
1376 c->icon = luaA_object_ref_item(L, cidx, iidx);
1377 luaA_object_emit_signal(L, cidx, "property::icon", 0);
1378 /* execute hook */
1379 hook_property(c, "icon");
1382 /** Kill a client.
1383 * \param L The Lua VM state.
1385 * \luastack
1386 * \lvalue A client.
1388 static int
1389 luaA_client_kill(lua_State *L)
1391 client_t *c = luaA_client_checkudata(L, 1);
1392 client_kill(c);
1393 return 0;
1396 /** Swap a client with another one.
1397 * \param L The Lua VM state.
1398 * \luastack
1399 * \lvalue A client.
1400 * \lparam A client to swap with.
1402 static int
1403 luaA_client_swap(lua_State *L)
1405 client_t *c = luaA_client_checkudata(L, 1);
1406 client_t *swap = luaA_client_checkudata(L, 2);
1408 if(c != swap)
1410 client_t **ref_c = NULL, **ref_swap = NULL;
1411 foreach(item, globalconf.clients)
1413 if(*item == c)
1414 ref_c = item;
1415 else if(*item == swap)
1416 ref_swap = item;
1417 if(ref_c && ref_swap)
1418 break;
1420 /* swap ! */
1421 *ref_c = swap;
1422 *ref_swap = c;
1424 /* Call hook to notify list change */
1425 if(globalconf.hooks.clients != LUA_REFNIL)
1426 luaA_dofunction_from_registry(L, globalconf.hooks.clients, 0, 0);
1428 luaA_class_emit_signal(globalconf.L, &client_class, "list", 0);
1431 return 0;
1434 /** Access or set the client tags.
1435 * \param L The Lua VM state.
1436 * \return The number of elements pushed on stack.
1437 * \lparam A table with tags to set, or none to get the current tags table.
1438 * \return The clients tag.
1440 static int
1441 luaA_client_tags(lua_State *L)
1443 client_t *c = luaA_client_checkudata(L, 1);
1444 tag_array_t *tags = &c->screen->tags;
1445 int j = 0;
1447 if(lua_gettop(L) == 2)
1449 luaA_checktable(L, 2);
1450 for(int i = 0; i < tags->len; i++)
1451 untag_client(c, tags->tab[i]);
1452 lua_pushnil(L);
1453 while(lua_next(L, 2))
1454 tag_client(c);
1455 lua_pop(L, 1);
1458 lua_newtable(L);
1459 foreach(tag, *tags)
1460 if(is_client_tagged(c, *tag))
1462 luaA_object_push(L, *tag);
1463 lua_rawseti(L, -2, ++j);
1466 return 1;
1469 /** Raise a client on top of others which are on the same layer.
1470 * \param L The Lua VM state.
1471 * \luastack
1472 * \lvalue A client.
1474 static int
1475 luaA_client_raise(lua_State *L)
1477 client_t *c = luaA_client_checkudata(L, 1);
1478 client_raise(c);
1479 return 0;
1482 /** Lower a client on bottom of others which are on the same layer.
1483 * \param L The Lua VM state.
1484 * \luastack
1485 * \lvalue A client.
1487 static int
1488 luaA_client_lower(lua_State *L)
1490 client_t *c = luaA_client_checkudata(L, 1);
1491 client_lower(c);
1492 return 0;
1495 /** Redraw a client by unmapping and mapping it quickly.
1496 * \param L The Lua VM state.
1498 * \luastack
1499 * \lvalue A client.
1501 static int
1502 luaA_client_redraw(lua_State *L)
1504 client_t *c = luaA_client_checkudata(L, 1);
1506 xcb_unmap_window(globalconf.connection, c->window);
1507 xcb_map_window(globalconf.connection, c->window);
1509 /* Set the focus on the current window if the redraw has been
1510 performed on the window where the pointer is currently on
1511 because after the unmapping/mapping, the focus is lost */
1512 if(globalconf.screen_focus->client_focus == c)
1514 client_unfocus(c);
1515 client_focus(c);
1518 return 0;
1521 /** Stop managing a client.
1522 * \param L The Lua VM state.
1523 * \return The number of elements pushed on stack.
1524 * \luastack
1525 * \lvalue A client.
1527 static int
1528 luaA_client_unmanage(lua_State *L)
1530 client_t *c = luaA_client_checkudata(L, 1);
1531 client_unmanage(c);
1532 return 0;
1535 /** Return client geometry.
1536 * \param L The Lua VM state.
1537 * \return The number of elements pushed on stack.
1538 * \luastack
1539 * \lparam A table with new coordinates, or none.
1540 * \lreturn A table with client coordinates.
1542 static int
1543 luaA_client_geometry(lua_State *L)
1545 client_t *c = luaA_client_checkudata(L, 1);
1547 if(lua_gettop(L) == 2)
1549 area_t geometry;
1551 luaA_checktable(L, 2);
1552 geometry.x = luaA_getopt_number(L, 2, "x", c->geometry.x);
1553 geometry.y = luaA_getopt_number(L, 2, "y", c->geometry.y);
1554 if(client_isfixed(c))
1556 geometry.width = c->geometry.width;
1557 geometry.height = c->geometry.height;
1559 else
1561 geometry.width = luaA_getopt_number(L, 2, "width", c->geometry.width);
1562 geometry.height = luaA_getopt_number(L, 2, "height", c->geometry.height);
1565 client_resize(c, geometry, c->size_hints_honor);
1568 return luaA_pusharea(L, c->geometry);
1571 /** Return client struts (reserved space at the edge of the screen).
1572 * \param L The Lua VM state.
1573 * \return The number of elements pushed on stack.
1574 * \luastack
1575 * \lparam A table with new strut values, or none.
1576 * \lreturn A table with strut values.
1578 static int
1579 luaA_client_struts(lua_State *L)
1581 client_t *c = luaA_client_checkudata(L, 1);
1583 if(lua_gettop(L) == 2)
1585 luaA_tostrut(L, 2, &c->strut);
1586 ewmh_update_strut(c->window, &c->strut);
1587 hook_property(c, "struts");
1588 luaA_object_emit_signal(L, 1, "property::struts", 0);
1589 screen_emit_signal(L, c->screen, "property::workarea", 0);
1592 return luaA_pushstrut(L, c->strut);
1595 static int
1596 luaA_client_set_screen(lua_State *L, client_t *c)
1598 if(globalconf.xinerama_is_active)
1600 int screen = luaL_checknumber(L, -1) - 1;
1601 luaA_checkscreen(screen);
1602 screen_client_moveto(c, &globalconf.screens.tab[screen], true, true);
1604 return 0;
1607 static int
1608 luaA_client_set_hidden(lua_State *L, client_t *c)
1610 bool b = luaA_checkboolean(L, -1);
1611 if(b != c->hidden)
1613 client_need_reban(c);
1614 c->hidden = b;
1615 client_need_reban(c);
1616 hook_property(c, "hidden");
1617 luaA_object_emit_signal(L, -3, "property::screen", 0);
1619 return 0;
1622 static int
1623 luaA_client_set_minimized(lua_State *L, client_t *c)
1625 client_set_minimized(L, -3, luaA_checkboolean(L, -1));
1626 return 0;
1629 static int
1630 luaA_client_set_fullscreen(lua_State *L, client_t *c)
1632 client_set_fullscreen(L, -3, luaA_checkboolean(L, -1));
1633 return 0;
1636 static int
1637 luaA_client_set_modal(lua_State *L, client_t *c)
1639 client_set_modal(L, -3, luaA_checkboolean(L, -1));
1640 return 0;
1643 static int
1644 luaA_client_set_maximized_horizontal(lua_State *L, client_t *c)
1646 client_set_maximized_horizontal(L, -3, luaA_checkboolean(L, -1));
1647 return 0;
1650 static int
1651 luaA_client_set_maximized_vertical(lua_State *L, client_t *c)
1653 client_set_maximized_vertical(L, -3, luaA_checkboolean(L, -1));
1654 return 0;
1657 static int
1658 luaA_client_set_icon(lua_State *L, client_t *c)
1660 client_set_icon(L, -3, -1);
1661 return 0;
1664 static int
1665 luaA_client_set_opacity(lua_State *L, client_t *c)
1667 if(lua_isnil(L, -1))
1668 client_set_opacity(L, -3, -1);
1669 else
1670 client_set_opacity(L, -3, luaL_checknumber(L, -1));
1671 return 0;
1674 static int
1675 luaA_client_set_sticky(lua_State *L, client_t *c)
1677 client_set_sticky(L, -3, luaA_checkboolean(L, -1));
1678 return 0;
1681 static int
1682 luaA_client_set_size_hints_honor(lua_State *L, client_t *c)
1684 c->size_hints_honor = luaA_checkboolean(L, -1);
1685 hook_property(c, "size_hints_honor");
1686 luaA_object_emit_signal(L, -3, "property::size_hints_honor", 0);
1687 return 0;
1690 static int
1691 luaA_client_set_border_width(lua_State *L, client_t *c)
1693 client_set_border_width(L, -3, luaL_checknumber(L, -1));
1694 return 0;
1697 static int
1698 luaA_client_set_ontop(lua_State *L, client_t *c)
1700 client_set_ontop(L, -3, luaA_checkboolean(L, -1));
1701 return 0;
1704 static int
1705 luaA_client_set_below(lua_State *L, client_t *c)
1707 client_set_below(L, -3, luaA_checkboolean(L, -1));
1708 return 0;
1711 static int
1712 luaA_client_set_above(lua_State *L, client_t *c)
1714 client_set_above(L, -3, luaA_checkboolean(L, -1));
1715 return 0;
1718 static int
1719 luaA_client_set_urgent(lua_State *L, client_t *c)
1721 client_set_urgent(L, -3, luaA_checkboolean(L, -1));
1722 return 0;
1725 static int
1726 luaA_client_set_border_color(lua_State *L, client_t *c)
1728 size_t len;
1729 const char *buf;
1730 if((buf = luaL_checklstring(L, -1, &len))
1731 && xcolor_init_reply(xcolor_init_unchecked(&c->border_color, buf, len)))
1733 xcb_change_window_attributes(globalconf.connection, c->window,
1734 XCB_CW_BORDER_PIXEL, &c->border_color.pixel);
1735 luaA_object_emit_signal(L, -3, "property::border_color", 0);
1737 return 0;
1740 static int
1741 luaA_client_set_titlebar(lua_State *L, client_t *c)
1743 if(lua_isnil(L, -1))
1744 titlebar_client_detach(c);
1745 else
1746 titlebar_client_attach(c);
1747 return 0;
1750 static int
1751 luaA_client_set_skip_taskbar(lua_State *L, client_t *c)
1753 client_set_skip_taskbar(L, -3, luaA_checkboolean(L, -1));
1754 return 0;
1757 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, name, lua_pushstring)
1758 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, icon_name, lua_pushstring)
1759 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, class, lua_pushstring)
1760 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, instance, lua_pushstring)
1761 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, machine, lua_pushstring)
1762 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, role, lua_pushstring)
1763 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, transient_for, luaA_object_push)
1764 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, skip_taskbar, lua_pushboolean)
1765 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, window, lua_pushnumber)
1766 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, leader_window, lua_pushnumber)
1767 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, group_window, lua_pushnumber)
1768 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, pid, lua_pushnumber)
1769 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, hidden, lua_pushboolean)
1770 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, minimized, lua_pushboolean)
1771 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, fullscreen, lua_pushboolean)
1772 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, modal, lua_pushboolean)
1773 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, ontop, lua_pushboolean)
1774 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, urgent, lua_pushboolean)
1775 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, above, lua_pushboolean)
1776 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, below, lua_pushboolean)
1777 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, sticky, lua_pushboolean)
1778 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, size_hints_honor, lua_pushboolean)
1779 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, maximized_horizontal, lua_pushboolean)
1780 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, maximized_vertical, lua_pushboolean)
1781 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, opacity, lua_pushnumber)
1782 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, border_width, lua_pushnumber)
1783 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, border_color, luaA_pushxcolor)
1785 static int
1786 luaA_client_get_content(lua_State *L, client_t *c)
1788 xcb_image_t *ximage = xcb_image_get(globalconf.connection,
1789 c->window,
1790 0, 0,
1791 c->geometries.internal.width,
1792 c->geometries.internal.height,
1793 ~0, XCB_IMAGE_FORMAT_Z_PIXMAP);
1794 int retval = 0;
1796 if(ximage)
1798 if(ximage->bpp >= 24)
1800 uint32_t *data = p_alloca(uint32_t, ximage->width * ximage->height);
1802 for(int y = 0; y < ximage->height; y++)
1803 for(int x = 0; x < ximage->width; x++)
1805 data[y * ximage->width + x] = xcb_image_get_pixel(ximage, x, y);
1806 data[y * ximage->width + x] |= 0xff000000; /* set alpha to 0xff */
1809 retval = image_new_from_argb32(ximage->width, ximage->height, data);
1811 xcb_image_destroy(ximage);
1814 return retval;
1817 static int
1818 luaA_client_get_type(lua_State *L, client_t *c)
1820 switch(c->type)
1822 case WINDOW_TYPE_DESKTOP:
1823 lua_pushliteral(L, "desktop");
1824 break;
1825 case WINDOW_TYPE_DOCK:
1826 lua_pushliteral(L, "dock");
1827 break;
1828 case WINDOW_TYPE_SPLASH:
1829 lua_pushliteral(L, "splash");
1830 break;
1831 case WINDOW_TYPE_DIALOG:
1832 lua_pushliteral(L, "dialog");
1833 break;
1834 case WINDOW_TYPE_MENU:
1835 lua_pushliteral(L, "menu");
1836 break;
1837 case WINDOW_TYPE_TOOLBAR:
1838 lua_pushliteral(L, "toolbar");
1839 break;
1840 case WINDOW_TYPE_UTILITY:
1841 lua_pushliteral(L, "utility");
1842 break;
1843 case WINDOW_TYPE_DROPDOWN_MENU:
1844 lua_pushliteral(L, "dropdown_menu");
1845 break;
1846 case WINDOW_TYPE_POPUP_MENU:
1847 lua_pushliteral(L, "popup_menu");
1848 break;
1849 case WINDOW_TYPE_TOOLTIP:
1850 lua_pushliteral(L, "tooltip");
1851 break;
1852 case WINDOW_TYPE_NOTIFICATION:
1853 lua_pushliteral(L, "notification");
1854 break;
1855 case WINDOW_TYPE_COMBO:
1856 lua_pushliteral(L, "combo");
1857 break;
1858 case WINDOW_TYPE_DND:
1859 lua_pushliteral(L, "dnd");
1860 break;
1861 case WINDOW_TYPE_NORMAL:
1862 lua_pushliteral(L, "normal");
1863 break;
1865 return 1;
1868 static int
1869 luaA_client_get_screen(lua_State *L, client_t *c)
1871 lua_pushnumber(L, 1 + screen_array_indexof(&globalconf.screens, c->screen));
1872 return 1;
1875 static int
1876 luaA_client_get_icon(lua_State *L, client_t *c)
1878 return luaA_object_push_item(L, -2, c->icon);
1881 static int
1882 luaA_client_get_titlebar(lua_State *L, client_t *c)
1884 return luaA_object_push_item(L, -2, c->titlebar);
1887 static int
1888 luaA_client_get_size_hints(lua_State *L, client_t *c)
1890 const char *u_or_p = NULL;
1892 lua_createtable(L, 0, 1);
1894 if(c->size_hints.flags & XCB_SIZE_HINT_US_POSITION)
1895 u_or_p = "user_position";
1896 else if(c->size_hints.flags & XCB_SIZE_HINT_P_POSITION)
1897 u_or_p = "program_position";
1899 if(u_or_p)
1901 lua_createtable(L, 0, 2);
1902 lua_pushnumber(L, c->size_hints.x);
1903 lua_setfield(L, -2, "x");
1904 lua_pushnumber(L, c->size_hints.y);
1905 lua_setfield(L, -2, "y");
1906 lua_setfield(L, -2, u_or_p);
1907 u_or_p = NULL;
1910 if(c->size_hints.flags & XCB_SIZE_HINT_US_SIZE)
1911 u_or_p = "user_size";
1912 else if(c->size_hints.flags & XCB_SIZE_HINT_P_SIZE)
1913 u_or_p = "program_size";
1915 if(u_or_p)
1917 lua_createtable(L, 0, 2);
1918 lua_pushnumber(L, c->size_hints.width);
1919 lua_setfield(L, -2, "width");
1920 lua_pushnumber(L, c->size_hints.height);
1921 lua_setfield(L, -2, "height");
1922 lua_setfield(L, -2, u_or_p);
1925 if(c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)
1927 lua_pushnumber(L, c->size_hints.min_width);
1928 lua_setfield(L, -2, "min_width");
1929 lua_pushnumber(L, c->size_hints.min_height);
1930 lua_setfield(L, -2, "min_height");
1933 if(c->size_hints.flags & XCB_SIZE_HINT_P_MAX_SIZE)
1935 lua_pushnumber(L, c->size_hints.max_width);
1936 lua_setfield(L, -2, "max_width");
1937 lua_pushnumber(L, c->size_hints.max_height);
1938 lua_setfield(L, -2, "max_height");
1941 if(c->size_hints.flags & XCB_SIZE_HINT_P_RESIZE_INC)
1943 lua_pushnumber(L, c->size_hints.width_inc);
1944 lua_setfield(L, -2, "width_inc");
1945 lua_pushnumber(L, c->size_hints.height_inc);
1946 lua_setfield(L, -2, "height_inc");
1949 if(c->size_hints.flags & XCB_SIZE_HINT_P_ASPECT)
1951 lua_pushnumber(L, c->size_hints.min_aspect_num);
1952 lua_setfield(L, -2, "min_aspect_num");
1953 lua_pushnumber(L, c->size_hints.min_aspect_den);
1954 lua_setfield(L, -2, "min_aspect_den");
1955 lua_pushnumber(L, c->size_hints.max_aspect_num);
1956 lua_setfield(L, -2, "max_aspect_num");
1957 lua_pushnumber(L, c->size_hints.max_aspect_den);
1958 lua_setfield(L, -2, "max_aspect_den");
1961 if(c->size_hints.flags & XCB_SIZE_HINT_BASE_SIZE)
1963 lua_pushnumber(L, c->size_hints.base_width);
1964 lua_setfield(L, -2, "base_width");
1965 lua_pushnumber(L, c->size_hints.base_height);
1966 lua_setfield(L, -2, "base_height");
1969 if(c->size_hints.flags & XCB_SIZE_HINT_P_WIN_GRAVITY)
1971 switch(c->size_hints.win_gravity)
1973 default:
1974 lua_pushliteral(L, "north_west");
1975 break;
1976 case XCB_GRAVITY_NORTH:
1977 lua_pushliteral(L, "north");
1978 break;
1979 case XCB_GRAVITY_NORTH_EAST:
1980 lua_pushliteral(L, "north_east");
1981 break;
1982 case XCB_GRAVITY_WEST:
1983 lua_pushliteral(L, "west");
1984 break;
1985 case XCB_GRAVITY_CENTER:
1986 lua_pushliteral(L, "center");
1987 break;
1988 case XCB_GRAVITY_EAST:
1989 lua_pushliteral(L, "east");
1990 break;
1991 case XCB_GRAVITY_SOUTH_WEST:
1992 lua_pushliteral(L, "south_west");
1993 break;
1994 case XCB_GRAVITY_SOUTH:
1995 lua_pushliteral(L, "south");
1996 break;
1997 case XCB_GRAVITY_SOUTH_EAST:
1998 lua_pushliteral(L, "south_east");
1999 break;
2000 case XCB_GRAVITY_STATIC:
2001 lua_pushliteral(L, "static");
2002 break;
2004 lua_setfield(L, -2, "win_gravity");
2007 return 1;
2010 /** Get or set mouse buttons bindings for a client.
2011 * \param L The Lua VM state.
2012 * \return The number of element pushed on stack.
2013 * \luastack
2014 * \lvalue A client.
2015 * \lparam An array of mouse button bindings objects, or nothing.
2016 * \return The array of mouse button bindings objects of this client.
2018 static int
2019 luaA_client_buttons(lua_State *L)
2021 client_t *client = luaA_client_checkudata(L, 1);
2022 button_array_t *buttons = &client->buttons;
2024 if(lua_gettop(L) == 2)
2026 luaA_button_array_set(L, 1, 2, buttons);
2027 luaA_object_emit_signal(L, 1, "property::buttons", 0);
2028 window_buttons_grab(client->window, &client->buttons);
2031 return luaA_button_array_get(L, 1, buttons);
2034 /** Get or set keys bindings for a client.
2035 * \param L The Lua VM state.
2036 * \return The number of element pushed on stack.
2037 * \luastack
2038 * \lvalue A client.
2039 * \lparam An array of key bindings objects, or nothing.
2040 * \return The array of key bindings objects of this client.
2042 static int
2043 luaA_client_keys(lua_State *L)
2045 client_t *c = luaA_client_checkudata(L, 1);
2046 key_array_t *keys = &c->keys;
2048 if(lua_gettop(L) == 2)
2050 luaA_key_array_set(L, 1, 2, keys);
2051 luaA_object_emit_signal(L, 1, "property::keys", 0);
2052 xcb_ungrab_key(globalconf.connection, XCB_GRAB_ANY, c->window, XCB_BUTTON_MASK_ANY);
2053 window_grabkeys(c->window, keys);
2056 return luaA_key_array_get(L, 1, keys);
2059 /* Client module.
2060 * \param L The Lua VM state.
2061 * \return The number of pushed elements.
2063 static int
2064 luaA_client_module_index(lua_State *L)
2066 size_t len;
2067 const char *buf = luaL_checklstring(L, 2, &len);
2069 switch(a_tokenize(buf, len))
2071 case A_TK_FOCUS:
2072 return luaA_object_push(globalconf.L, globalconf.screen_focus->client_focus);
2073 break;
2074 default:
2075 return 0;
2079 /* Client module new index.
2080 * \param L The Lua VM state.
2081 * \return The number of pushed elements.
2083 static int
2084 luaA_client_module_newindex(lua_State *L)
2086 size_t len;
2087 const char *buf = luaL_checklstring(L, 2, &len);
2088 client_t *c;
2090 switch(a_tokenize(buf, len))
2092 case A_TK_FOCUS:
2093 c = luaA_client_checkudata(L, 3);
2094 client_focus(c);
2095 break;
2096 default:
2097 break;
2100 return 0;
2103 void
2104 client_class_setup(lua_State *L)
2106 static const struct luaL_reg client_methods[] =
2108 LUA_CLASS_METHODS(client)
2109 { "get", luaA_client_get },
2110 { "__index", luaA_client_module_index },
2111 { "__newindex", luaA_client_module_newindex },
2112 { NULL, NULL }
2115 static const struct luaL_reg client_meta[] =
2117 LUA_OBJECT_META(client)
2118 LUA_CLASS_META
2119 { "buttons", luaA_client_buttons },
2120 { "keys", luaA_client_keys },
2121 { "isvisible", luaA_client_isvisible },
2122 { "geometry", luaA_client_geometry },
2123 { "struts", luaA_client_struts },
2124 { "tags", luaA_client_tags },
2125 { "kill", luaA_client_kill },
2126 { "swap", luaA_client_swap },
2127 { "raise", luaA_client_raise },
2128 { "lower", luaA_client_lower },
2129 { "redraw", luaA_client_redraw },
2130 { "unmanage", luaA_client_unmanage },
2131 { "__gc", luaA_client_gc },
2132 { NULL, NULL }
2135 luaA_class_setup(L, &client_class, "client", (lua_class_allocator_t) client_new,
2136 client_methods, client_meta);
2137 luaA_class_add_property(&client_class, A_TK_NAME,
2138 NULL,
2139 (lua_class_propfunc_t) luaA_client_get_name,
2140 NULL);
2141 luaA_class_add_property(&client_class, A_TK_TRANSIENT_FOR,
2142 NULL,
2143 (lua_class_propfunc_t) luaA_client_get_transient_for,
2144 NULL);
2145 luaA_class_add_property(&client_class, A_TK_SKIP_TASKBAR,
2146 (lua_class_propfunc_t) luaA_client_set_skip_taskbar,
2147 (lua_class_propfunc_t) luaA_client_get_skip_taskbar,
2148 (lua_class_propfunc_t) luaA_client_set_skip_taskbar);
2149 luaA_class_add_property(&client_class, A_TK_CONTENT,
2150 NULL,
2151 (lua_class_propfunc_t) luaA_client_get_content,
2152 NULL);
2153 luaA_class_add_property(&client_class, A_TK_TYPE,
2154 NULL,
2155 (lua_class_propfunc_t) luaA_client_get_type,
2156 NULL);
2157 luaA_class_add_property(&client_class, A_TK_CLASS,
2158 NULL,
2159 (lua_class_propfunc_t) luaA_client_get_class,
2160 NULL);
2161 luaA_class_add_property(&client_class, A_TK_INSTANCE,
2162 NULL,
2163 (lua_class_propfunc_t) luaA_client_get_instance,
2164 NULL);
2165 luaA_class_add_property(&client_class, A_TK_ROLE,
2166 NULL,
2167 (lua_class_propfunc_t) luaA_client_get_role,
2168 NULL);
2169 luaA_class_add_property(&client_class, A_TK_PID,
2170 NULL,
2171 (lua_class_propfunc_t) luaA_client_get_pid,
2172 NULL);
2173 luaA_class_add_property(&client_class, A_TK_WINDOW,
2174 NULL,
2175 (lua_class_propfunc_t) luaA_client_get_window,
2176 NULL);
2177 luaA_class_add_property(&client_class, A_TK_LEADER_WINDOW,
2178 NULL,
2179 (lua_class_propfunc_t) luaA_client_get_leader_window,
2180 NULL);
2181 luaA_class_add_property(&client_class, A_TK_MACHINE,
2182 NULL,
2183 (lua_class_propfunc_t) luaA_client_get_machine,
2184 NULL);
2185 luaA_class_add_property(&client_class, A_TK_ICON_NAME,
2186 NULL,
2187 (lua_class_propfunc_t) luaA_client_get_icon_name,
2188 NULL);
2189 luaA_class_add_property(&client_class, A_TK_SCREEN,
2190 NULL,
2191 (lua_class_propfunc_t) luaA_client_get_screen,
2192 (lua_class_propfunc_t) luaA_client_set_screen);
2193 luaA_class_add_property(&client_class, A_TK_HIDDEN,
2194 (lua_class_propfunc_t) luaA_client_set_hidden,
2195 (lua_class_propfunc_t) luaA_client_get_hidden,
2196 (lua_class_propfunc_t) luaA_client_set_hidden);
2197 luaA_class_add_property(&client_class, A_TK_MINIMIZED,
2198 (lua_class_propfunc_t) luaA_client_set_minimized,
2199 (lua_class_propfunc_t) luaA_client_get_minimized,
2200 (lua_class_propfunc_t) luaA_client_set_minimized);
2201 luaA_class_add_property(&client_class, A_TK_FULLSCREEN,
2202 (lua_class_propfunc_t) luaA_client_set_fullscreen,
2203 (lua_class_propfunc_t) luaA_client_get_fullscreen,
2204 (lua_class_propfunc_t) luaA_client_set_fullscreen);
2205 luaA_class_add_property(&client_class, A_TK_MODAL,
2206 (lua_class_propfunc_t) luaA_client_set_modal,
2207 (lua_class_propfunc_t) luaA_client_get_modal,
2208 (lua_class_propfunc_t) luaA_client_set_modal);
2209 luaA_class_add_property(&client_class, A_TK_GROUP_WINDOW,
2210 NULL,
2211 (lua_class_propfunc_t) luaA_client_get_group_window,
2212 NULL);
2213 luaA_class_add_property(&client_class, A_TK_MAXIMIZED_HORIZONTAL,
2214 (lua_class_propfunc_t) luaA_client_set_maximized_horizontal,
2215 (lua_class_propfunc_t) luaA_client_get_maximized_horizontal,
2216 (lua_class_propfunc_t) luaA_client_set_maximized_horizontal);
2217 luaA_class_add_property(&client_class, A_TK_MAXIMIZED_VERTICAL,
2218 (lua_class_propfunc_t) luaA_client_set_maximized_vertical,
2219 (lua_class_propfunc_t) luaA_client_get_maximized_vertical,
2220 (lua_class_propfunc_t) luaA_client_set_maximized_vertical);
2221 luaA_class_add_property(&client_class, A_TK_ICON,
2222 (lua_class_propfunc_t) luaA_client_set_icon,
2223 (lua_class_propfunc_t) luaA_client_get_icon,
2224 (lua_class_propfunc_t) luaA_client_set_icon);
2225 luaA_class_add_property(&client_class, A_TK_OPACITY,
2226 (lua_class_propfunc_t) luaA_client_set_opacity,
2227 (lua_class_propfunc_t) luaA_client_get_opacity,
2228 (lua_class_propfunc_t) luaA_client_set_opacity);
2229 luaA_class_add_property(&client_class, A_TK_ONTOP,
2230 (lua_class_propfunc_t) luaA_client_set_ontop,
2231 (lua_class_propfunc_t) luaA_client_get_ontop,
2232 (lua_class_propfunc_t) luaA_client_set_ontop);
2233 luaA_class_add_property(&client_class, A_TK_ABOVE,
2234 (lua_class_propfunc_t) luaA_client_set_above,
2235 (lua_class_propfunc_t) luaA_client_get_above,
2236 (lua_class_propfunc_t) luaA_client_set_above);
2237 luaA_class_add_property(&client_class, A_TK_BELOW,
2238 (lua_class_propfunc_t) luaA_client_set_below,
2239 (lua_class_propfunc_t) luaA_client_get_below,
2240 (lua_class_propfunc_t) luaA_client_set_below);
2241 luaA_class_add_property(&client_class, A_TK_STICKY,
2242 (lua_class_propfunc_t) luaA_client_set_sticky,
2243 (lua_class_propfunc_t) luaA_client_get_sticky,
2244 (lua_class_propfunc_t) luaA_client_set_sticky);
2245 luaA_class_add_property(&client_class, A_TK_SIZE_HINTS_HONOR,
2246 (lua_class_propfunc_t) luaA_client_set_size_hints_honor,
2247 (lua_class_propfunc_t) luaA_client_get_size_hints_honor,
2248 (lua_class_propfunc_t) luaA_client_set_size_hints_honor);
2249 luaA_class_add_property(&client_class, A_TK_BORDER_WIDTH,
2250 (lua_class_propfunc_t) luaA_client_set_border_width,
2251 (lua_class_propfunc_t) luaA_client_get_border_width,
2252 (lua_class_propfunc_t) luaA_client_set_border_width);
2253 luaA_class_add_property(&client_class, A_TK_BORDER_COLOR,
2254 (lua_class_propfunc_t) luaA_client_set_border_color,
2255 (lua_class_propfunc_t) luaA_client_get_border_color,
2256 (lua_class_propfunc_t) luaA_client_set_border_color);
2257 luaA_class_add_property(&client_class, A_TK_TITLEBAR,
2258 (lua_class_propfunc_t) luaA_client_set_titlebar,
2259 (lua_class_propfunc_t) luaA_client_get_titlebar,
2260 (lua_class_propfunc_t) luaA_client_set_titlebar);
2261 luaA_class_add_property(&client_class, A_TK_URGENT,
2262 (lua_class_propfunc_t) luaA_client_set_urgent,
2263 (lua_class_propfunc_t) luaA_client_get_urgent,
2264 (lua_class_propfunc_t) luaA_client_set_urgent);
2265 luaA_class_add_property(&client_class, A_TK_SIZE_HINTS,
2266 NULL,
2267 (lua_class_propfunc_t) luaA_client_get_size_hints,
2268 NULL);
2271 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80