awful.util: pread return error
[awesome.git] / client.c
blobf4620dd06a4f67f56e2e72ebe10882de3eead6f8
1 /*
2 * client.c - client management
4 * Copyright © 2007-2009 Julien Danjou <julien@danjou.info>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <xcb/xcb_atom.h>
23 #include <xcb/xcb_image.h>
25 #include "tag.h"
26 #include "ewmh.h"
27 #include "screen.h"
28 #include "titlebar.h"
29 #include "systray.h"
30 #include "property.h"
31 #include "spawn.h"
32 #include "luaa.h"
33 #include "common/atoms.h"
34 #include "common/xutil.h"
36 client_t *
37 luaA_client_checkudata(lua_State *L, int ud)
39 client_t *c = luaA_checkudata(L, ud, &client_class);
40 if(c->invalid)
41 luaL_error(L, "client is invalid\n");
42 return c;
45 /** Collect a client.
46 * \param L The Lua VM state.
47 * \return The number of element pushed on stack.
49 static int
50 luaA_client_gc(lua_State *L)
52 client_t *c = luaA_checkudata(L, 1, &client_class);
53 button_array_wipe(&c->buttons);
54 key_array_wipe(&c->keys);
55 xcb_get_wm_protocols_reply_wipe(&c->protocols);
56 p_delete(&c->class);
57 p_delete(&c->instance);
58 p_delete(&c->icon_name);
59 p_delete(&c->alt_icon_name);
60 p_delete(&c->name);
61 p_delete(&c->alt_name);
62 return luaA_object_gc(L);
65 /** Change the client opacity.
66 * \param L The Lua VM state.
67 * \param cidx The client index.
68 * \param opacity The opacity.
70 void
71 client_set_opacity(lua_State *L, int cidx, double opacity)
73 client_t *c = luaA_client_checkudata(L, cidx);
75 if(c->opacity != opacity)
77 c->opacity = opacity;
78 window_opacity_set(c->window, opacity);
79 luaA_object_emit_signal(L, cidx, "property::opacity", 0);
83 /** Change the clients urgency flag.
84 * \param L The Lua VM state.
85 * \param cidx The client index on the stack.
86 * \param urgent The new flag state.
88 void
89 client_set_urgent(lua_State *L, int cidx, bool urgent)
91 client_t *c = luaA_client_checkudata(L, cidx);
93 if(c->urgent != urgent)
95 xcb_get_property_cookie_t hints =
96 xcb_get_wm_hints_unchecked(globalconf.connection, c->window);
98 c->urgent = urgent;
99 ewmh_client_update_hints(c);
101 /* update ICCCM hints */
102 xcb_wm_hints_t wmh;
103 xcb_get_wm_hints_reply(globalconf.connection, hints, &wmh, NULL);
105 if(urgent)
106 wmh.flags |= XCB_WM_HINT_X_URGENCY;
107 else
108 wmh.flags &= ~XCB_WM_HINT_X_URGENCY;
110 xcb_set_wm_hints(globalconf.connection, c->window, &wmh);
112 hook_property(c, "urgent");
113 luaA_object_emit_signal(L, cidx, "property::urgent", 0);
117 void
118 client_set_group_window(lua_State *L, int cidx, xcb_window_t window)
120 client_t *c = luaA_client_checkudata(L, cidx);
122 if(c->group_window != window)
124 c->group_window = window;
125 luaA_object_emit_signal(L, cidx, "property::group_window", 0);
129 void
130 client_set_type(lua_State *L, int cidx, window_type_t type)
132 client_t *c = luaA_client_checkudata(L, cidx);
134 if(c->type != type)
136 c->type = type;
137 luaA_object_emit_signal(L, cidx, "property::type", 0);
141 void
142 client_set_pid(lua_State *L, int cidx, uint32_t pid)
144 client_t *c = luaA_client_checkudata(L, cidx);
146 if(c->pid != pid)
148 c->pid = pid;
149 luaA_object_emit_signal(L, cidx, "property::pid", 0);
153 void
154 client_set_icon_name(lua_State *L, int cidx, char *icon_name)
156 client_t *c = luaA_client_checkudata(L, cidx);
157 p_delete(&c->icon_name);
158 c->icon_name = icon_name;
159 luaA_object_emit_signal(L, cidx, "property::icon_name", 0);
160 hook_property(c, "icon_name");
163 void
164 client_set_alt_icon_name(lua_State *L, int cidx, char *icon_name)
166 client_t *c = luaA_client_checkudata(L, cidx);
167 p_delete(&c->alt_icon_name);
168 c->alt_icon_name = icon_name;
169 luaA_object_emit_signal(L, cidx, "property::icon_name", 0);
170 hook_property(c, "icon_name");
173 void
174 client_set_role(lua_State *L, int cidx, char *role)
176 client_t *c = luaA_client_checkudata(L, cidx);
177 p_delete(&c->role);
178 c->role = role;
179 luaA_object_emit_signal(L, cidx, "property::role", 0);
182 void
183 client_set_machine(lua_State *L, int cidx, char *machine)
185 client_t *c = luaA_client_checkudata(L, cidx);
186 p_delete(&c->machine);
187 c->machine = machine;
188 luaA_object_emit_signal(L, cidx, "property::machine", 0);
191 void
192 client_set_class_instance(lua_State *L, int cidx, const char *class, const char *instance)
194 client_t *c = luaA_client_checkudata(L, cidx);
195 p_delete(&c->class);
196 p_delete(&c->instance);
197 c->class = a_strdup(class);
198 c->instance = a_strdup(instance);
199 luaA_object_emit_signal(L, cidx, "property::class", 0);
200 luaA_object_emit_signal(L, cidx, "property::instance", 0);
203 void
204 client_set_transient_for(lua_State *L, int cidx, client_t *transient_for)
206 client_t *c = luaA_client_checkudata(L, cidx);
208 if(c->transient_for != transient_for)
210 c->transient_for = transient_for;
211 luaA_object_emit_signal(L, cidx, "property::transient_for", 0);
215 void
216 client_set_name(lua_State *L, int cidx, char *name)
218 client_t *c = luaA_client_checkudata(L, cidx);
219 p_delete(&c->name);
220 c->name = name;
221 hook_property(c, "name");
222 luaA_object_emit_signal(L, cidx, "property::name", 0);
225 void
226 client_set_alt_name(lua_State *L, int cidx, char *name)
228 client_t *c = luaA_client_checkudata(L, cidx);
229 p_delete(&c->alt_name);
230 c->alt_name = name;
231 hook_property(c, "name");
232 luaA_object_emit_signal(L, cidx, "property::name", 0);
235 /** Returns true if a client is tagged
236 * with one of the tags of the specified screen.
237 * \param c The client to check.
238 * \param screen Virtual screen.
239 * \return true if the client is visible, false otherwise.
241 bool
242 client_maybevisible(client_t *c, screen_t *screen)
244 if(screen && c->screen == screen)
246 if(c->sticky || c->type == WINDOW_TYPE_DESKTOP)
247 return true;
249 foreach(tag, screen->tags)
250 if(tag_get_selected(*tag) && is_client_tagged(c, *tag))
251 return true;
253 return false;
256 /** Get a client by its window.
257 * \param w The client window to find.
258 * \return A client pointer if found, NULL otherwise.
260 client_t *
261 client_getbywin(xcb_window_t w)
263 foreach(c, globalconf.clients)
264 if((*c)->window == w)
265 return *c;
267 return NULL;
270 /** Record that a client lost focus.
271 * \param c Client being unfocused
273 void
274 client_unfocus_update(client_t *c)
276 globalconf.screens.tab[c->phys_screen].client_focus = NULL;
277 ewmh_update_net_active_window(c->phys_screen);
279 /* Call hook */
280 if(globalconf.hooks.unfocus != LUA_REFNIL)
282 luaA_object_push(globalconf.L, c);
283 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.unfocus, 1, 0);
286 luaA_object_push(globalconf.L, c);
287 luaA_class_emit_signal(globalconf.L, &client_class, "unfocus", 1);
290 /** Unfocus a client.
291 * \param c The client.
293 void
294 client_unfocus(client_t *c)
297 xcb_window_t root_win = xutil_screen_get(globalconf.connection, c->phys_screen)->root;
298 /* Set focus on root window, so no events leak to the current window.
299 * This kind of inlines client_set_focus(), but a root window will never have
300 * the WM_TAKE_FOCUS protocol.
302 xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_PARENT,
303 root_win, XCB_CURRENT_TIME);
305 client_unfocus_update(c);
308 /** Check if client supports protocol a protocole in WM_PROTOCOL.
309 * \param c The client.
310 * \param atom The protocol atom to check for.
311 * \return True if client has the atom in protocol, false otherwise.
313 bool
314 client_hasproto(client_t *c, xcb_atom_t atom)
316 for(uint32_t i = 0; i < c->protocols.atoms_len; i++)
317 if(c->protocols.atoms[i] == atom)
318 return true;
319 return false;
322 /** Sets focus on window - using xcb_set_input_focus or WM_TAKE_FOCUS
323 * \param c Client that should get focus
324 * \param set_input_focus Should we call xcb_set_input_focus
326 void
327 client_set_focus(client_t *c, bool set_input_focus)
329 bool takefocus = client_hasproto(c, WM_TAKE_FOCUS);
330 if(set_input_focus)
331 xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_PARENT,
332 c->window, XCB_CURRENT_TIME);
333 if(takefocus)
334 window_takefocus(c->window);
337 /** Ban client and move it out of the viewport.
338 * \param c The client.
340 void
341 client_ban(client_t *c)
343 if(!c->isbanned)
345 xcb_unmap_window(globalconf.connection, c->window);
347 c->isbanned = true;
349 if(globalconf.screens.tab[c->phys_screen].prev_client_focus == c)
350 globalconf.screens.tab[c->phys_screen].prev_client_focus = NULL;
352 /* Wait until the last moment to take away the focus from the window. */
353 if(globalconf.screens.tab[c->phys_screen].client_focus == c)
354 client_unfocus(c);
358 /** This is part of The Bob Marley Algorithmm: we ignore enter and leave window
359 * in certain cases, like map/unmap or move, so we don't get spurious events.
361 void
362 client_ignore_enterleave_events(void)
364 foreach(c, globalconf.clients)
365 xcb_change_window_attributes(globalconf.connection,
366 (*c)->window,
367 XCB_CW_EVENT_MASK,
368 (const uint32_t []) { CLIENT_SELECT_INPUT_EVENT_MASK & ~(XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW) });
371 void
372 client_restore_enterleave_events(void)
374 foreach(c, globalconf.clients)
375 xcb_change_window_attributes(globalconf.connection,
376 (*c)->window,
377 XCB_CW_EVENT_MASK,
378 (const uint32_t []) { CLIENT_SELECT_INPUT_EVENT_MASK });
381 /** Record that a client got focus.
382 * \param c The client.
384 void
385 client_focus_update(client_t *c)
387 if(!client_maybevisible(c, c->screen))
389 /* Focus previously focused client */
390 client_focus(globalconf.screen_focus->prev_client_focus);
391 return;
394 if(globalconf.screen_focus
395 && globalconf.screen_focus->client_focus)
397 if (globalconf.screen_focus->client_focus != c)
398 client_unfocus_update(globalconf.screen_focus->client_focus);
399 else
400 /* Already focused */
401 return;
403 luaA_object_push(globalconf.L, c);
404 client_set_minimized(globalconf.L, -1, false);
406 /* unban the client before focusing for consistency */
407 client_unban(c);
409 globalconf.screen_focus = &globalconf.screens.tab[c->phys_screen];
410 globalconf.screen_focus->prev_client_focus = c;
411 globalconf.screen_focus->client_focus = c;
413 /* according to EWMH, we have to remove the urgent state from a client */
414 client_set_urgent(globalconf.L, -1, false);
416 ewmh_update_net_active_window(c->phys_screen);
418 /* execute hook */
419 if(globalconf.hooks.focus != LUA_REFNIL)
421 luaA_object_push(globalconf.L, c);
422 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.focus, 1, 0);
425 luaA_object_push(globalconf.L, c);
426 luaA_class_emit_signal(globalconf.L, &client_class, "focus", 1);
429 /** Give focus to client, or to first client if client is NULL.
430 * \param c The client.
432 void
433 client_focus(client_t *c)
435 /* We have to set focus on first client */
436 if(!c && globalconf.clients.len && !(c = globalconf.clients.tab[0]))
437 return;
439 if(!client_maybevisible(c, c->screen))
440 return;
442 if (!c->nofocus)
443 client_focus_update(c);
445 client_set_focus(c, !c->nofocus);
448 /** Stack a window below.
449 * \param c The client.
450 * \param previous The previous window on the stack.
451 * \return The next-previous!
453 static xcb_window_t
454 client_stack_above(client_t *c, xcb_window_t previous)
456 uint32_t config_win_vals[2];
458 config_win_vals[0] = previous;
459 config_win_vals[1] = XCB_STACK_MODE_ABOVE;
461 xcb_configure_window(globalconf.connection, c->window,
462 XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
463 config_win_vals);
465 config_win_vals[0] = c->window;
467 if(c->titlebar)
469 xcb_configure_window(globalconf.connection,
470 c->titlebar->window,
471 XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
472 config_win_vals);
473 previous = c->titlebar->window;
475 else
476 previous = c->window;
478 /* stack transient window on top of their parents */
479 foreach(node, globalconf.stack)
480 if((*node)->transient_for == c)
481 previous = client_stack_above(*node, previous);
483 return previous;
486 /** Stacking layout layers */
487 typedef enum
489 /** This one is a special layer */
490 LAYER_IGNORE,
491 LAYER_DESKTOP,
492 LAYER_BELOW,
493 LAYER_NORMAL,
494 LAYER_ABOVE,
495 LAYER_FULLSCREEN,
496 LAYER_ONTOP,
497 /** This one only used for counting and is not a real layer */
498 LAYER_COUNT
499 } layer_t;
501 /** Get the real layer of a client according to its attribute (fullscreen, …)
502 * \param c The client.
503 * \return The real layer.
505 static layer_t
506 client_layer_translator(client_t *c)
508 /* first deal with user set attributes */
509 if(c->ontop)
510 return LAYER_ONTOP;
511 else if(c->fullscreen)
512 return LAYER_FULLSCREEN;
513 else if(c->above)
514 return LAYER_ABOVE;
515 else if(c->below)
516 return LAYER_BELOW;
518 /* check for transient attr */
519 if(c->transient_for)
520 return LAYER_IGNORE;
522 /* then deal with windows type */
523 switch(c->type)
525 case WINDOW_TYPE_DESKTOP:
526 return LAYER_DESKTOP;
527 default:
528 break;
531 return LAYER_NORMAL;
534 /** Restack clients.
535 * \todo It might be worth stopping to restack everyone and only stack `c'
536 * relatively to the first matching in the list.
538 void
539 client_stack_refresh()
541 uint32_t config_win_vals[2];
542 layer_t layer;
544 if (!globalconf.client_need_stack_refresh)
545 return;
546 globalconf.client_need_stack_refresh = false;
548 config_win_vals[0] = XCB_NONE;
549 config_win_vals[1] = XCB_STACK_MODE_ABOVE;
551 /* stack desktop windows */
552 for(layer = LAYER_DESKTOP; layer < LAYER_BELOW; layer++)
553 foreach(node, globalconf.stack)
554 if(client_layer_translator(*node) == layer)
555 config_win_vals[0] = client_stack_above(*node,
556 config_win_vals[0]);
558 /* first stack not ontop wibox window */
559 foreach(_sb, globalconf.wiboxes)
561 wibox_t *sb = *_sb;
562 if(!sb->ontop)
564 xcb_configure_window(globalconf.connection,
565 sb->window,
566 XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
567 config_win_vals);
568 config_win_vals[0] = sb->window;
572 /* then stack clients */
573 for(layer = LAYER_BELOW; layer < LAYER_COUNT; layer++)
574 foreach(node, globalconf.stack)
575 if(client_layer_translator(*node) == layer)
576 config_win_vals[0] = client_stack_above(*node,
577 config_win_vals[0]);
579 /* then stack ontop wibox window */
580 foreach(_sb, globalconf.wiboxes)
582 wibox_t *sb = *_sb;
583 if(sb->ontop)
585 xcb_configure_window(globalconf.connection,
586 sb->window,
587 XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
588 config_win_vals);
589 config_win_vals[0] = sb->window;
594 /** Manage a new client.
595 * \param w The window.
596 * \param wgeom Window geometry.
597 * \param phys_screen Physical screen number.
598 * \param startup True if we are managing at startup time.
600 void
601 client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen, bool startup)
603 screen_t *screen;
604 const uint32_t select_input_val[] = { CLIENT_SELECT_INPUT_EVENT_MASK };
606 if(systray_iskdedockapp(w))
608 systray_request_handle(w, phys_screen, NULL);
609 return;
612 /* If this is a new client that just has been launched, then request its
613 * startup id. */
614 xcb_get_property_cookie_t startup_id_q = { 0 };
615 if(!startup)
616 startup_id_q = xcb_get_any_property(globalconf.connection,
617 false, w, _NET_STARTUP_ID, UINT_MAX);
619 xcb_change_window_attributes(globalconf.connection, w, XCB_CW_EVENT_MASK, select_input_val);
621 client_t *c = client_new(globalconf.L);
622 /* Push client in client list */
623 client_array_push(&globalconf.clients, luaA_object_ref(globalconf.L, -1));
626 screen = c->screen = screen_getbycoord(&globalconf.screens.tab[phys_screen],
627 wgeom->x, wgeom->y);
629 c->phys_screen = phys_screen;
631 /* consider the window banned */
632 c->isbanned = true;
634 /* Initial values */
635 c->window = w;
636 c->geometry.x = wgeom->x;
637 c->geometry.y = wgeom->y;
638 /* Border will be added later. */
639 c->geometry.width = wgeom->width;
640 c->geometry.height = wgeom->height;
641 /* Also set internal geometry (client_ban() needs it). */
642 c->geometries.internal.x = wgeom->x;
643 c->geometries.internal.y = wgeom->y;
644 c->geometries.internal.width = wgeom->width;
645 c->geometries.internal.height = wgeom->height;
647 /* Push client */
648 luaA_object_push(globalconf.L, c);
649 client_set_border_width(globalconf.L, -1, wgeom->border_width);
650 lua_pop(globalconf.L, 1);
652 /* we honor size hints by default */
653 c->size_hints_honor = true;
655 /* update hints */
656 property_update_wm_normal_hints(c, NULL);
657 property_update_wm_hints(c, NULL);
658 property_update_wm_transient_for(c, NULL);
659 property_update_wm_client_leader(c, NULL);
660 property_update_wm_client_machine(c, NULL);
661 property_update_wm_window_role(c, NULL);
662 property_update_net_wm_pid(c, NULL);
663 property_update_net_wm_icon(c, NULL);
665 /* get opacity */
666 c->opacity = window_opacity_get(c->window);
668 /* Then check clients hints */
669 ewmh_client_check_hints(c);
671 screen_client_moveto(c, screen, true);
673 /* Push client in stack */
674 client_raise(c);
676 /* update window title */
677 property_update_wm_name(c, NULL);
678 property_update_net_wm_name(c, NULL);
679 property_update_wm_icon_name(c, NULL);
680 property_update_net_wm_icon_name(c, NULL);
681 property_update_wm_class(c, NULL);
682 property_update_wm_protocols(c, NULL);
684 /* update strut */
685 ewmh_process_client_strut(c, NULL);
687 ewmh_update_net_client_list(c->phys_screen);
689 /* Always stay in NORMAL_STATE. Even though iconified seems more
690 * appropriate sometimes. The only possible loss is that clients not using
691 * visibility events may continue to proces data (when banned).
692 * Without any exposes or other events the cost should be fairly limited though.
694 * Some clients may expect the window to be unmapped when STATE_ICONIFIED.
695 * Two conflicting parts of the ICCCM v2.0 (section 4.1.4):
697 * "Normal -> Iconic - The client should send a ClientMessage event as described later in this section."
698 * (note no explicit mention of unmapping, while Normal->Widthdrawn does mention that)
700 * "Once a client's window has left the Withdrawn state, the window will be mapped
701 * if it is in the Normal state and the window will be unmapped if it is in the Iconic state."
703 * At this stage it's just safer to keep it in normal state and avoid confusion.
705 window_state_set(c->window, XCB_WM_STATE_NORMAL);
707 if(!startup)
709 /* Request our response */
710 xcb_get_property_reply_t *reply =
711 xcb_get_property_reply(globalconf.connection, startup_id_q, NULL);
712 /* Say spawn that a client has been started, with startup id as argument */
713 char *startup_id = xutil_get_text_property_from_reply(reply);
714 p_delete(&reply);
715 spawn_start_notify(c, startup_id);
716 p_delete(&startup_id);
719 /* Call hook to notify list change */
720 if(globalconf.hooks.clients != LUA_REFNIL)
721 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.clients, 0, 0);
723 luaA_class_emit_signal(globalconf.L, &client_class, "list", 0);
725 /* call hook */
726 if(globalconf.hooks.manage != LUA_REFNIL)
728 luaA_object_push(globalconf.L, c);
729 lua_pushboolean(globalconf.L, startup);
730 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.manage, 2, 0);
733 luaA_object_push(globalconf.L, c);
734 lua_pushboolean(globalconf.L, startup);
735 luaA_class_emit_signal(globalconf.L, &client_class, "manage", 2);
738 /** Compute client geometry with respect to its geometry hints.
739 * \param c The client.
740 * \param geometry The geometry that the client might receive.
741 * \return The geometry the client must take respecting its hints.
743 area_t
744 client_geometry_hints(client_t *c, area_t geometry)
746 int32_t basew, baseh, minw, minh;
748 /* base size is substituted with min size if not specified */
749 if(c->size_hints.flags & XCB_SIZE_HINT_P_SIZE)
751 basew = c->size_hints.base_width;
752 baseh = c->size_hints.base_height;
754 else if(c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)
756 basew = c->size_hints.min_width;
757 baseh = c->size_hints.min_height;
759 else
760 basew = baseh = 0;
762 /* min size is substituted with base size if not specified */
763 if(c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)
765 minw = c->size_hints.min_width;
766 minh = c->size_hints.min_height;
768 else if(c->size_hints.flags & XCB_SIZE_HINT_P_SIZE)
770 minw = c->size_hints.base_width;
771 minh = c->size_hints.base_height;
773 else
774 minw = minh = 0;
776 if(c->size_hints.flags & XCB_SIZE_HINT_P_ASPECT
777 && c->size_hints.min_aspect_num > 0
778 && c->size_hints.min_aspect_den > 0
779 && geometry.height - baseh > 0
780 && geometry.width - basew > 0)
782 double dx = (double) (geometry.width - basew);
783 double dy = (double) (geometry.height - baseh);
784 double min = (double) c->size_hints.min_aspect_num / (double) c->size_hints.min_aspect_den;
785 double max = (double) c->size_hints.max_aspect_num / (double) c->size_hints.min_aspect_den;
786 double ratio = dx / dy;
787 if(max > 0 && min > 0 && ratio > 0)
789 if(ratio < min)
791 dy = (dx * min + dy) / (min * min + 1);
792 dx = dy * min;
793 geometry.width = (int) dx + basew;
794 geometry.height = (int) dy + baseh;
796 else if(ratio > max)
798 dy = (dx * min + dy) / (max * max + 1);
799 dx = dy * min;
800 geometry.width = (int) dx + basew;
801 geometry.height = (int) dy + baseh;
806 if(minw)
807 geometry.width = MAX(geometry.width, minw);
808 if(minh)
809 geometry.height = MAX(geometry.height, minh);
811 if(c->size_hints.flags & XCB_SIZE_HINT_P_MAX_SIZE)
813 if(c->size_hints.max_width)
814 geometry.width = MIN(geometry.width, c->size_hints.max_width);
815 if(c->size_hints.max_height)
816 geometry.height = MIN(geometry.height, c->size_hints.max_height);
819 if(c->size_hints.flags & (XCB_SIZE_HINT_P_RESIZE_INC | XCB_SIZE_HINT_BASE_SIZE)
820 && c->size_hints.width_inc && c->size_hints.height_inc)
822 uint16_t t1 = geometry.width, t2 = geometry.height;
823 unsigned_subtract(t1, basew);
824 unsigned_subtract(t2, baseh);
825 geometry.width -= t1 % c->size_hints.width_inc;
826 geometry.height -= t2 % c->size_hints.height_inc;
829 return geometry;
832 /** Resize client window.
833 * The sizse given as parameters are with titlebar and borders!
834 * \param c Client to resize.
835 * \param geometry New window geometry.
836 * \param hints Use size hints.
837 * \return true if an actual resize occurred.
839 bool
840 client_resize(client_t *c, area_t geometry, bool hints)
842 area_t geometry_internal;
843 area_t area;
845 /* offscreen appearance fixes */
846 area = display_area_get(c->phys_screen);
848 if(geometry.x > area.width)
849 geometry.x = area.width - geometry.width;
850 if(geometry.y > area.height)
851 geometry.y = area.height - geometry.height;
852 if(geometry.x + geometry.width < 0)
853 geometry.x = 0;
854 if(geometry.y + geometry.height < 0)
855 geometry.y = 0;
857 /* Real client geometry, please keep it contained to C code at the very least. */
858 geometry_internal = titlebar_geometry_remove(c->titlebar, c->border_width, geometry);
860 if(hints)
861 geometry_internal = client_geometry_hints(c, geometry_internal);
863 if(geometry_internal.width == 0 || geometry_internal.height == 0)
864 return false;
866 /* Also let client hints propegate to the "official" geometry. */
867 geometry = titlebar_geometry_add(c->titlebar, c->border_width, geometry_internal);
869 if(c->geometries.internal.x != geometry_internal.x
870 || c->geometries.internal.y != geometry_internal.y
871 || c->geometries.internal.width != geometry_internal.width
872 || c->geometries.internal.height != geometry_internal.height)
874 screen_t *new_screen = screen_getbycoord(c->screen,
875 geometry_internal.x, geometry_internal.y);
877 /* Values to configure a window is an array where values are
878 * stored according to 'value_mask' */
879 uint32_t values[4];
881 c->geometries.internal.x = values[0] = geometry_internal.x;
882 c->geometries.internal.y = values[1] = geometry_internal.y;
883 c->geometries.internal.width = values[2] = geometry_internal.width;
884 c->geometries.internal.height = values[3] = geometry_internal.height;
886 /* Also store geometry including border and titlebar. */
887 c->geometry = geometry;
889 titlebar_update_geometry(c);
891 /* Ignore all spurious enter/leave notify events */
892 client_ignore_enterleave_events();
894 xcb_configure_window(globalconf.connection, c->window,
895 XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y
896 | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
897 values);
899 client_restore_enterleave_events();
901 screen_client_moveto(c, new_screen, false);
903 /* execute hook */
904 hook_property(c, "geometry");
906 return true;
909 return false;
912 /** Set a client minimized, or not.
913 * \param L The Lua VM state.
914 * \param cidx The client index.
915 * \param s Set or not the client minimized.
917 void
918 client_set_minimized(lua_State *L, int cidx, bool s)
920 client_t *c = luaA_client_checkudata(L, cidx);
922 if(c->minimized != s)
924 client_need_reban(c);
925 c->minimized = s;
926 client_need_reban(c);
927 if(s)
928 window_state_set(c->window, XCB_WM_STATE_ICONIC);
929 else
930 window_state_set(c->window, XCB_WM_STATE_NORMAL);
931 ewmh_client_update_hints(c);
932 /* execute hook */
933 hook_property(c, "minimized");
934 luaA_object_emit_signal(L, cidx, "property::minimized", 0);
938 /** Set a client sticky, or not.
939 * \param L The Lua VM state.
940 * \param cidx The client index.
941 * \param s Set or not the client sticky.
943 void
944 client_set_sticky(lua_State *L, int cidx, bool s)
946 client_t *c = luaA_client_checkudata(L, cidx);
948 if(c->sticky != s)
950 client_need_reban(c);
951 c->sticky = s;
952 client_need_reban(c);
953 ewmh_client_update_hints(c);
954 hook_property(c, "sticky");
955 luaA_object_emit_signal(L, cidx, "property::sticky", 0);
959 /** Set a client fullscreen, or not.
960 * \param L The Lua VM state.
961 * \param cidx The client index.
962 * \param s Set or not the client fullscreen.
964 void
965 client_set_fullscreen(lua_State *L, int cidx, bool s)
967 client_t *c = luaA_client_checkudata(L, cidx);
969 if(c->fullscreen != s)
971 area_t geometry;
973 /* become fullscreen! */
974 if(s)
976 /* Make sure the current geometry is stored without titlebar. */
977 titlebar_ban(c->titlebar);
978 /* remove any max state */
979 client_set_maximized_horizontal(L, cidx, false);
980 client_set_maximized_vertical(L, cidx, false);
981 /* You can only be part of one of the special layers. */
982 client_set_below(L, cidx, false);
983 client_set_above(L, cidx, false);
984 client_set_ontop(L, cidx, false);
986 geometry = screen_area_get(c->screen, false);
987 c->geometries.fullscreen = c->geometry;
988 c->border_width_fs = c->border_width;
989 client_set_border_width(L, cidx, 0);
990 c->fullscreen = true;
992 else
994 geometry = c->geometries.fullscreen;
995 c->fullscreen = false;
996 client_set_border_width(L, cidx, c->border_width_fs);
998 client_resize(c, geometry, false);
999 client_stack();
1000 ewmh_client_update_hints(c);
1001 hook_property(c, "fullscreen");
1002 luaA_object_emit_signal(L, cidx, "property::fullscreen", 0);
1006 /** Set a client horizontally maximized.
1007 * \param L The Lua VM state.
1008 * \param cidx The client index.
1009 * \param s The maximized status.
1011 void
1012 client_set_maximized_horizontal(lua_State *L, int cidx, bool s)
1014 client_t *c = luaA_client_checkudata(L, cidx);
1016 if(c->maximized_horizontal != s)
1018 area_t geometry;
1020 if((c->maximized_horizontal = s))
1022 /* remove fullscreen mode */
1023 client_set_fullscreen(L, cidx, false);
1025 geometry = screen_area_get(c->screen, true);
1026 geometry.y = c->geometry.y;
1027 geometry.height = c->geometry.height;
1028 c->geometries.max.x = c->geometry.x;
1029 c->geometries.max.width = c->geometry.width;
1031 else
1033 geometry = c->geometry;
1034 geometry.x = c->geometries.max.x;
1035 geometry.width = c->geometries.max.width;
1038 client_resize(c, geometry, c->size_hints_honor);
1039 client_stack();
1040 ewmh_client_update_hints(c);
1041 hook_property(c, "maximized_horizontal");
1042 luaA_object_emit_signal(L, cidx, "property::maximized_horizontal", 0);
1046 /** Set a client vertically 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_vertical(lua_State *L, int cidx, bool s)
1054 client_t *c = luaA_client_checkudata(L, cidx);
1056 if(c->maximized_vertical != s)
1058 area_t geometry;
1060 if((c->maximized_vertical = s))
1062 /* remove fullscreen mode */
1063 client_set_fullscreen(L, cidx, false);
1065 geometry = screen_area_get(c->screen, true);
1066 geometry.x = c->geometry.x;
1067 geometry.width = c->geometry.width;
1068 c->geometries.max.y = c->geometry.y;
1069 c->geometries.max.height = c->geometry.height;
1071 else
1073 geometry = c->geometry;
1074 geometry.y = c->geometries.max.y;
1075 geometry.height = c->geometries.max.height;
1078 client_resize(c, geometry, c->size_hints_honor);
1079 client_stack();
1080 ewmh_client_update_hints(c);
1081 hook_property(c, "maximized_vertical");
1082 luaA_object_emit_signal(L, cidx, "property::maximized_vertical", 0);
1086 /** Set a client above, or not.
1087 * \param L The Lua VM state.
1088 * \param cidx The client index.
1089 * \param s Set or not the client above.
1091 void
1092 client_set_above(lua_State *L, int cidx, bool s)
1094 client_t *c = luaA_client_checkudata(L, cidx);
1096 if(c->above != s)
1098 /* You can only be part of one of the special layers. */
1099 if(s)
1101 client_set_below(L, cidx, false);
1102 client_set_ontop(L, cidx, false);
1103 client_set_fullscreen(L, cidx, false);
1105 c->above = s;
1106 client_stack();
1107 ewmh_client_update_hints(c);
1108 /* execute hook */
1109 hook_property(c, "above");
1110 luaA_object_emit_signal(L, cidx, "property::above", 0);
1114 /** Set a client below, or not.
1115 * \param L The Lua VM state.
1116 * \param cidx The client index.
1117 * \param s Set or not the client below.
1119 void
1120 client_set_below(lua_State *L, int cidx, bool s)
1122 client_t *c = luaA_client_checkudata(L, cidx);
1124 if(c->below != s)
1126 /* You can only be part of one of the special layers. */
1127 if(s)
1129 client_set_above(L, cidx, false);
1130 client_set_ontop(L, cidx, false);
1131 client_set_fullscreen(L, cidx, false);
1133 c->below = s;
1134 client_stack();
1135 ewmh_client_update_hints(c);
1136 /* execute hook */
1137 hook_property(c, "below");
1138 luaA_object_emit_signal(L, cidx, "property::below", 0);
1142 /** Set a client modal, or not.
1143 * \param L The Lua VM state.
1144 * \param cidx The client index.
1145 * \param s Set or not the client modal attribute.
1147 void
1148 client_set_modal(lua_State *L, int cidx, bool s)
1150 client_t *c = luaA_client_checkudata(L, cidx);
1152 if(c->modal != s)
1154 c->modal = s;
1155 client_stack();
1156 ewmh_client_update_hints(c);
1157 /* execute hook */
1158 hook_property(c, "modal");
1159 luaA_object_emit_signal(L, cidx, "property::modal", 0);
1163 /** Set a client ontop, or not.
1164 * \param L The Lua VM state.
1165 * \param cidx The client index.
1166 * \param s Set or not the client ontop attribute.
1168 void
1169 client_set_ontop(lua_State *L, int cidx, bool s)
1171 client_t *c = luaA_client_checkudata(L, cidx);
1173 if(c->ontop != s)
1175 /* You can only be part of one of the special layers. */
1176 if(s)
1178 client_set_above(L, cidx, false);
1179 client_set_below(L, cidx, false);
1180 client_set_fullscreen(L, cidx, false);
1182 c->ontop = s;
1183 client_stack();
1184 /* execute hook */
1185 hook_property(c, "ontop");
1186 luaA_object_emit_signal(L, cidx, "property::ontop", 0);
1190 /** Set a client skip taskbar attribute.
1191 * \param L Tha Lua VM state.
1192 * \param cidx The client index.
1193 * \param s Set or not the client skip taskbar attribute.
1195 void
1196 client_set_skip_taskbar(lua_State *L, int cidx, bool s)
1198 client_t *c = luaA_client_checkudata(L, cidx);
1200 if(c->skip_taskbar != s)
1202 c->skip_taskbar = s;
1203 ewmh_client_update_hints(c);
1204 luaA_object_emit_signal(L, cidx, "property::skip_taskbar", 0);
1208 /** Unban a client and move it back into the viewport.
1209 * \param c The client.
1211 void
1212 client_unban(client_t *c)
1214 if(c->isbanned)
1216 xcb_map_window(globalconf.connection, c->window);
1218 c->isbanned = false;
1222 /** Unmanage a client.
1223 * \param c The client.
1225 void
1226 client_unmanage(client_t *c)
1228 tag_array_t *tags = &c->screen->tags;
1230 /* Reset transient_for attributes of widows that maybe refering to us */
1231 foreach(_tc, globalconf.clients)
1233 client_t *tc = *_tc;
1234 if(tc->transient_for == c)
1235 tc->transient_for = NULL;
1238 if(globalconf.screens.tab[c->phys_screen].prev_client_focus == c)
1239 globalconf.screens.tab[c->phys_screen].prev_client_focus = NULL;
1241 if(globalconf.screens.tab[c->phys_screen].client_focus == c)
1242 client_unfocus(c);
1244 /* remove client from global list and everywhere else */
1245 foreach(elem, globalconf.clients)
1246 if(*elem == c)
1248 client_array_remove(&globalconf.clients, elem);
1249 break;
1251 stack_client_remove(c);
1252 for(int i = 0; i < tags->len; i++)
1253 untag_client(c, tags->tab[i]);
1255 /* call hook */
1256 if(globalconf.hooks.unmanage != LUA_REFNIL)
1258 luaA_object_push(globalconf.L, c);
1259 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.unmanage, 1, 0);
1262 luaA_object_push(globalconf.L, c);
1263 luaA_class_emit_signal(globalconf.L, &client_class, "unmanage", 1);
1265 /* Call hook to notify list change */
1266 if(globalconf.hooks.clients != LUA_REFNIL)
1267 luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.clients, 0, 0);
1269 luaA_class_emit_signal(globalconf.L, &client_class, "list", 0);
1271 window_state_set(c->window, XCB_WM_STATE_WITHDRAWN);
1273 titlebar_client_detach(c);
1275 ewmh_update_net_client_list(c->phys_screen);
1277 /* set client as invalid */
1278 c->invalid = true;
1280 luaA_object_unref(globalconf.L, c);
1283 /** Kill a client via a WM_DELETE_WINDOW request or KillClient if not
1284 * supported.
1285 * \param c The client to kill.
1287 void
1288 client_kill(client_t *c)
1290 if(client_hasproto(c, WM_DELETE_WINDOW))
1292 xcb_client_message_event_t ev;
1294 /* Initialize all of event's fields first */
1295 p_clear(&ev, 1);
1297 ev.response_type = XCB_CLIENT_MESSAGE;
1298 ev.window = c->window;
1299 ev.format = 32;
1300 ev.data.data32[1] = XCB_CURRENT_TIME;
1301 ev.type = WM_PROTOCOLS;
1302 ev.data.data32[0] = WM_DELETE_WINDOW;
1304 xcb_send_event(globalconf.connection, false, c->window,
1305 XCB_EVENT_MASK_NO_EVENT, (char *) &ev);
1307 else
1308 xcb_kill_client(globalconf.connection, c->window);
1311 /** Get all clients into a table.
1312 * \param L The Lua VM state.
1313 * \return The number of elements pushed on stack.
1314 * \luastack
1315 * \lparam An optional screen nunmber.
1316 * \lreturn A table with all clients.
1318 static int
1319 luaA_client_get(lua_State *L)
1321 int i = 1, screen;
1323 screen = luaL_optnumber(L, 1, 0) - 1;
1325 lua_newtable(L);
1327 if(screen == -1)
1328 foreach(c, globalconf.clients)
1330 luaA_object_push(L, *c);
1331 lua_rawseti(L, -2, i++);
1333 else
1335 luaA_checkscreen(screen);
1336 foreach(c, globalconf.clients)
1337 if((*c)->screen == &globalconf.screens.tab[screen])
1339 luaA_object_push(L, *c);
1340 lua_rawseti(L, -2, i++);
1344 return 1;
1347 /** Check if a client is visible on its screen.
1348 * \param L The Lua VM state.
1349 * \return The number of elements pushed on stack.
1350 * \luastack
1351 * \lvalue A client.
1352 * \lreturn A boolean value, true if the client is visible, false otherwise.
1354 static int
1355 luaA_client_isvisible(lua_State *L)
1357 client_t *c = luaA_client_checkudata(L, 1);
1358 lua_pushboolean(L, client_isvisible(c, c->screen));
1359 return 1;
1362 /** Set client border width.
1363 * \param L The Lua VM state.
1364 * \param cidx The client index.
1365 * \param width The border width.
1367 void
1368 client_set_border_width(lua_State *L, int cidx, int width)
1370 client_t *c = luaA_client_checkudata(L, cidx);
1371 uint32_t w = width;
1373 if(width > 0 && (c->type == WINDOW_TYPE_DOCK
1374 || c->type == WINDOW_TYPE_SPLASH
1375 || c->type == WINDOW_TYPE_DESKTOP
1376 || c->fullscreen))
1377 return;
1379 if(width == c->border_width || width < 0)
1380 return;
1382 /* disallow change of border width if the client is fullscreen */
1383 if(c->fullscreen)
1384 return;
1386 /* Update geometry with the new border. */
1387 c->geometry.width -= 2 * c->border_width;
1388 c->geometry.height -= 2 * c->border_width;
1390 c->border_width = width;
1391 xcb_configure_window(globalconf.connection, c->window,
1392 XCB_CONFIG_WINDOW_BORDER_WIDTH, &w);
1394 c->geometry.width += 2 * c->border_width;
1395 c->geometry.height += 2 * c->border_width;
1397 /* Changing border size also affects the size of the titlebar. */
1398 titlebar_update_geometry(c);
1400 hook_property(c, "border_width");
1401 luaA_object_emit_signal(L, cidx, "property::border_width", 0);
1404 /** Set a client icon.
1405 * \param L The Lua VM state.
1406 * \param cidx The client index on the stack.
1407 * \para iidx The image index on the stack.
1409 void
1410 client_set_icon(lua_State *L, int cidx, int iidx)
1412 client_t *c = luaA_client_checkudata(L, cidx);
1413 /* convert index to absolute */
1414 cidx = luaA_absindex(L, cidx);
1415 iidx = luaA_absindex(L, iidx);
1416 luaA_checkudata(L, iidx, &image_class);
1417 luaA_object_unref_item(L, cidx, c->icon);
1418 c->icon = luaA_object_ref_item(L, cidx, iidx);
1419 luaA_object_emit_signal(L, cidx < iidx ? cidx : cidx - 1, "property::icon", 0);
1420 /* execute hook */
1421 hook_property(c, "icon");
1424 /** Kill a client.
1425 * \param L The Lua VM state.
1427 * \luastack
1428 * \lvalue A client.
1430 static int
1431 luaA_client_kill(lua_State *L)
1433 client_t *c = luaA_client_checkudata(L, 1);
1434 client_kill(c);
1435 return 0;
1438 /** Swap a client with another one.
1439 * \param L The Lua VM state.
1440 * \luastack
1441 * \lvalue A client.
1442 * \lparam A client to swap with.
1444 static int
1445 luaA_client_swap(lua_State *L)
1447 client_t *c = luaA_client_checkudata(L, 1);
1448 client_t *swap = luaA_client_checkudata(L, 2);
1450 if(c != swap)
1452 client_t **ref_c = NULL, **ref_swap = NULL;
1453 foreach(item, globalconf.clients)
1455 if(*item == c)
1456 ref_c = item;
1457 else if(*item == swap)
1458 ref_swap = item;
1459 if(ref_c && ref_swap)
1460 break;
1462 /* swap ! */
1463 *ref_c = swap;
1464 *ref_swap = c;
1466 /* Call hook to notify list change */
1467 if(globalconf.hooks.clients != LUA_REFNIL)
1468 luaA_dofunction_from_registry(L, globalconf.hooks.clients, 0, 0);
1470 luaA_class_emit_signal(globalconf.L, &client_class, "list", 0);
1473 return 0;
1476 /** Access or set the client tags.
1477 * \param L The Lua VM state.
1478 * \return The number of elements pushed on stack.
1479 * \lparam A table with tags to set, or none to get the current tags table.
1480 * \return The clients tag.
1482 static int
1483 luaA_client_tags(lua_State *L)
1485 client_t *c = luaA_client_checkudata(L, 1);
1486 tag_array_t *tags = &c->screen->tags;
1487 int j = 0;
1489 if(lua_gettop(L) == 2)
1491 luaA_checktable(L, 2);
1492 for(int i = 0; i < tags->len; i++)
1493 untag_client(c, tags->tab[i]);
1494 lua_pushnil(L);
1495 while(lua_next(L, 2))
1496 tag_client(c);
1497 lua_pop(L, 1);
1500 lua_newtable(L);
1501 foreach(tag, *tags)
1502 if(is_client_tagged(c, *tag))
1504 luaA_object_push(L, *tag);
1505 lua_rawseti(L, -2, ++j);
1508 return 1;
1511 /** Raise a client on top of others which are on the same layer.
1512 * \param L The Lua VM state.
1513 * \luastack
1514 * \lvalue A client.
1516 static int
1517 luaA_client_raise(lua_State *L)
1519 client_t *c = luaA_client_checkudata(L, 1);
1520 client_raise(c);
1521 return 0;
1524 /** Lower a client on bottom of others which are on the same layer.
1525 * \param L The Lua VM state.
1526 * \luastack
1527 * \lvalue A client.
1529 static int
1530 luaA_client_lower(lua_State *L)
1532 client_t *c = luaA_client_checkudata(L, 1);
1533 client_lower(c);
1534 return 0;
1537 /** Redraw a client by unmapping and mapping it quickly.
1538 * \param L The Lua VM state.
1540 * \luastack
1541 * \lvalue A client.
1543 static int
1544 luaA_client_redraw(lua_State *L)
1546 client_t *c = luaA_client_checkudata(L, 1);
1548 xcb_unmap_window(globalconf.connection, c->window);
1549 xcb_map_window(globalconf.connection, c->window);
1551 /* Set the focus on the current window if the redraw has been
1552 performed on the window where the pointer is currently on
1553 because after the unmapping/mapping, the focus is lost */
1554 if(globalconf.screen_focus->client_focus == c)
1556 client_unfocus(c);
1557 client_focus(c);
1560 return 0;
1563 /** Stop managing a client.
1564 * \param L The Lua VM state.
1565 * \return The number of elements pushed on stack.
1566 * \luastack
1567 * \lvalue A client.
1569 static int
1570 luaA_client_unmanage(lua_State *L)
1572 client_t *c = luaA_client_checkudata(L, 1);
1573 client_unmanage(c);
1574 return 0;
1577 /** Return client geometry.
1578 * \param L The Lua VM state.
1579 * \return The number of elements pushed on stack.
1580 * \luastack
1581 * \lparam A table with new coordinates, or none.
1582 * \lreturn A table with client coordinates.
1584 static int
1585 luaA_client_geometry(lua_State *L)
1587 client_t *c = luaA_client_checkudata(L, 1);
1589 if(lua_gettop(L) == 2)
1591 area_t geometry;
1593 luaA_checktable(L, 2);
1594 geometry.x = luaA_getopt_number(L, 2, "x", c->geometry.x);
1595 geometry.y = luaA_getopt_number(L, 2, "y", c->geometry.y);
1596 if(client_isfixed(c))
1598 geometry.width = c->geometry.width;
1599 geometry.height = c->geometry.height;
1601 else
1603 geometry.width = luaA_getopt_number(L, 2, "width", c->geometry.width);
1604 geometry.height = luaA_getopt_number(L, 2, "height", c->geometry.height);
1607 client_resize(c, geometry, c->size_hints_honor);
1610 return luaA_pusharea(L, c->geometry);
1613 /** Return client struts (reserved space at the edge of the screen).
1614 * \param L The Lua VM state.
1615 * \return The number of elements pushed on stack.
1616 * \luastack
1617 * \lparam A table with new strut values, or none.
1618 * \lreturn A table with strut values.
1620 static int
1621 luaA_client_struts(lua_State *L)
1623 client_t *c = luaA_client_checkudata(L, 1);
1625 if(lua_gettop(L) == 2)
1627 luaA_tostrut(L, 2, &c->strut);
1628 ewmh_update_strut(c->window, &c->strut);
1629 hook_property(c, "struts");
1630 luaA_object_emit_signal(L, 1, "property::struts", 0);
1631 screen_emit_signal(L, c->screen, "property::workarea", 0);
1634 return luaA_pushstrut(L, c->strut);
1637 static int
1638 luaA_client_set_screen(lua_State *L, client_t *c)
1640 if(globalconf.xinerama_is_active)
1642 int screen = luaL_checknumber(L, -1) - 1;
1643 luaA_checkscreen(screen);
1644 screen_client_moveto(c, &globalconf.screens.tab[screen], true);
1646 return 0;
1649 static int
1650 luaA_client_set_hidden(lua_State *L, client_t *c)
1652 bool b = luaA_checkboolean(L, -1);
1653 if(b != c->hidden)
1655 client_need_reban(c);
1656 c->hidden = b;
1657 client_need_reban(c);
1658 hook_property(c, "hidden");
1659 luaA_object_emit_signal(L, -3, "property::hidden", 0);
1661 return 0;
1664 static int
1665 luaA_client_set_minimized(lua_State *L, client_t *c)
1667 client_set_minimized(L, -3, luaA_checkboolean(L, -1));
1668 return 0;
1671 static int
1672 luaA_client_set_fullscreen(lua_State *L, client_t *c)
1674 client_set_fullscreen(L, -3, luaA_checkboolean(L, -1));
1675 return 0;
1678 static int
1679 luaA_client_set_modal(lua_State *L, client_t *c)
1681 client_set_modal(L, -3, luaA_checkboolean(L, -1));
1682 return 0;
1685 static int
1686 luaA_client_set_maximized_horizontal(lua_State *L, client_t *c)
1688 client_set_maximized_horizontal(L, -3, luaA_checkboolean(L, -1));
1689 return 0;
1692 static int
1693 luaA_client_set_maximized_vertical(lua_State *L, client_t *c)
1695 client_set_maximized_vertical(L, -3, luaA_checkboolean(L, -1));
1696 return 0;
1699 static int
1700 luaA_client_set_icon(lua_State *L, client_t *c)
1702 client_set_icon(L, -3, -1);
1703 return 0;
1706 static int
1707 luaA_client_set_opacity(lua_State *L, client_t *c)
1709 if(lua_isnil(L, -1))
1710 client_set_opacity(L, -3, -1);
1711 else
1712 client_set_opacity(L, -3, luaL_checknumber(L, -1));
1713 return 0;
1716 static int
1717 luaA_client_set_sticky(lua_State *L, client_t *c)
1719 client_set_sticky(L, -3, luaA_checkboolean(L, -1));
1720 return 0;
1723 static int
1724 luaA_client_set_size_hints_honor(lua_State *L, client_t *c)
1726 c->size_hints_honor = luaA_checkboolean(L, -1);
1727 hook_property(c, "size_hints_honor");
1728 luaA_object_emit_signal(L, -3, "property::size_hints_honor", 0);
1729 return 0;
1732 static int
1733 luaA_client_set_border_width(lua_State *L, client_t *c)
1735 client_set_border_width(L, -3, luaL_checknumber(L, -1));
1736 return 0;
1739 static int
1740 luaA_client_set_ontop(lua_State *L, client_t *c)
1742 client_set_ontop(L, -3, luaA_checkboolean(L, -1));
1743 return 0;
1746 static int
1747 luaA_client_set_below(lua_State *L, client_t *c)
1749 client_set_below(L, -3, luaA_checkboolean(L, -1));
1750 return 0;
1753 static int
1754 luaA_client_set_above(lua_State *L, client_t *c)
1756 client_set_above(L, -3, luaA_checkboolean(L, -1));
1757 return 0;
1760 static int
1761 luaA_client_set_urgent(lua_State *L, client_t *c)
1763 client_set_urgent(L, -3, luaA_checkboolean(L, -1));
1764 return 0;
1767 static int
1768 luaA_client_set_border_color(lua_State *L, client_t *c)
1770 size_t len;
1771 const char *buf;
1772 if((buf = luaL_checklstring(L, -1, &len))
1773 && xcolor_init_reply(xcolor_init_unchecked(&c->border_color, buf, len)))
1775 xcb_change_window_attributes(globalconf.connection, c->window,
1776 XCB_CW_BORDER_PIXEL, &c->border_color.pixel);
1777 luaA_object_emit_signal(L, -3, "property::border_color", 0);
1779 return 0;
1782 static int
1783 luaA_client_set_titlebar(lua_State *L, client_t *c)
1785 if(lua_isnil(L, -1))
1786 titlebar_client_detach(c);
1787 else
1788 titlebar_client_attach(c);
1789 return 0;
1792 static int
1793 luaA_client_set_skip_taskbar(lua_State *L, client_t *c)
1795 client_set_skip_taskbar(L, -3, luaA_checkboolean(L, -1));
1796 return 0;
1799 static int
1800 luaA_client_get_name(lua_State *L, client_t *c)
1802 lua_pushstring(L, c->name ? c->name : c->alt_name);
1803 return 1;
1806 static int
1807 luaA_client_get_icon_name(lua_State *L, client_t *c)
1809 lua_pushstring(L, c->icon_name ? c->icon_name : c->alt_icon_name);
1810 return 1;
1813 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, class, lua_pushstring)
1814 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, instance, lua_pushstring)
1815 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, machine, lua_pushstring)
1816 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, role, lua_pushstring)
1817 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, transient_for, luaA_object_push)
1818 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, skip_taskbar, lua_pushboolean)
1819 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, window, lua_pushnumber)
1820 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, leader_window, lua_pushnumber)
1821 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, group_window, lua_pushnumber)
1822 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, pid, lua_pushnumber)
1823 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, hidden, lua_pushboolean)
1824 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, minimized, lua_pushboolean)
1825 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, fullscreen, lua_pushboolean)
1826 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, modal, lua_pushboolean)
1827 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, ontop, lua_pushboolean)
1828 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, urgent, lua_pushboolean)
1829 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, above, lua_pushboolean)
1830 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, below, lua_pushboolean)
1831 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, sticky, lua_pushboolean)
1832 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, size_hints_honor, lua_pushboolean)
1833 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, maximized_horizontal, lua_pushboolean)
1834 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, maximized_vertical, lua_pushboolean)
1835 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, opacity, lua_pushnumber)
1836 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, border_width, lua_pushnumber)
1837 LUA_OBJECT_EXPORT_PROPERTY(client, client_t, border_color, luaA_pushxcolor)
1839 static int
1840 luaA_client_get_content(lua_State *L, client_t *c)
1842 xcb_image_t *ximage = xcb_image_get(globalconf.connection,
1843 c->window,
1844 0, 0,
1845 c->geometries.internal.width,
1846 c->geometries.internal.height,
1847 ~0, XCB_IMAGE_FORMAT_Z_PIXMAP);
1848 int retval = 0;
1850 if(ximage)
1852 if(ximage->bpp >= 24)
1854 uint32_t *data = p_alloca(uint32_t, ximage->width * ximage->height);
1856 for(int y = 0; y < ximage->height; y++)
1857 for(int x = 0; x < ximage->width; x++)
1859 data[y * ximage->width + x] = xcb_image_get_pixel(ximage, x, y);
1860 data[y * ximage->width + x] |= 0xff000000; /* set alpha to 0xff */
1863 retval = image_new_from_argb32(ximage->width, ximage->height, data);
1865 xcb_image_destroy(ximage);
1868 return retval;
1871 static int
1872 luaA_client_get_type(lua_State *L, client_t *c)
1874 switch(c->type)
1876 case WINDOW_TYPE_DESKTOP:
1877 lua_pushliteral(L, "desktop");
1878 break;
1879 case WINDOW_TYPE_DOCK:
1880 lua_pushliteral(L, "dock");
1881 break;
1882 case WINDOW_TYPE_SPLASH:
1883 lua_pushliteral(L, "splash");
1884 break;
1885 case WINDOW_TYPE_DIALOG:
1886 lua_pushliteral(L, "dialog");
1887 break;
1888 case WINDOW_TYPE_MENU:
1889 lua_pushliteral(L, "menu");
1890 break;
1891 case WINDOW_TYPE_TOOLBAR:
1892 lua_pushliteral(L, "toolbar");
1893 break;
1894 case WINDOW_TYPE_UTILITY:
1895 lua_pushliteral(L, "utility");
1896 break;
1897 case WINDOW_TYPE_DROPDOWN_MENU:
1898 lua_pushliteral(L, "dropdown_menu");
1899 break;
1900 case WINDOW_TYPE_POPUP_MENU:
1901 lua_pushliteral(L, "popup_menu");
1902 break;
1903 case WINDOW_TYPE_TOOLTIP:
1904 lua_pushliteral(L, "tooltip");
1905 break;
1906 case WINDOW_TYPE_NOTIFICATION:
1907 lua_pushliteral(L, "notification");
1908 break;
1909 case WINDOW_TYPE_COMBO:
1910 lua_pushliteral(L, "combo");
1911 break;
1912 case WINDOW_TYPE_DND:
1913 lua_pushliteral(L, "dnd");
1914 break;
1915 case WINDOW_TYPE_NORMAL:
1916 lua_pushliteral(L, "normal");
1917 break;
1919 return 1;
1922 static int
1923 luaA_client_get_screen(lua_State *L, client_t *c)
1925 lua_pushnumber(L, 1 + screen_array_indexof(&globalconf.screens, c->screen));
1926 return 1;
1929 static int
1930 luaA_client_get_icon(lua_State *L, client_t *c)
1932 return luaA_object_push_item(L, -2, c->icon);
1935 static int
1936 luaA_client_get_titlebar(lua_State *L, client_t *c)
1938 return luaA_object_push(L, c->titlebar);
1941 static int
1942 luaA_client_get_size_hints(lua_State *L, client_t *c)
1944 const char *u_or_p = NULL;
1946 lua_createtable(L, 0, 1);
1948 if(c->size_hints.flags & XCB_SIZE_HINT_US_POSITION)
1949 u_or_p = "user_position";
1950 else if(c->size_hints.flags & XCB_SIZE_HINT_P_POSITION)
1951 u_or_p = "program_position";
1953 if(u_or_p)
1955 lua_createtable(L, 0, 2);
1956 lua_pushnumber(L, c->size_hints.x);
1957 lua_setfield(L, -2, "x");
1958 lua_pushnumber(L, c->size_hints.y);
1959 lua_setfield(L, -2, "y");
1960 lua_setfield(L, -2, u_or_p);
1961 u_or_p = NULL;
1964 if(c->size_hints.flags & XCB_SIZE_HINT_US_SIZE)
1965 u_or_p = "user_size";
1966 else if(c->size_hints.flags & XCB_SIZE_HINT_P_SIZE)
1967 u_or_p = "program_size";
1969 if(u_or_p)
1971 lua_createtable(L, 0, 2);
1972 lua_pushnumber(L, c->size_hints.width);
1973 lua_setfield(L, -2, "width");
1974 lua_pushnumber(L, c->size_hints.height);
1975 lua_setfield(L, -2, "height");
1976 lua_setfield(L, -2, u_or_p);
1979 if(c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)
1981 lua_pushnumber(L, c->size_hints.min_width);
1982 lua_setfield(L, -2, "min_width");
1983 lua_pushnumber(L, c->size_hints.min_height);
1984 lua_setfield(L, -2, "min_height");
1987 if(c->size_hints.flags & XCB_SIZE_HINT_P_MAX_SIZE)
1989 lua_pushnumber(L, c->size_hints.max_width);
1990 lua_setfield(L, -2, "max_width");
1991 lua_pushnumber(L, c->size_hints.max_height);
1992 lua_setfield(L, -2, "max_height");
1995 if(c->size_hints.flags & XCB_SIZE_HINT_P_RESIZE_INC)
1997 lua_pushnumber(L, c->size_hints.width_inc);
1998 lua_setfield(L, -2, "width_inc");
1999 lua_pushnumber(L, c->size_hints.height_inc);
2000 lua_setfield(L, -2, "height_inc");
2003 if(c->size_hints.flags & XCB_SIZE_HINT_P_ASPECT)
2005 lua_pushnumber(L, c->size_hints.min_aspect_num);
2006 lua_setfield(L, -2, "min_aspect_num");
2007 lua_pushnumber(L, c->size_hints.min_aspect_den);
2008 lua_setfield(L, -2, "min_aspect_den");
2009 lua_pushnumber(L, c->size_hints.max_aspect_num);
2010 lua_setfield(L, -2, "max_aspect_num");
2011 lua_pushnumber(L, c->size_hints.max_aspect_den);
2012 lua_setfield(L, -2, "max_aspect_den");
2015 if(c->size_hints.flags & XCB_SIZE_HINT_BASE_SIZE)
2017 lua_pushnumber(L, c->size_hints.base_width);
2018 lua_setfield(L, -2, "base_width");
2019 lua_pushnumber(L, c->size_hints.base_height);
2020 lua_setfield(L, -2, "base_height");
2023 if(c->size_hints.flags & XCB_SIZE_HINT_P_WIN_GRAVITY)
2025 switch(c->size_hints.win_gravity)
2027 default:
2028 lua_pushliteral(L, "north_west");
2029 break;
2030 case XCB_GRAVITY_NORTH:
2031 lua_pushliteral(L, "north");
2032 break;
2033 case XCB_GRAVITY_NORTH_EAST:
2034 lua_pushliteral(L, "north_east");
2035 break;
2036 case XCB_GRAVITY_WEST:
2037 lua_pushliteral(L, "west");
2038 break;
2039 case XCB_GRAVITY_CENTER:
2040 lua_pushliteral(L, "center");
2041 break;
2042 case XCB_GRAVITY_EAST:
2043 lua_pushliteral(L, "east");
2044 break;
2045 case XCB_GRAVITY_SOUTH_WEST:
2046 lua_pushliteral(L, "south_west");
2047 break;
2048 case XCB_GRAVITY_SOUTH:
2049 lua_pushliteral(L, "south");
2050 break;
2051 case XCB_GRAVITY_SOUTH_EAST:
2052 lua_pushliteral(L, "south_east");
2053 break;
2054 case XCB_GRAVITY_STATIC:
2055 lua_pushliteral(L, "static");
2056 break;
2058 lua_setfield(L, -2, "win_gravity");
2061 return 1;
2064 /** Get or set mouse buttons bindings for a client.
2065 * \param L The Lua VM state.
2066 * \return The number of element pushed on stack.
2067 * \luastack
2068 * \lvalue A client.
2069 * \lparam An array of mouse button bindings objects, or nothing.
2070 * \return The array of mouse button bindings objects of this client.
2072 static int
2073 luaA_client_buttons(lua_State *L)
2075 client_t *client = luaA_client_checkudata(L, 1);
2076 button_array_t *buttons = &client->buttons;
2078 if(lua_gettop(L) == 2)
2080 luaA_button_array_set(L, 1, 2, buttons);
2081 luaA_object_emit_signal(L, 1, "property::buttons", 0);
2082 window_buttons_grab(client->window, &client->buttons);
2085 return luaA_button_array_get(L, 1, buttons);
2088 /** Get or set keys bindings for a client.
2089 * \param L The Lua VM state.
2090 * \return The number of element pushed on stack.
2091 * \luastack
2092 * \lvalue A client.
2093 * \lparam An array of key bindings objects, or nothing.
2094 * \return The array of key bindings objects of this client.
2096 static int
2097 luaA_client_keys(lua_State *L)
2099 client_t *c = luaA_client_checkudata(L, 1);
2100 key_array_t *keys = &c->keys;
2102 if(lua_gettop(L) == 2)
2104 luaA_key_array_set(L, 1, 2, keys);
2105 luaA_object_emit_signal(L, 1, "property::keys", 0);
2106 xcb_ungrab_key(globalconf.connection, XCB_GRAB_ANY, c->window, XCB_BUTTON_MASK_ANY);
2107 window_grabkeys(c->window, keys);
2110 return luaA_key_array_get(L, 1, keys);
2113 /* Client module.
2114 * \param L The Lua VM state.
2115 * \return The number of pushed elements.
2117 static int
2118 luaA_client_module_index(lua_State *L)
2120 size_t len;
2121 const char *buf = luaL_checklstring(L, 2, &len);
2123 switch(a_tokenize(buf, len))
2125 case A_TK_FOCUS:
2126 return luaA_object_push(globalconf.L, globalconf.screen_focus->client_focus);
2127 break;
2128 default:
2129 return 0;
2133 /* Client module new index.
2134 * \param L The Lua VM state.
2135 * \return The number of pushed elements.
2137 static int
2138 luaA_client_module_newindex(lua_State *L)
2140 size_t len;
2141 const char *buf = luaL_checklstring(L, 2, &len);
2142 client_t *c;
2144 switch(a_tokenize(buf, len))
2146 case A_TK_FOCUS:
2147 c = luaA_client_checkudata(L, 3);
2148 client_focus(c);
2149 break;
2150 default:
2151 break;
2154 return 0;
2157 void
2158 client_class_setup(lua_State *L)
2160 static const struct luaL_reg client_methods[] =
2162 LUA_CLASS_METHODS(client)
2163 { "get", luaA_client_get },
2164 { "__index", luaA_client_module_index },
2165 { "__newindex", luaA_client_module_newindex },
2166 { NULL, NULL }
2169 static const struct luaL_reg client_meta[] =
2171 LUA_OBJECT_META(client)
2172 LUA_CLASS_META
2173 { "buttons", luaA_client_buttons },
2174 { "keys", luaA_client_keys },
2175 { "isvisible", luaA_client_isvisible },
2176 { "geometry", luaA_client_geometry },
2177 { "struts", luaA_client_struts },
2178 { "tags", luaA_client_tags },
2179 { "kill", luaA_client_kill },
2180 { "swap", luaA_client_swap },
2181 { "raise", luaA_client_raise },
2182 { "lower", luaA_client_lower },
2183 { "redraw", luaA_client_redraw },
2184 { "unmanage", luaA_client_unmanage },
2185 { "__gc", luaA_client_gc },
2186 { NULL, NULL }
2189 luaA_class_setup(L, &client_class, "client", (lua_class_allocator_t) client_new,
2190 luaA_class_index_miss_property, luaA_class_newindex_miss_property,
2191 client_methods, client_meta);
2192 luaA_class_add_property(&client_class, A_TK_NAME,
2193 NULL,
2194 (lua_class_propfunc_t) luaA_client_get_name,
2195 NULL);
2196 luaA_class_add_property(&client_class, A_TK_TRANSIENT_FOR,
2197 NULL,
2198 (lua_class_propfunc_t) luaA_client_get_transient_for,
2199 NULL);
2200 luaA_class_add_property(&client_class, A_TK_SKIP_TASKBAR,
2201 (lua_class_propfunc_t) luaA_client_set_skip_taskbar,
2202 (lua_class_propfunc_t) luaA_client_get_skip_taskbar,
2203 (lua_class_propfunc_t) luaA_client_set_skip_taskbar);
2204 luaA_class_add_property(&client_class, A_TK_CONTENT,
2205 NULL,
2206 (lua_class_propfunc_t) luaA_client_get_content,
2207 NULL);
2208 luaA_class_add_property(&client_class, A_TK_TYPE,
2209 NULL,
2210 (lua_class_propfunc_t) luaA_client_get_type,
2211 NULL);
2212 luaA_class_add_property(&client_class, A_TK_CLASS,
2213 NULL,
2214 (lua_class_propfunc_t) luaA_client_get_class,
2215 NULL);
2216 luaA_class_add_property(&client_class, A_TK_INSTANCE,
2217 NULL,
2218 (lua_class_propfunc_t) luaA_client_get_instance,
2219 NULL);
2220 luaA_class_add_property(&client_class, A_TK_ROLE,
2221 NULL,
2222 (lua_class_propfunc_t) luaA_client_get_role,
2223 NULL);
2224 luaA_class_add_property(&client_class, A_TK_PID,
2225 NULL,
2226 (lua_class_propfunc_t) luaA_client_get_pid,
2227 NULL);
2228 luaA_class_add_property(&client_class, A_TK_WINDOW,
2229 NULL,
2230 (lua_class_propfunc_t) luaA_client_get_window,
2231 NULL);
2232 luaA_class_add_property(&client_class, A_TK_LEADER_WINDOW,
2233 NULL,
2234 (lua_class_propfunc_t) luaA_client_get_leader_window,
2235 NULL);
2236 luaA_class_add_property(&client_class, A_TK_MACHINE,
2237 NULL,
2238 (lua_class_propfunc_t) luaA_client_get_machine,
2239 NULL);
2240 luaA_class_add_property(&client_class, A_TK_ICON_NAME,
2241 NULL,
2242 (lua_class_propfunc_t) luaA_client_get_icon_name,
2243 NULL);
2244 luaA_class_add_property(&client_class, A_TK_SCREEN,
2245 NULL,
2246 (lua_class_propfunc_t) luaA_client_get_screen,
2247 (lua_class_propfunc_t) luaA_client_set_screen);
2248 luaA_class_add_property(&client_class, A_TK_HIDDEN,
2249 (lua_class_propfunc_t) luaA_client_set_hidden,
2250 (lua_class_propfunc_t) luaA_client_get_hidden,
2251 (lua_class_propfunc_t) luaA_client_set_hidden);
2252 luaA_class_add_property(&client_class, A_TK_MINIMIZED,
2253 (lua_class_propfunc_t) luaA_client_set_minimized,
2254 (lua_class_propfunc_t) luaA_client_get_minimized,
2255 (lua_class_propfunc_t) luaA_client_set_minimized);
2256 luaA_class_add_property(&client_class, A_TK_FULLSCREEN,
2257 (lua_class_propfunc_t) luaA_client_set_fullscreen,
2258 (lua_class_propfunc_t) luaA_client_get_fullscreen,
2259 (lua_class_propfunc_t) luaA_client_set_fullscreen);
2260 luaA_class_add_property(&client_class, A_TK_MODAL,
2261 (lua_class_propfunc_t) luaA_client_set_modal,
2262 (lua_class_propfunc_t) luaA_client_get_modal,
2263 (lua_class_propfunc_t) luaA_client_set_modal);
2264 luaA_class_add_property(&client_class, A_TK_GROUP_WINDOW,
2265 NULL,
2266 (lua_class_propfunc_t) luaA_client_get_group_window,
2267 NULL);
2268 luaA_class_add_property(&client_class, A_TK_MAXIMIZED_HORIZONTAL,
2269 (lua_class_propfunc_t) luaA_client_set_maximized_horizontal,
2270 (lua_class_propfunc_t) luaA_client_get_maximized_horizontal,
2271 (lua_class_propfunc_t) luaA_client_set_maximized_horizontal);
2272 luaA_class_add_property(&client_class, A_TK_MAXIMIZED_VERTICAL,
2273 (lua_class_propfunc_t) luaA_client_set_maximized_vertical,
2274 (lua_class_propfunc_t) luaA_client_get_maximized_vertical,
2275 (lua_class_propfunc_t) luaA_client_set_maximized_vertical);
2276 luaA_class_add_property(&client_class, A_TK_ICON,
2277 (lua_class_propfunc_t) luaA_client_set_icon,
2278 (lua_class_propfunc_t) luaA_client_get_icon,
2279 (lua_class_propfunc_t) luaA_client_set_icon);
2280 luaA_class_add_property(&client_class, A_TK_OPACITY,
2281 (lua_class_propfunc_t) luaA_client_set_opacity,
2282 (lua_class_propfunc_t) luaA_client_get_opacity,
2283 (lua_class_propfunc_t) luaA_client_set_opacity);
2284 luaA_class_add_property(&client_class, A_TK_ONTOP,
2285 (lua_class_propfunc_t) luaA_client_set_ontop,
2286 (lua_class_propfunc_t) luaA_client_get_ontop,
2287 (lua_class_propfunc_t) luaA_client_set_ontop);
2288 luaA_class_add_property(&client_class, A_TK_ABOVE,
2289 (lua_class_propfunc_t) luaA_client_set_above,
2290 (lua_class_propfunc_t) luaA_client_get_above,
2291 (lua_class_propfunc_t) luaA_client_set_above);
2292 luaA_class_add_property(&client_class, A_TK_BELOW,
2293 (lua_class_propfunc_t) luaA_client_set_below,
2294 (lua_class_propfunc_t) luaA_client_get_below,
2295 (lua_class_propfunc_t) luaA_client_set_below);
2296 luaA_class_add_property(&client_class, A_TK_STICKY,
2297 (lua_class_propfunc_t) luaA_client_set_sticky,
2298 (lua_class_propfunc_t) luaA_client_get_sticky,
2299 (lua_class_propfunc_t) luaA_client_set_sticky);
2300 luaA_class_add_property(&client_class, A_TK_SIZE_HINTS_HONOR,
2301 (lua_class_propfunc_t) luaA_client_set_size_hints_honor,
2302 (lua_class_propfunc_t) luaA_client_get_size_hints_honor,
2303 (lua_class_propfunc_t) luaA_client_set_size_hints_honor);
2304 luaA_class_add_property(&client_class, A_TK_BORDER_WIDTH,
2305 (lua_class_propfunc_t) luaA_client_set_border_width,
2306 (lua_class_propfunc_t) luaA_client_get_border_width,
2307 (lua_class_propfunc_t) luaA_client_set_border_width);
2308 luaA_class_add_property(&client_class, A_TK_BORDER_COLOR,
2309 (lua_class_propfunc_t) luaA_client_set_border_color,
2310 (lua_class_propfunc_t) luaA_client_get_border_color,
2311 (lua_class_propfunc_t) luaA_client_set_border_color);
2312 luaA_class_add_property(&client_class, A_TK_TITLEBAR,
2313 (lua_class_propfunc_t) luaA_client_set_titlebar,
2314 (lua_class_propfunc_t) luaA_client_get_titlebar,
2315 (lua_class_propfunc_t) luaA_client_set_titlebar);
2316 luaA_class_add_property(&client_class, A_TK_URGENT,
2317 (lua_class_propfunc_t) luaA_client_set_urgent,
2318 (lua_class_propfunc_t) luaA_client_get_urgent,
2319 (lua_class_propfunc_t) luaA_client_set_urgent);
2320 luaA_class_add_property(&client_class, A_TK_SIZE_HINTS,
2321 NULL,
2322 (lua_class_propfunc_t) luaA_client_get_size_hints,
2323 NULL);
2326 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80