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>
24 #include <xcb/shape.h>
25 #include <cairo-xcb.h>
27 #include "objects/tag.h"
35 #include "common/atoms.h"
36 #include "common/xutil.h"
38 static area_t
titlebar_get_area(client_t
*c
, client_titlebar_t bar
);
39 static drawable_t
*titlebar_get_drawable(lua_State
*L
, client_t
*c
, int cl_idx
, client_titlebar_t bar
);
42 * \param L The Lua VM state.
43 * \return The number of element pushed on stack.
46 client_wipe(client_t
*c
)
48 key_array_wipe(&c
->keys
);
49 xcb_icccm_get_wm_protocols_reply_wipe(&c
->protocols
);
50 p_delete(&c
->machine
);
52 p_delete(&c
->instance
);
53 p_delete(&c
->icon_name
);
54 p_delete(&c
->alt_icon_name
);
56 p_delete(&c
->alt_name
);
58 cairo_surface_destroy(c
->icon
);
61 /** Change the clients urgency flag.
62 * \param L The Lua VM state.
63 * \param cidx The client index on the stack.
64 * \param urgent The new flag state.
67 client_set_urgent(lua_State
*L
, int cidx
, bool urgent
)
69 client_t
*c
= luaA_checkudata(L
, cidx
, &client_class
);
71 if(c
->urgent
!= urgent
)
73 xcb_get_property_cookie_t hints
=
74 xcb_icccm_get_wm_hints_unchecked(globalconf
.connection
, c
->window
);
78 /* update ICCCM hints */
79 xcb_icccm_wm_hints_t wmh
;
80 xcb_icccm_get_wm_hints_reply(globalconf
.connection
, hints
, &wmh
, NULL
);
83 wmh
.flags
|= XCB_ICCCM_WM_HINT_X_URGENCY
;
85 wmh
.flags
&= ~XCB_ICCCM_WM_HINT_X_URGENCY
;
87 xcb_icccm_set_wm_hints(globalconf
.connection
, c
->window
, &wmh
);
89 luaA_object_emit_signal(L
, cidx
, "property::urgent", 0);
93 #define DO_CLIENT_SET_PROPERTY(prop) \
95 client_set_##prop(lua_State *L, int cidx, fieldtypeof(client_t, prop) value) \
97 client_t *c = luaA_checkudata(L, cidx, &client_class); \
98 if(c->prop != value) \
101 luaA_object_emit_signal(L, cidx, "property::" #prop, 0); \
104 DO_CLIENT_SET_PROPERTY(group_window
)
105 DO_CLIENT_SET_PROPERTY(type
)
106 DO_CLIENT_SET_PROPERTY(transient_for
)
107 DO_CLIENT_SET_PROPERTY(pid
)
108 DO_CLIENT_SET_PROPERTY(skip_taskbar
)
109 #undef DO_CLIENT_SET_PROPERTY
111 #define DO_CLIENT_SET_STRING_PROPERTY2(prop, signal) \
113 client_set_##prop(lua_State *L, int cidx, char *value) \
115 client_t *c = luaA_checkudata(L, cidx, &client_class); \
116 p_delete(&c->prop); \
118 luaA_object_emit_signal(L, cidx, "property::" #signal, 0); \
120 #define DO_CLIENT_SET_STRING_PROPERTY(prop) \
121 DO_CLIENT_SET_STRING_PROPERTY2(prop, prop)
122 DO_CLIENT_SET_STRING_PROPERTY(name
)
123 DO_CLIENT_SET_STRING_PROPERTY2(alt_name
, name
)
124 DO_CLIENT_SET_STRING_PROPERTY(icon_name
)
125 DO_CLIENT_SET_STRING_PROPERTY2(alt_icon_name
, icon_name
)
126 DO_CLIENT_SET_STRING_PROPERTY(role
)
127 DO_CLIENT_SET_STRING_PROPERTY(machine
)
128 #undef DO_CLIENT_SET_STRING_PROPERTY
131 client_set_class_instance(lua_State
*L
, int cidx
, const char *class, const char *instance
)
133 client_t
*c
= luaA_checkudata(L
, cidx
, &client_class
);
135 p_delete(&c
->instance
);
136 c
->class = a_strdup(class);
137 luaA_object_emit_signal(L
, cidx
, "property::class", 0);
138 c
->instance
= a_strdup(instance
);
139 luaA_object_emit_signal(L
, cidx
, "property::instance", 0);
142 /** Returns true if a client is tagged
143 * with one of the tags of the specified screen.
144 * \param c The client to check.
145 * \param screen Virtual screen.
146 * \return true if the client is visible, false otherwise.
149 client_maybevisible(client_t
*c
)
154 foreach(tag
, globalconf
.tags
)
155 if(tag_get_selected(*tag
) && is_client_tagged(c
, *tag
))
161 /** Get a client by its window.
162 * \param w The client window to find.
163 * \return A client pointer if found, NULL otherwise.
166 client_getbywin(xcb_window_t w
)
168 foreach(c
, globalconf
.clients
)
169 if((*c
)->window
== w
)
175 /** Get a client by its frame window.
176 * \param w The client window to find.
177 * \return A client pointer if found, NULL otherwise.
180 client_getbyframewin(xcb_window_t w
)
182 foreach(c
, globalconf
.clients
)
183 if((*c
)->frame_window
== w
)
189 /** Unfocus a client (internal).
190 * \param c The client.
193 client_unfocus_internal(client_t
*c
)
195 globalconf
.focus
.client
= NULL
;
197 luaA_object_push(globalconf
.L
, c
);
198 luaA_object_emit_signal(globalconf
.L
, -1, "unfocus", 0);
199 lua_pop(globalconf
.L
, 1);
202 /** Unfocus a client.
203 * \param c The client.
206 client_unfocus(client_t
*c
)
208 client_unfocus_internal(c
);
209 globalconf
.focus
.need_update
= true;
212 /** Check if client supports atom a protocol in WM_PROTOCOL.
213 * \param c The client.
214 * \param atom The protocol atom to check for.
215 * \return True if client has the atom in protocol, false otherwise.
218 client_hasproto(client_t
*c
, xcb_atom_t atom
)
220 for(uint32_t i
= 0; i
< c
->protocols
.atoms_len
; i
++)
221 if(c
->protocols
.atoms
[i
] == atom
)
226 /** Prepare banning a client by running all needed lua events.
227 * \param c The client.
229 void client_ban_unfocus(client_t
*c
)
231 /* Wait until the last moment to take away the focus from the window. */
232 if(globalconf
.focus
.client
== c
)
236 /** Ban client and move it out of the viewport.
237 * \param c The client.
240 client_ban(client_t
*c
)
244 xcb_unmap_window(globalconf
.connection
, c
->frame_window
);
248 client_ban_unfocus(c
);
252 /** This is part of The Bob Marley Algorithm: we ignore enter and leave window
253 * in certain cases, like map/unmap or move, so we don't get spurious events.
256 client_ignore_enterleave_events(void)
258 foreach(c
, globalconf
.clients
)
260 xcb_change_window_attributes(globalconf
.connection
,
263 (const uint32_t []) { CLIENT_SELECT_INPUT_EVENT_MASK
& ~(XCB_EVENT_MASK_ENTER_WINDOW
| XCB_EVENT_MASK_LEAVE_WINDOW
) });
264 xcb_change_window_attributes(globalconf
.connection
,
267 (const uint32_t []) { FRAME_SELECT_INPUT_EVENT_MASK
& ~(XCB_EVENT_MASK_ENTER_WINDOW
| XCB_EVENT_MASK_LEAVE_WINDOW
) });
272 client_restore_enterleave_events(void)
274 foreach(c
, globalconf
.clients
)
276 xcb_change_window_attributes(globalconf
.connection
,
279 (const uint32_t []) { CLIENT_SELECT_INPUT_EVENT_MASK
});
280 xcb_change_window_attributes(globalconf
.connection
,
283 (const uint32_t []) { FRAME_SELECT_INPUT_EVENT_MASK
});
287 /** Record that a client got focus.
288 * \param c The client.
291 client_focus_update(client_t
*c
)
293 if(!client_maybevisible(c
))
296 if(globalconf
.focus
.client
)
298 if (globalconf
.focus
.client
== c
)
299 /* Already focused */
302 /* When we are called due to a FocusIn event (=old focused client
303 * already unfocused), we don't want to cause a SetInputFocus,
304 * because the client which has focus now could be using globally
305 * active input model (or 'no input').
307 client_unfocus_internal(globalconf
.focus
.client
);
310 globalconf
.focus
.client
= c
;
312 /* according to EWMH, we have to remove the urgent state from a client */
313 luaA_object_push(globalconf
.L
, c
);
314 client_set_urgent(globalconf
.L
, -1, false);
316 luaA_object_emit_signal(globalconf
.L
, -1, "focus", 0);
317 lua_pop(globalconf
.L
, 1);
320 /** Give focus to client, or to first client if client is NULL.
321 * \param c The client.
324 client_focus(client_t
*c
)
326 /* We have to set focus on first client */
327 if(!c
&& globalconf
.clients
.len
&& !(c
= globalconf
.clients
.tab
[0]))
330 if(!client_maybevisible(c
) || c
== globalconf
.focus
.client
)
333 client_focus_update(c
);
334 globalconf
.focus
.need_update
= true;
338 client_focus_refresh(void)
340 client_t
*c
= globalconf
.focus
.client
;
341 xcb_window_t win
= globalconf
.screen
->root
;
343 if(!globalconf
.focus
.need_update
)
345 globalconf
.focus
.need_update
= false;
349 /* Make sure this window is unbanned and e.g. not minimized */
351 /* Sets focus on window - using xcb_set_input_focus or WM_TAKE_FOCUS */
355 /* Focus the root window to make sure the previously focused client
356 * doesn't get any input in case WM_TAKE_FOCUS gets ignored.
358 win
= globalconf
.screen
->root
;
360 if(client_hasproto(c
, WM_TAKE_FOCUS
))
361 xwindow_takefocus(c
->window
);
364 /* If nothing has the focused or the currently focused client doesn't want
365 * us to focus it, this sets the focus to the root window. This makes sure
366 * the previously focused client actually gets unfocused. Alternatively, the
367 * new client gets the input focus.
369 xcb_set_input_focus(globalconf
.connection
, XCB_INPUT_FOCUS_PARENT
,
370 win
, globalconf
.timestamp
);
374 client_update_properties(client_t
*c
)
377 xcb_get_property_cookie_t wm_normal_hints
= property_get_wm_normal_hints(c
);
378 xcb_get_property_cookie_t wm_hints
= property_get_wm_hints(c
);
379 xcb_get_property_cookie_t wm_transient_for
= property_get_wm_transient_for(c
);
380 xcb_get_property_cookie_t wm_client_leader
= property_get_wm_client_leader(c
);
381 xcb_get_property_cookie_t wm_client_machine
= property_get_wm_client_machine(c
);
382 xcb_get_property_cookie_t wm_window_role
= property_get_wm_window_role(c
);
383 xcb_get_property_cookie_t net_wm_pid
= property_get_net_wm_pid(c
);
384 xcb_get_property_cookie_t net_wm_icon
= property_get_net_wm_icon(c
);
385 xcb_get_property_cookie_t wm_name
= property_get_wm_name(c
);
386 xcb_get_property_cookie_t net_wm_name
= property_get_net_wm_name(c
);
387 xcb_get_property_cookie_t wm_icon_name
= property_get_wm_icon_name(c
);
388 xcb_get_property_cookie_t net_wm_icon_name
= property_get_net_wm_icon_name(c
);
389 xcb_get_property_cookie_t wm_class
= property_get_wm_class(c
);
390 xcb_get_property_cookie_t wm_protocols
= property_get_wm_protocols(c
);
391 xcb_get_property_cookie_t opacity
= xwindow_get_opacity_unchecked(c
->window
);
394 ewmh_process_client_strut(c
);
396 /* Now process all replies */
397 property_update_wm_normal_hints(c
, wm_normal_hints
);
398 property_update_wm_hints(c
, wm_hints
);
399 property_update_wm_transient_for(c
, wm_transient_for
);
400 property_update_wm_client_leader(c
, wm_client_leader
);
401 property_update_wm_client_machine(c
, wm_client_machine
);
402 property_update_wm_window_role(c
, wm_window_role
);
403 property_update_net_wm_pid(c
, net_wm_pid
);
404 property_update_net_wm_icon(c
, net_wm_icon
);
405 property_update_wm_name(c
, wm_name
);
406 property_update_net_wm_name(c
, net_wm_name
);
407 property_update_wm_icon_name(c
, wm_icon_name
);
408 property_update_net_wm_icon_name(c
, net_wm_icon_name
);
409 property_update_wm_class(c
, wm_class
);
410 property_update_wm_protocols(c
, wm_protocols
);
411 window_set_opacity(globalconf
.L
, -1, xwindow_get_opacity_from_cookie(opacity
));
414 /** Manage a new client.
415 * \param w The window.
416 * \param wgeom Window geometry.
417 * \param startup True if we are managing at startup time.
420 client_manage(xcb_window_t w
, xcb_get_geometry_reply_t
*wgeom
, bool startup
)
422 const uint32_t select_input_val
[] = { CLIENT_SELECT_INPUT_EVENT_MASK
};
424 if(systray_iskdedockapp(w
))
426 systray_request_handle(w
, NULL
);
430 /* If this is a new client that just has been launched, then request its
432 xcb_get_property_cookie_t startup_id_q
= { 0 };
434 startup_id_q
= xcb_get_property(globalconf
.connection
, false, w
,
435 _NET_STARTUP_ID
, XCB_GET_PROPERTY_TYPE_ANY
, 0, UINT_MAX
);
437 /* Make sure the window is automatically mapped if awesome exits or dies. */
438 xcb_change_save_set(globalconf
.connection
, XCB_SET_MODE_INSERT
, w
);
440 client_t
*c
= client_new(globalconf
.L
);
441 xcb_screen_t
*s
= globalconf
.screen
;
443 /* consider the window banned */
447 c
->frame_window
= xcb_generate_id(globalconf
.connection
);
448 xcb_create_window(globalconf
.connection
, globalconf
.default_depth
, c
->frame_window
, s
->root
,
449 wgeom
->x
, wgeom
->y
, wgeom
->width
, wgeom
->height
,
450 wgeom
->border_width
, XCB_COPY_FROM_PARENT
, globalconf
.visual
->visual_id
,
451 XCB_CW_BACK_PIXEL
| XCB_CW_BORDER_PIXEL
| XCB_CW_BIT_GRAVITY
452 | XCB_CW_WIN_GRAVITY
| XCB_CW_OVERRIDE_REDIRECT
| XCB_CW_EVENT_MASK
456 globalconf
.screen
->black_pixel
,
457 globalconf
.screen
->black_pixel
,
458 XCB_GRAVITY_NORTH_WEST
,
459 XCB_GRAVITY_NORTH_WEST
,
461 FRAME_SELECT_INPUT_EVENT_MASK
,
462 globalconf
.default_cmap
467 /* The client is already mapped, thus we must be sure that we don't send
468 * ourselves an UnmapNotify due to the xcb_reparent_window().
470 * Grab the server to make sure we don't lose any events.
472 uint32_t no_event
[] = { 0 };
473 xcb_grab_server(globalconf
.connection
);
475 xcb_change_window_attributes(globalconf
.connection
,
476 globalconf
.screen
->root
,
481 xcb_reparent_window(globalconf
.connection
, w
, c
->frame_window
, 0, 0);
482 xcb_map_window(globalconf
.connection
, w
);
486 xcb_change_window_attributes(globalconf
.connection
,
487 globalconf
.screen
->root
,
489 ROOT_WINDOW_EVENT_MASK
);
490 xcb_ungrab_server(globalconf
.connection
);
493 /* Do this now so that we don't get any events for the above
494 * (Else, reparent could cause an UnmapNotify) */
495 xcb_change_window_attributes(globalconf
.connection
, w
, XCB_CW_EVENT_MASK
, select_input_val
);
497 luaA_object_emit_signal(globalconf
.L
, -1, "property::window", 0);
499 /* The frame window gets the border, not the real client window */
500 xcb_configure_window(globalconf
.connection
, w
,
501 XCB_CONFIG_WINDOW_BORDER_WIDTH
,
504 /* Move this window to the bottom of the stack. Without this we would force
505 * other windows which will be above this one to redraw themselves because
506 * this window occludes them for a tiny moment. The next stack_refresh()
507 * will fix this up and move the window to its correct place. */
508 xcb_configure_window(globalconf
.connection
, c
->frame_window
,
509 XCB_CONFIG_WINDOW_STACK_MODE
,
510 (uint32_t[]) { XCB_STACK_MODE_BELOW
});
512 /* Duplicate client and push it in client list */
513 lua_pushvalue(globalconf
.L
, -1);
514 client_array_push(&globalconf
.clients
, luaA_object_ref(globalconf
.L
, -1));
516 /* Set the right screen */
517 screen_client_moveto(c
, screen_getbycoord(wgeom
->x
, wgeom
->y
), false);
519 /* Store initial geometry and emits signals so we inform that geometry have
521 #define HANDLE_GEOM(attr) \
522 c->geometry.attr = wgeom->attr; \
523 luaA_object_emit_signal(globalconf.L, -1, "property::" #attr, 0);
530 luaA_object_emit_signal(globalconf
.L
, -1, "property::geometry", 0);
532 /* Set border width */
533 window_set_border_width(globalconf
.L
, -1, wgeom
->border_width
);
535 /* we honor size hints by default */
536 c
->size_hints_honor
= true;
537 luaA_object_emit_signal(globalconf
.L
, -1, "property::size_hints_honor", 0);
539 /* update all properties */
540 client_update_properties(c
);
542 /* Then check clients hints */
543 ewmh_client_check_hints(c
);
545 /* Push client in stack */
548 /* Always stay in NORMAL_STATE. Even though iconified seems more
549 * appropriate sometimes. The only possible loss is that clients not using
550 * visibility events may continue to process data (when banned).
551 * Without any exposes or other events the cost should be fairly limited though.
553 * Some clients may expect the window to be unmapped when STATE_ICONIFIED.
554 * Two conflicting parts of the ICCCM v2.0 (section 4.1.4):
556 * "Normal -> Iconic - The client should send a ClientMessage event as described later in this section."
557 * (note no explicit mention of unmapping, while Normal->Widthdrawn does mention that)
559 * "Once a client's window has left the Withdrawn state, the window will be mapped
560 * if it is in the Normal state and the window will be unmapped if it is in the Iconic state."
562 * At this stage it's just safer to keep it in normal state and avoid confusion.
564 xwindow_set_state(c
->window
, XCB_ICCCM_WM_STATE_NORMAL
);
568 /* Request our response */
569 xcb_get_property_reply_t
*reply
=
570 xcb_get_property_reply(globalconf
.connection
, startup_id_q
, NULL
);
571 /* Say spawn that a client has been started, with startup id as argument */
572 char *startup_id
= xutil_get_text_property_from_reply(reply
);
574 spawn_start_notify(c
, startup_id
);
575 p_delete(&startup_id
);
578 luaA_class_emit_signal(globalconf
.L
, &client_class
, "list", 0);
580 /* client is still on top of the stack; push startup value,
581 * and emit signals with one arg */
582 lua_pushboolean(globalconf
.L
, startup
);
583 luaA_object_emit_signal(globalconf
.L
, -2, "manage", 1);
585 lua_pop(globalconf
.L
, 1);
589 client_remove_titlebar_geometry(client_t
*c
, area_t
*geometry
)
591 geometry
->x
+= c
->titlebar
[CLIENT_TITLEBAR_LEFT
].size
;
592 geometry
->y
+= c
->titlebar
[CLIENT_TITLEBAR_TOP
].size
;
593 geometry
->width
-= c
->titlebar
[CLIENT_TITLEBAR_LEFT
].size
;
594 geometry
->width
-= c
->titlebar
[CLIENT_TITLEBAR_RIGHT
].size
;
595 geometry
->height
-= c
->titlebar
[CLIENT_TITLEBAR_TOP
].size
;
596 geometry
->height
-= c
->titlebar
[CLIENT_TITLEBAR_BOTTOM
].size
;
600 client_add_titlebar_geometry(client_t
*c
, area_t
*geometry
)
602 geometry
->x
-= c
->titlebar
[CLIENT_TITLEBAR_LEFT
].size
;
603 geometry
->y
-= c
->titlebar
[CLIENT_TITLEBAR_TOP
].size
;
604 geometry
->width
+= c
->titlebar
[CLIENT_TITLEBAR_LEFT
].size
;
605 geometry
->width
+= c
->titlebar
[CLIENT_TITLEBAR_RIGHT
].size
;
606 geometry
->height
+= c
->titlebar
[CLIENT_TITLEBAR_TOP
].size
;
607 geometry
->height
+= c
->titlebar
[CLIENT_TITLEBAR_BOTTOM
].size
;
610 /** Send a synthetic configure event to a window.
613 client_send_configure(client_t
*c
)
615 area_t geometry
= c
->geometry
;
617 client_remove_titlebar_geometry(c
, &geometry
);
618 xwindow_configure(c
->window
, geometry
, c
->border_width
);
621 /** Apply size hints to the client's new geometry.
624 client_apply_size_hints(client_t
*c
, area_t geometry
)
626 int32_t minw
= 0, minh
= 0;
627 int32_t basew
= 0, baseh
= 0, real_basew
= 0, real_baseh
= 0;
632 /* Size hints are applied to the window without any decoration */
633 client_remove_titlebar_geometry(c
, &geometry
);
635 if(c
->size_hints
.flags
& XCB_ICCCM_SIZE_HINT_P_SIZE
)
637 basew
= c
->size_hints
.base_width
;
638 baseh
= c
->size_hints
.base_height
;
642 else if(c
->size_hints
.flags
& XCB_ICCCM_SIZE_HINT_P_MIN_SIZE
)
644 /* base size is substituted with min size if not specified */
645 basew
= c
->size_hints
.min_width
;
646 baseh
= c
->size_hints
.min_height
;
649 if(c
->size_hints
.flags
& XCB_ICCCM_SIZE_HINT_P_MIN_SIZE
)
651 minw
= c
->size_hints
.min_width
;
652 minh
= c
->size_hints
.min_height
;
654 else if(c
->size_hints
.flags
& XCB_ICCCM_SIZE_HINT_P_SIZE
)
656 /* min size is substituted with base size if not specified */
657 minw
= c
->size_hints
.base_width
;
658 minh
= c
->size_hints
.base_height
;
661 /* Handle the size aspect ratio */
662 if(c
->size_hints
.flags
& XCB_ICCCM_SIZE_HINT_P_ASPECT
663 && c
->size_hints
.min_aspect_den
> 0
664 && c
->size_hints
.max_aspect_den
> 0
665 && geometry
.height
> real_baseh
666 && geometry
.width
> real_basew
)
669 * If a base size is provided along with the aspect ratio fields, the base size should be subtracted from the
670 * window size prior to checking that the aspect ratio falls in range. If a base size is not provided, nothing
671 * should be subtracted from the window size. (The minimum size is not to be used in place of the base size for
674 double dx
= geometry
.width
- real_basew
;
675 double dy
= geometry
.height
- real_baseh
;
676 double ratio
= dx
/ dy
;
677 double min
= c
->size_hints
.min_aspect_num
/ (double) c
->size_hints
.min_aspect_den
;
678 double max
= c
->size_hints
.max_aspect_num
/ (double) c
->size_hints
.max_aspect_den
;
680 if(max
> 0 && min
> 0 && ratio
> 0)
684 /* dx is lower than allowed, make dy lower to compensate this (+ 0.5 to force proper rounding). */
686 geometry
.width
= dx
+ real_basew
;
687 geometry
.height
= dy
+ real_baseh
;
688 } else if(ratio
> max
)
690 /* dx is too high, lower it (+0.5 for proper rounding) */
692 geometry
.width
= dx
+ real_basew
;
693 geometry
.height
= dy
+ real_baseh
;
698 /* Handle the minimum size */
699 geometry
.width
= MAX(geometry
.width
, minw
);
700 geometry
.height
= MAX(geometry
.height
, minh
);
702 /* Handle the maximum size */
703 if(c
->size_hints
.flags
& XCB_ICCCM_SIZE_HINT_P_MAX_SIZE
)
705 if(c
->size_hints
.max_width
)
706 geometry
.width
= MIN(geometry
.width
, c
->size_hints
.max_width
);
707 if(c
->size_hints
.max_height
)
708 geometry
.height
= MIN(geometry
.height
, c
->size_hints
.max_height
);
711 /* Handle the size increment */
712 if(c
->size_hints
.flags
& (XCB_ICCCM_SIZE_HINT_P_RESIZE_INC
| XCB_ICCCM_SIZE_HINT_BASE_SIZE
)
713 && c
->size_hints
.width_inc
&& c
->size_hints
.height_inc
)
715 uint16_t t1
= geometry
.width
, t2
= geometry
.height
;
716 unsigned_subtract(t1
, basew
);
717 unsigned_subtract(t2
, baseh
);
718 geometry
.width
-= t1
% c
->size_hints
.width_inc
;
719 geometry
.height
-= t2
% c
->size_hints
.height_inc
;
722 client_add_titlebar_geometry(c
, &geometry
);
727 client_resize_do(client_t
*c
, area_t geometry
, bool force_notice
, bool honor_hints
)
729 bool send_notice
= force_notice
;
730 bool hide_titlebars
= c
->fullscreen
;
731 screen_t
*new_screen
= screen_getbycoord(geometry
.x
, geometry
.y
);
734 geometry
= client_apply_size_hints(c
, geometry
);
736 if(c
->geometry
.width
== geometry
.width
737 && c
->geometry
.height
== geometry
.height
)
740 /* Also store geometry including border */
741 area_t old_geometry
= c
->geometry
;
742 c
->geometry
= geometry
;
744 /* Ignore all spurious enter/leave notify events */
745 client_ignore_enterleave_events();
747 /* Configure the client for its new size */
748 area_t real_geometry
= geometry
;
751 real_geometry
.x
= c
->titlebar
[CLIENT_TITLEBAR_LEFT
].size
;
752 real_geometry
.y
= c
->titlebar
[CLIENT_TITLEBAR_TOP
].size
;
753 real_geometry
.width
-= c
->titlebar
[CLIENT_TITLEBAR_LEFT
].size
;
754 real_geometry
.width
-= c
->titlebar
[CLIENT_TITLEBAR_RIGHT
].size
;
755 real_geometry
.height
-= c
->titlebar
[CLIENT_TITLEBAR_TOP
].size
;
756 real_geometry
.height
-= c
->titlebar
[CLIENT_TITLEBAR_BOTTOM
].size
;
762 xcb_configure_window(globalconf
.connection
, c
->frame_window
,
763 XCB_CONFIG_WINDOW_X
| XCB_CONFIG_WINDOW_Y
| XCB_CONFIG_WINDOW_WIDTH
| XCB_CONFIG_WINDOW_HEIGHT
,
764 (uint32_t[]) { geometry
.x
, geometry
.y
, geometry
.width
, geometry
.height
});
765 xcb_configure_window(globalconf
.connection
, c
->window
,
766 XCB_CONFIG_WINDOW_X
| XCB_CONFIG_WINDOW_Y
| XCB_CONFIG_WINDOW_WIDTH
| XCB_CONFIG_WINDOW_HEIGHT
,
767 (uint32_t[]) { real_geometry
.x
, real_geometry
.y
, real_geometry
.width
, real_geometry
.height
});
770 /* We are moving without changing the size, see ICCCM 4.2.3 */
771 client_send_configure(c
);
773 client_restore_enterleave_events();
775 screen_client_moveto(c
, new_screen
, false);
777 luaA_object_push(globalconf
.L
, c
);
778 luaA_object_emit_signal(globalconf
.L
, -1, "property::geometry", 0);
779 if (old_geometry
.x
!= geometry
.x
)
780 luaA_object_emit_signal(globalconf
.L
, -1, "property::x", 0);
781 if (old_geometry
.y
!= geometry
.y
)
782 luaA_object_emit_signal(globalconf
.L
, -1, "property::y", 0);
783 if (old_geometry
.width
!= geometry
.width
)
784 luaA_object_emit_signal(globalconf
.L
, -1, "property::width", 0);
785 if (old_geometry
.height
!= geometry
.height
)
786 luaA_object_emit_signal(globalconf
.L
, -1, "property::height", 0);
787 lua_pop(globalconf
.L
, 1);
789 /* Update all titlebars */
790 for (client_titlebar_t bar
= CLIENT_TITLEBAR_TOP
; bar
< CLIENT_TITLEBAR_COUNT
; bar
++) {
791 if (c
->titlebar
[bar
].drawable
== NULL
&& c
->titlebar
[bar
].size
== 0)
794 luaA_object_push(globalconf
.L
, c
);
795 drawable_t
*drawable
= titlebar_get_drawable(globalconf
.L
, c
, -1, bar
);
796 luaA_object_push_item(globalconf
.L
, -1, drawable
);
798 area_t area
= titlebar_get_area(c
, bar
);
800 /* Convert to global coordinates */
801 area
.x
+= geometry
.x
;
802 area
.y
+= geometry
.y
;
804 area
.width
= area
.height
= 0;
806 if (old_geometry
.width
!= geometry
.width
|| old_geometry
.height
!= geometry
.height
||
807 drawable
->geometry
.width
== 0 || drawable
->geometry
.height
== 0) {
808 /* Get rid of the old state */
809 drawable_unset_surface(drawable
);
810 if (c
->titlebar
[bar
].pixmap
!= XCB_NONE
)
811 xcb_free_pixmap(globalconf
.connection
, c
->titlebar
[bar
].pixmap
);
812 c
->titlebar
[bar
].pixmap
= XCB_NONE
;
814 /* And get us some new state */
815 if (c
->titlebar
[bar
].size
!= 0 && !hide_titlebars
)
817 c
->titlebar
[bar
].pixmap
= xcb_generate_id(globalconf
.connection
);
818 xcb_create_pixmap(globalconf
.connection
, globalconf
.default_depth
, c
->titlebar
[bar
].pixmap
,
819 globalconf
.screen
->root
, area
.width
, area
.height
);
820 cairo_surface_t
*surface
= cairo_xcb_surface_create(globalconf
.connection
,
821 c
->titlebar
[bar
].pixmap
, globalconf
.visual
,
822 area
.width
, area
.height
);
823 drawable_set_surface(drawable
, -1, surface
, area
);
825 drawable_set_geometry(drawable
, -1, area
);
827 drawable_set_geometry(drawable
, -1, area
);
829 /* Pop the client and the drawable */
830 lua_pop(globalconf
.L
, 2);
834 /** Resize client window.
835 * The sizes given as parameters are with borders!
836 * \param c Client to resize.
837 * \param geometry New window geometry.
838 * \param honor_hints Use size hints.
839 * \return true if an actual resize occurred.
842 client_resize(client_t
*c
, area_t geometry
, bool honor_hints
)
846 /* offscreen appearance fixes */
847 area
= display_area_get();
849 if(geometry
.x
> area
.width
)
850 geometry
.x
= area
.width
- geometry
.width
;
851 if(geometry
.y
> area
.height
)
852 geometry
.y
= area
.height
- geometry
.height
;
853 if(geometry
.x
+ geometry
.width
< 0)
855 if(geometry
.y
+ geometry
.height
< 0)
858 if(geometry
.width
< c
->titlebar
[CLIENT_TITLEBAR_LEFT
].size
+ c
->titlebar
[CLIENT_TITLEBAR_RIGHT
].size
)
860 if(geometry
.height
< c
->titlebar
[CLIENT_TITLEBAR_TOP
].size
+ c
->titlebar
[CLIENT_TITLEBAR_BOTTOM
].size
)
863 if(geometry
.width
== 0 || geometry
.height
== 0)
866 if(c
->geometry
.x
!= geometry
.x
867 || c
->geometry
.y
!= geometry
.y
868 || c
->geometry
.width
!= geometry
.width
869 || c
->geometry
.height
!= geometry
.height
)
871 client_resize_do(c
, geometry
, false, honor_hints
);
879 /** Set a client minimized, or not.
880 * \param L The Lua VM state.
881 * \param cidx The client index.
882 * \param s Set or not the client minimized.
885 client_set_minimized(lua_State
*L
, int cidx
, bool s
)
887 client_t
*c
= luaA_checkudata(L
, cidx
, &client_class
);
889 if(c
->minimized
!= s
)
892 banning_need_update();
894 xwindow_set_state(c
->window
, XCB_ICCCM_WM_STATE_ICONIC
);
896 xwindow_set_state(c
->window
, XCB_ICCCM_WM_STATE_NORMAL
);
897 if(strut_has_value(&c
->strut
))
898 screen_emit_signal(globalconf
.L
, c
->screen
, "property::workarea", 0);
899 luaA_object_emit_signal(L
, cidx
, "property::minimized", 0);
903 /** Set a client hidden, or not.
904 * \param L The Lua VM state.
905 * \param cidx The client index.
906 * \param s Set or not the client hidden.
909 client_set_hidden(lua_State
*L
, int cidx
, bool s
)
911 client_t
*c
= luaA_checkudata(L
, cidx
, &client_class
);
916 banning_need_update();
917 if(strut_has_value(&c
->strut
))
918 screen_emit_signal(globalconf
.L
, c
->screen
, "property::workarea", 0);
919 luaA_object_emit_signal(L
, cidx
, "property::hidden", 0);
923 /** Set a client sticky, or not.
924 * \param L The Lua VM state.
925 * \param cidx The client index.
926 * \param s Set or not the client sticky.
929 client_set_sticky(lua_State
*L
, int cidx
, bool s
)
931 client_t
*c
= luaA_checkudata(L
, cidx
, &client_class
);
936 banning_need_update();
937 luaA_object_emit_signal(L
, cidx
, "property::sticky", 0);
941 /** Set a client fullscreen, or not.
942 * \param L The Lua VM state.
943 * \param cidx The client index.
944 * \param s Set or not the client fullscreen.
947 client_set_fullscreen(lua_State
*L
, int cidx
, bool s
)
949 client_t
*c
= luaA_checkudata(L
, cidx
, &client_class
);
951 if(c
->fullscreen
!= s
)
953 /* become fullscreen! */
956 /* remove any max state */
957 client_set_maximized_horizontal(L
, cidx
, false);
958 client_set_maximized_vertical(L
, cidx
, false);
959 /* You can only be part of one of the special layers. */
960 client_set_below(L
, cidx
, false);
961 client_set_above(L
, cidx
, false);
962 client_set_ontop(L
, cidx
, false);
964 int abs_cidx
= luaA_absindex(L
, cidx
); \
965 lua_pushboolean(L
, s
);
967 luaA_object_emit_signal(L
, abs_cidx
, "request::fullscreen", 1);
968 luaA_object_emit_signal(L
, abs_cidx
, "property::fullscreen", 0);
969 /* Force a client resize, so that titlebars get shown/hidden */
970 client_resize_do(c
, c
->geometry
, true, false);
975 /** Set a client horizontally|vertically maximized.
976 * \param L The Lua VM state.
977 * \param cidx The client index.
978 * \param s The maximized status.
980 #define DO_FUNCTION_CLIENT_MAXIMIZED(type) \
982 client_set_maximized_##type(lua_State *L, int cidx, bool s) \
984 client_t *c = luaA_checkudata(L, cidx, &client_class); \
985 if(c->maximized_##type != s) \
987 int abs_cidx = luaA_absindex(L, cidx); \
989 client_set_fullscreen(L, abs_cidx, false); \
990 lua_pushboolean(L, s); \
991 c->maximized_##type = s; \
992 luaA_object_emit_signal(L, abs_cidx, "request::maximized_" #type, 1); \
993 luaA_object_emit_signal(L, abs_cidx, "property::maximized_" #type, 0); \
997 DO_FUNCTION_CLIENT_MAXIMIZED(vertical
)
998 DO_FUNCTION_CLIENT_MAXIMIZED(horizontal
)
999 #undef DO_FUNCTION_CLIENT_MAXIMIZED
1001 /** Set a client above, or not.
1002 * \param L The Lua VM state.
1003 * \param cidx The client index.
1004 * \param s Set or not the client above.
1007 client_set_above(lua_State
*L
, int cidx
, bool s
)
1009 client_t
*c
= luaA_checkudata(L
, cidx
, &client_class
);
1013 /* You can only be part of one of the special layers. */
1016 client_set_below(L
, cidx
, false);
1017 client_set_ontop(L
, cidx
, false);
1018 client_set_fullscreen(L
, cidx
, false);
1022 luaA_object_emit_signal(L
, cidx
, "property::above", 0);
1026 /** Set a client below, or not.
1027 * \param L The Lua VM state.
1028 * \param cidx The client index.
1029 * \param s Set or not the client below.
1032 client_set_below(lua_State
*L
, int cidx
, bool s
)
1034 client_t
*c
= luaA_checkudata(L
, cidx
, &client_class
);
1038 /* You can only be part of one of the special layers. */
1041 client_set_above(L
, cidx
, false);
1042 client_set_ontop(L
, cidx
, false);
1043 client_set_fullscreen(L
, cidx
, false);
1047 luaA_object_emit_signal(L
, cidx
, "property::below", 0);
1051 /** Set a client modal, or not.
1052 * \param L The Lua VM state.
1053 * \param cidx The client index.
1054 * \param s Set or not the client modal attribute.
1057 client_set_modal(lua_State
*L
, int cidx
, bool s
)
1059 client_t
*c
= luaA_checkudata(L
, cidx
, &client_class
);
1065 luaA_object_emit_signal(L
, cidx
, "property::modal", 0);
1069 /** Set a client ontop, or not.
1070 * \param L The Lua VM state.
1071 * \param cidx The client index.
1072 * \param s Set or not the client ontop attribute.
1075 client_set_ontop(lua_State
*L
, int cidx
, bool s
)
1077 client_t
*c
= luaA_checkudata(L
, cidx
, &client_class
);
1081 /* You can only be part of one of the special layers. */
1084 client_set_above(L
, cidx
, false);
1085 client_set_below(L
, cidx
, false);
1086 client_set_fullscreen(L
, cidx
, false);
1090 luaA_object_emit_signal(L
, cidx
, "property::ontop", 0);
1094 /** Unban a client and move it back into the viewport.
1095 * \param c The client.
1098 client_unban(client_t
*c
)
1102 xcb_map_window(globalconf
.connection
, c
->frame_window
);
1104 c
->isbanned
= false;
1106 /* An unbanned client shouldn't be minimized or hidden */
1107 luaA_object_push(globalconf
.L
, c
);
1108 client_set_minimized(globalconf
.L
, -1, false);
1109 client_set_hidden(globalconf
.L
, -1, false);
1110 lua_pop(globalconf
.L
, 1);
1114 /** Unmanage a client.
1115 * \param c The client.
1116 * \param window_valid Is the client's window still valid?
1119 client_unmanage(client_t
*c
, bool window_valid
)
1121 /* Reset transient_for attributes of widows that maybe referring to us */
1122 foreach(_tc
, globalconf
.clients
)
1124 client_t
*tc
= *_tc
;
1125 if(tc
->transient_for
== c
)
1126 tc
->transient_for
= NULL
;
1129 if(globalconf
.focus
.client
== c
)
1132 /* remove client from global list and everywhere else */
1133 foreach(elem
, globalconf
.clients
)
1136 client_array_remove(&globalconf
.clients
, elem
);
1139 stack_client_remove(c
);
1140 for(int i
= 0; i
< globalconf
.tags
.len
; i
++)
1141 untag_client(c
, globalconf
.tags
.tab
[i
]);
1143 luaA_object_push(globalconf
.L
, c
);
1144 luaA_object_emit_signal(globalconf
.L
, -1, "unmanage", 0);
1145 lua_pop(globalconf
.L
, 1);
1147 luaA_class_emit_signal(globalconf
.L
, &client_class
, "list", 0);
1149 if(strut_has_value(&c
->strut
))
1150 screen_emit_signal(globalconf
.L
, c
->screen
, "property::workarea", 0);
1152 /* Get rid of all titlebars */
1153 for (client_titlebar_t bar
= CLIENT_TITLEBAR_TOP
; bar
< CLIENT_TITLEBAR_COUNT
; bar
++) {
1154 if (c
->titlebar
[bar
].drawable
== NULL
)
1157 luaA_object_push(globalconf
.L
, c
);
1158 luaA_object_push_item(globalconf
.L
, -1, c
->titlebar
[bar
].drawable
);
1160 /* Make the drawable unusable */
1161 drawable_unset_surface(c
->titlebar
[bar
].drawable
);
1162 if (c
->titlebar
[bar
].pixmap
!= XCB_NONE
)
1163 xcb_free_pixmap(globalconf
.connection
, c
->titlebar
[bar
].pixmap
);
1165 /* And forget about it */
1166 luaA_object_unref_item(globalconf
.L
, -2, c
->titlebar
[bar
].drawable
);
1167 c
->titlebar
[bar
].drawable
= NULL
;
1168 lua_pop(globalconf
.L
, 2);
1171 /* Clear our event mask so that we don't receive any events from now on,
1172 * especially not for the following requests. */
1174 xcb_change_window_attributes(globalconf
.connection
,
1177 (const uint32_t []) { 0 });
1178 xcb_change_window_attributes(globalconf
.connection
,
1181 (const uint32_t []) { 0 });
1185 xcb_unmap_window(globalconf
.connection
, c
->window
);
1186 xcb_reparent_window(globalconf
.connection
, c
->window
, globalconf
.screen
->root
,
1187 c
->geometry
.x
, c
->geometry
.y
);
1189 xcb_destroy_window(globalconf
.connection
, c
->frame_window
);
1193 /* Remove this window from the save set since this shouldn't be made visible
1194 * after a restart anymore. */
1195 xcb_change_save_set(globalconf
.connection
, XCB_SET_MODE_DELETE
, c
->window
);
1197 /* Do this last to avoid races with clients. According to ICCCM, clients
1198 * arent allowed to re-use the window until after this. */
1199 xwindow_set_state(c
->window
, XCB_ICCCM_WM_STATE_WITHDRAWN
);
1202 /* set client as invalid */
1203 c
->window
= XCB_NONE
;
1205 luaA_object_unref(globalconf
.L
, c
);
1208 /** Kill a client via a WM_DELETE_WINDOW request or KillClient if not
1210 * \param c The client to kill.
1213 client_kill(client_t
*c
)
1215 if(client_hasproto(c
, WM_DELETE_WINDOW
))
1217 xcb_client_message_event_t ev
;
1219 /* Initialize all of event's fields first */
1222 ev
.response_type
= XCB_CLIENT_MESSAGE
;
1223 ev
.window
= c
->window
;
1225 ev
.data
.data32
[1] = globalconf
.timestamp
;
1226 ev
.type
= WM_PROTOCOLS
;
1227 ev
.data
.data32
[0] = WM_DELETE_WINDOW
;
1229 xcb_send_event(globalconf
.connection
, false, c
->window
,
1230 XCB_EVENT_MASK_NO_EVENT
, (char *) &ev
);
1233 xcb_kill_client(globalconf
.connection
, c
->window
);
1236 /** Get all clients into a table.
1237 * \param L The Lua VM state.
1238 * \return The number of elements pushed on stack.
1240 * \lparam An optional screen number.
1241 * \lreturn A table with all clients.
1244 luaA_client_get(lua_State
*L
)
1248 screen
= luaL_optnumber(L
, 1, 0) - 1;
1253 foreach(c
, globalconf
.clients
)
1255 luaA_object_push(L
, *c
);
1256 lua_rawseti(L
, -2, i
++);
1260 luaA_checkscreen(screen
);
1261 foreach(c
, globalconf
.clients
)
1262 if((*c
)->screen
== &globalconf
.screens
.tab
[screen
])
1264 luaA_object_push(L
, *c
);
1265 lua_rawseti(L
, -2, i
++);
1272 /** Check if a client is visible on its screen.
1273 * \param L The Lua VM state.
1274 * \return The number of elements pushed on stack.
1277 * \lreturn A boolean value, true if the client is visible, false otherwise.
1280 luaA_client_isvisible(lua_State
*L
)
1282 client_t
*c
= luaA_checkudata(L
, 1, &client_class
);
1283 lua_pushboolean(L
, client_isvisible(c
));
1287 /** Set a client icon.
1288 * \param L The Lua VM state.
1289 * \param cidx The client index on the stack.
1290 * \param iidx The image index on the stack.
1293 client_set_icon(client_t
*c
, cairo_surface_t
*s
)
1296 s
= draw_dup_image_surface(s
);
1298 cairo_surface_destroy(c
->icon
);
1301 luaA_object_push(globalconf
.L
, c
);
1302 luaA_object_emit_signal(globalconf
.L
, -1, "property::icon", 0);
1303 lua_pop(globalconf
.L
, 1);
1307 * \param L The Lua VM state.
1313 luaA_client_kill(lua_State
*L
)
1315 client_t
*c
= luaA_checkudata(L
, 1, &client_class
);
1320 /** Swap a client with another one.
1321 * \param L The Lua VM state.
1324 * \lparam A client to swap with.
1327 luaA_client_swap(lua_State
*L
)
1329 client_t
*c
= luaA_checkudata(L
, 1, &client_class
);
1330 client_t
*swap
= luaA_checkudata(L
, 2, &client_class
);
1334 client_t
**ref_c
= NULL
, **ref_swap
= NULL
;
1335 foreach(item
, globalconf
.clients
)
1339 else if(*item
== swap
)
1341 if(ref_c
&& ref_swap
)
1348 luaA_class_emit_signal(globalconf
.L
, &client_class
, "list", 0);
1354 /** Access or set the client tags.
1355 * \param L The Lua VM state.
1356 * \return The number of elements pushed on stack.
1357 * \lparam A table with tags to set, or none to get the current tags table.
1358 * \return The clients tag.
1361 luaA_client_tags(lua_State
*L
)
1363 client_t
*c
= luaA_checkudata(L
, 1, &client_class
);
1366 if(lua_gettop(L
) == 2)
1368 luaA_checktable(L
, 2);
1369 for(int i
= 0; i
< globalconf
.tags
.len
; i
++)
1371 /* Only untag if we aren't going to add this tag again */
1374 while(lua_next(L
, 2))
1376 tag_t
*t
= lua_touserdata(L
, -1);
1377 /* Pop the value from lua_next */
1379 if (t
!= globalconf
.tags
.tab
[i
])
1382 /* Pop the key from lua_next */
1388 untag_client(c
, globalconf
.tags
.tab
[i
]);
1391 while(lua_next(L
, 2))
1397 foreach(tag
, globalconf
.tags
)
1398 if(is_client_tagged(c
, *tag
))
1400 luaA_object_push(L
, *tag
);
1401 lua_rawseti(L
, -2, ++j
);
1407 /** Raise a client on top of others which are on the same layer.
1408 * \param L The Lua VM state.
1413 luaA_client_raise(lua_State
*L
)
1415 client_t
*c
= luaA_checkudata(L
, 1, &client_class
);
1420 /** Lower a client on bottom of others which are on the same layer.
1421 * \param L The Lua VM state.
1426 luaA_client_lower(lua_State
*L
)
1428 client_t
*c
= luaA_checkudata(L
, 1, &client_class
);
1430 stack_client_push(c
);
1432 /* Traverse all transient layers. */
1433 for(client_t
*tc
= c
->transient_for
; tc
; tc
= tc
->transient_for
)
1434 stack_client_push(tc
);
1439 /** Stop managing a client.
1440 * \param L The Lua VM state.
1441 * \return The number of elements pushed on stack.
1446 luaA_client_unmanage(lua_State
*L
)
1448 client_t
*c
= luaA_checkudata(L
, 1, &client_class
);
1449 client_unmanage(c
, true);
1454 titlebar_get_area(client_t
*c
, client_titlebar_t bar
)
1456 area_t result
= c
->geometry
;
1457 result
.x
= result
.y
= 0;
1459 // Let's try some ascii art:
1460 // ---------------------------
1462 // |-------------------------|
1468 // |-------------------------|
1470 // ---------------------------
1473 case CLIENT_TITLEBAR_BOTTOM
:
1474 result
.y
= c
->geometry
.height
- c
->titlebar
[bar
].size
;
1476 case CLIENT_TITLEBAR_TOP
:
1477 result
.height
= c
->titlebar
[bar
].size
;
1479 case CLIENT_TITLEBAR_RIGHT
:
1480 result
.x
= c
->geometry
.width
- c
->titlebar
[bar
].size
;
1482 case CLIENT_TITLEBAR_LEFT
:
1483 result
.y
= c
->titlebar
[CLIENT_TITLEBAR_TOP
].size
;
1484 result
.width
= c
->titlebar
[bar
].size
;
1485 result
.height
-= c
->titlebar
[CLIENT_TITLEBAR_TOP
].size
;
1486 result
.height
-= c
->titlebar
[CLIENT_TITLEBAR_BOTTOM
].size
;
1489 fatal("Unknown titlebar kind %d\n", (int) bar
);
1496 client_get_drawable_offset(client_t
*c
, int *x
, int *y
)
1498 for (client_titlebar_t bar
= CLIENT_TITLEBAR_TOP
; bar
< CLIENT_TITLEBAR_COUNT
; bar
++) {
1499 area_t area
= titlebar_get_area(c
, bar
);
1500 if (AREA_LEFT(area
) > *x
|| AREA_RIGHT(area
) <= *x
)
1502 if (AREA_TOP(area
) > *y
|| AREA_BOTTOM(area
) <= *y
)
1507 return c
->titlebar
[bar
].drawable
;
1514 client_get_drawable(client_t
*c
, int x
, int y
)
1516 return client_get_drawable_offset(c
, &x
, &y
);
1520 client_refresh(client_t
*c
)
1522 for (client_titlebar_t bar
= CLIENT_TITLEBAR_TOP
; bar
< CLIENT_TITLEBAR_COUNT
; bar
++) {
1523 if (c
->titlebar
[bar
].drawable
== NULL
|| c
->titlebar
[bar
].drawable
->surface
== NULL
)
1526 area_t area
= titlebar_get_area(c
, bar
);
1527 cairo_surface_flush(c
->titlebar
[bar
].drawable
->surface
);
1528 xcb_copy_area(globalconf
.connection
, c
->titlebar
[bar
].pixmap
, c
->frame_window
,
1529 globalconf
.gc
, 0, 0, area
.x
, area
.y
, area
.width
, area
.height
);
1534 titlebar_get_drawable(lua_State
*L
, client_t
*c
, int cl_idx
, client_titlebar_t bar
)
1536 if (c
->titlebar
[bar
].drawable
== NULL
)
1538 cl_idx
= luaA_absindex(L
, cl_idx
);
1539 drawable_allocator(L
, (drawable_refresh_callback
*) client_refresh
, c
);
1540 c
->titlebar
[bar
].drawable
= luaA_object_ref_item(L
, cl_idx
, -1);
1543 return c
->titlebar
[bar
].drawable
;
1547 titlebar_resize(client_t
*c
, client_titlebar_t bar
, int size
)
1552 if (size
== c
->titlebar
[bar
].size
)
1555 /* Now resize the client (and titlebars!) suitably (the client without
1556 * titlebars should keep its current size!) */
1557 area_t geometry
= c
->geometry
;
1558 int change
= size
- c
->titlebar
[bar
].size
;
1560 case CLIENT_TITLEBAR_TOP
:
1561 case CLIENT_TITLEBAR_BOTTOM
:
1562 geometry
.height
+= change
;
1564 case CLIENT_TITLEBAR_RIGHT
:
1565 case CLIENT_TITLEBAR_LEFT
:
1566 geometry
.width
+= change
;
1569 fatal("Unknown titlebar kind %d\n", (int) bar
);
1572 c
->titlebar
[bar
].size
= size
;
1573 client_resize_do(c
, geometry
, true, false);
1576 #define HANDLE_TITLEBAR(name, index) \
1578 luaA_client_titlebar_ ## name(lua_State *L) \
1580 client_t *c = luaA_checkudata(L, 1, &client_class); \
1582 if (lua_gettop(L) == 2) \
1584 if (lua_isnil(L, 2)) \
1585 titlebar_resize(c, index, 0); \
1587 titlebar_resize(c, index, luaL_checknumber(L, 2)); \
1590 luaA_object_push_item(L, 1, titlebar_get_drawable(L, c, 1, index)); \
1591 lua_pushnumber(L, c->titlebar[index].size); \
1594 HANDLE_TITLEBAR(top
, CLIENT_TITLEBAR_TOP
)
1595 HANDLE_TITLEBAR(right
, CLIENT_TITLEBAR_RIGHT
)
1596 HANDLE_TITLEBAR(bottom
, CLIENT_TITLEBAR_BOTTOM
)
1597 HANDLE_TITLEBAR(left
, CLIENT_TITLEBAR_LEFT
)
1599 /** Return client geometry.
1600 * \param L The Lua VM state.
1601 * \return The number of elements pushed on stack.
1603 * \lparam A table with new coordinates, or none.
1604 * \lreturn A table with client coordinates.
1607 luaA_client_geometry(lua_State
*L
)
1609 client_t
*c
= luaA_checkudata(L
, 1, &client_class
);
1611 if(lua_gettop(L
) == 2 && !lua_isnil(L
, 2))
1615 luaA_checktable(L
, 2);
1616 geometry
.x
= luaA_getopt_number(L
, 2, "x", c
->geometry
.x
);
1617 geometry
.y
= luaA_getopt_number(L
, 2, "y", c
->geometry
.y
);
1618 if(client_isfixed(c
))
1620 geometry
.width
= c
->geometry
.width
;
1621 geometry
.height
= c
->geometry
.height
;
1625 geometry
.width
= luaA_getopt_number(L
, 2, "width", c
->geometry
.width
);
1626 geometry
.height
= luaA_getopt_number(L
, 2, "height", c
->geometry
.height
);
1629 client_resize(c
, geometry
, true);
1632 return luaA_pusharea(L
, c
->geometry
);
1636 luaA_client_set_screen(lua_State
*L
, client_t
*c
)
1638 int screen
= luaL_checknumber(L
, -1) - 1;
1639 luaA_checkscreen(screen
);
1640 screen_client_moveto(c
, &globalconf
.screens
.tab
[screen
], true);
1646 luaA_client_set_hidden(lua_State
*L
, client_t
*c
)
1648 client_set_hidden(L
, -3, luaA_checkboolean(L
, -1));
1653 luaA_client_set_minimized(lua_State
*L
, client_t
*c
)
1655 client_set_minimized(L
, -3, luaA_checkboolean(L
, -1));
1660 luaA_client_set_fullscreen(lua_State
*L
, client_t
*c
)
1662 client_set_fullscreen(L
, -3, luaA_checkboolean(L
, -1));
1667 luaA_client_set_modal(lua_State
*L
, client_t
*c
)
1669 client_set_modal(L
, -3, luaA_checkboolean(L
, -1));
1674 luaA_client_set_maximized_horizontal(lua_State
*L
, client_t
*c
)
1676 client_set_maximized_horizontal(L
, -3, luaA_checkboolean(L
, -1));
1681 luaA_client_set_maximized_vertical(lua_State
*L
, client_t
*c
)
1683 client_set_maximized_vertical(L
, -3, luaA_checkboolean(L
, -1));
1688 luaA_client_set_icon(lua_State
*L
, client_t
*c
)
1690 cairo_surface_t
*surf
= NULL
;
1691 if(!lua_isnil(L
, -1))
1692 surf
= (cairo_surface_t
*)lua_touserdata(L
, -1);
1693 client_set_icon(c
, surf
);
1698 luaA_client_set_sticky(lua_State
*L
, client_t
*c
)
1700 client_set_sticky(L
, -3, luaA_checkboolean(L
, -1));
1705 luaA_client_set_size_hints_honor(lua_State
*L
, client_t
*c
)
1707 c
->size_hints_honor
= luaA_checkboolean(L
, -1);
1708 luaA_object_emit_signal(L
, -3, "property::size_hints_honor", 0);
1713 luaA_client_set_ontop(lua_State
*L
, client_t
*c
)
1715 client_set_ontop(L
, -3, luaA_checkboolean(L
, -1));
1720 luaA_client_set_below(lua_State
*L
, client_t
*c
)
1722 client_set_below(L
, -3, luaA_checkboolean(L
, -1));
1727 luaA_client_set_above(lua_State
*L
, client_t
*c
)
1729 client_set_above(L
, -3, luaA_checkboolean(L
, -1));
1734 luaA_client_set_urgent(lua_State
*L
, client_t
*c
)
1736 client_set_urgent(L
, -3, luaA_checkboolean(L
, -1));
1741 luaA_client_set_skip_taskbar(lua_State
*L
, client_t
*c
)
1743 client_set_skip_taskbar(L
, -3, luaA_checkboolean(L
, -1));
1748 luaA_client_get_name(lua_State
*L
, client_t
*c
)
1750 lua_pushstring(L
, c
->name
? c
->name
: c
->alt_name
);
1755 luaA_client_get_icon_name(lua_State
*L
, client_t
*c
)
1757 lua_pushstring(L
, c
->icon_name
? c
->icon_name
: c
->alt_icon_name
);
1761 LUA_OBJECT_EXPORT_PROPERTY(client
, client_t
, class, lua_pushstring
)
1762 LUA_OBJECT_EXPORT_PROPERTY(client
, client_t
, instance
, lua_pushstring
)
1763 LUA_OBJECT_EXPORT_PROPERTY(client
, client_t
, machine
, lua_pushstring
)
1764 LUA_OBJECT_EXPORT_PROPERTY(client
, client_t
, role
, lua_pushstring
)
1765 LUA_OBJECT_EXPORT_PROPERTY(client
, client_t
, transient_for
, luaA_object_push
)
1766 LUA_OBJECT_EXPORT_PROPERTY(client
, client_t
, skip_taskbar
, lua_pushboolean
)
1767 LUA_OBJECT_EXPORT_PROPERTY(client
, client_t
, leader_window
, lua_pushnumber
)
1768 LUA_OBJECT_EXPORT_PROPERTY(client
, client_t
, group_window
, lua_pushnumber
)
1769 LUA_OBJECT_EXPORT_PROPERTY(client
, client_t
, pid
, lua_pushnumber
)
1770 LUA_OBJECT_EXPORT_PROPERTY(client
, client_t
, hidden
, lua_pushboolean
)
1771 LUA_OBJECT_EXPORT_PROPERTY(client
, client_t
, minimized
, lua_pushboolean
)
1772 LUA_OBJECT_EXPORT_PROPERTY(client
, client_t
, fullscreen
, lua_pushboolean
)
1773 LUA_OBJECT_EXPORT_PROPERTY(client
, client_t
, modal
, lua_pushboolean
)
1774 LUA_OBJECT_EXPORT_PROPERTY(client
, client_t
, ontop
, lua_pushboolean
)
1775 LUA_OBJECT_EXPORT_PROPERTY(client
, client_t
, urgent
, lua_pushboolean
)
1776 LUA_OBJECT_EXPORT_PROPERTY(client
, client_t
, above
, lua_pushboolean
)
1777 LUA_OBJECT_EXPORT_PROPERTY(client
, client_t
, below
, lua_pushboolean
)
1778 LUA_OBJECT_EXPORT_PROPERTY(client
, client_t
, sticky
, lua_pushboolean
)
1779 LUA_OBJECT_EXPORT_PROPERTY(client
, client_t
, size_hints_honor
, lua_pushboolean
)
1780 LUA_OBJECT_EXPORT_PROPERTY(client
, client_t
, maximized_horizontal
, lua_pushboolean
)
1781 LUA_OBJECT_EXPORT_PROPERTY(client
, client_t
, maximized_vertical
, lua_pushboolean
)
1784 luaA_client_get_content(lua_State
*L
, client_t
*c
)
1786 xcb_image_t
*ximage
= xcb_image_get(globalconf
.connection
,
1791 ~0, XCB_IMAGE_FORMAT_Z_PIXMAP
);
1792 cairo_surface_t
*surface
= NULL
;
1796 if(ximage
->bpp
>= 24)
1798 uint32_t *data
= p_new(uint32_t, ximage
->width
* ximage
->height
);
1800 for(int y
= 0; y
< ximage
->height
; y
++)
1801 for(int x
= 0; x
< ximage
->width
; x
++)
1803 data
[y
* ximage
->width
+ x
] = xcb_image_get_pixel(ximage
, x
, y
);
1804 data
[y
* ximage
->width
+ x
] |= 0xff000000; /* set alpha to 0xff */
1807 surface
= draw_surface_from_data(ximage
->width
, ximage
->height
, data
);
1810 xcb_image_destroy(ximage
);
1816 /* lua has to make sure to free the ref or we have a leak */
1817 lua_pushlightuserdata(L
, surface
);
1822 luaA_client_get_screen(lua_State
*L
, client_t
*c
)
1826 lua_pushnumber(L
, 1 + screen_array_indexof(&globalconf
.screens
, c
->screen
));
1831 luaA_client_get_icon(lua_State
*L
, client_t
*c
)
1835 /* lua gets its own reference which it will have to destroy */
1836 lua_pushlightuserdata(L
, cairo_surface_reference(c
->icon
));
1841 luaA_client_get_focusable(lua_State
*L
, client_t
*c
)
1845 /* A client can be focused if it doesnt have the "nofocus" hint...*/
1849 /* ...or if it knows the WM_TAKE_FOCUS protocol */
1850 ret
= client_hasproto(c
, WM_TAKE_FOCUS
);
1852 lua_pushboolean(L
, ret
);
1857 luaA_client_get_size_hints(lua_State
*L
, client_t
*c
)
1859 const char *u_or_p
= NULL
;
1861 lua_createtable(L
, 0, 1);
1863 if(c
->size_hints
.flags
& XCB_ICCCM_SIZE_HINT_US_POSITION
)
1864 u_or_p
= "user_position";
1865 else if(c
->size_hints
.flags
& XCB_ICCCM_SIZE_HINT_P_POSITION
)
1866 u_or_p
= "program_position";
1870 lua_createtable(L
, 0, 2);
1871 lua_pushnumber(L
, c
->size_hints
.x
);
1872 lua_setfield(L
, -2, "x");
1873 lua_pushnumber(L
, c
->size_hints
.y
);
1874 lua_setfield(L
, -2, "y");
1875 lua_setfield(L
, -2, u_or_p
);
1879 if(c
->size_hints
.flags
& XCB_ICCCM_SIZE_HINT_US_SIZE
)
1880 u_or_p
= "user_size";
1881 else if(c
->size_hints
.flags
& XCB_ICCCM_SIZE_HINT_P_SIZE
)
1882 u_or_p
= "program_size";
1886 lua_createtable(L
, 0, 2);
1887 lua_pushnumber(L
, c
->size_hints
.width
);
1888 lua_setfield(L
, -2, "width");
1889 lua_pushnumber(L
, c
->size_hints
.height
);
1890 lua_setfield(L
, -2, "height");
1891 lua_setfield(L
, -2, u_or_p
);
1894 if(c
->size_hints
.flags
& XCB_ICCCM_SIZE_HINT_P_MIN_SIZE
)
1896 lua_pushnumber(L
, c
->size_hints
.min_width
);
1897 lua_setfield(L
, -2, "min_width");
1898 lua_pushnumber(L
, c
->size_hints
.min_height
);
1899 lua_setfield(L
, -2, "min_height");
1902 if(c
->size_hints
.flags
& XCB_ICCCM_SIZE_HINT_P_MAX_SIZE
)
1904 lua_pushnumber(L
, c
->size_hints
.max_width
);
1905 lua_setfield(L
, -2, "max_width");
1906 lua_pushnumber(L
, c
->size_hints
.max_height
);
1907 lua_setfield(L
, -2, "max_height");
1910 if(c
->size_hints
.flags
& XCB_ICCCM_SIZE_HINT_P_RESIZE_INC
)
1912 lua_pushnumber(L
, c
->size_hints
.width_inc
);
1913 lua_setfield(L
, -2, "width_inc");
1914 lua_pushnumber(L
, c
->size_hints
.height_inc
);
1915 lua_setfield(L
, -2, "height_inc");
1918 if(c
->size_hints
.flags
& XCB_ICCCM_SIZE_HINT_P_ASPECT
)
1920 lua_pushnumber(L
, c
->size_hints
.min_aspect_num
);
1921 lua_setfield(L
, -2, "min_aspect_num");
1922 lua_pushnumber(L
, c
->size_hints
.min_aspect_den
);
1923 lua_setfield(L
, -2, "min_aspect_den");
1924 lua_pushnumber(L
, c
->size_hints
.max_aspect_num
);
1925 lua_setfield(L
, -2, "max_aspect_num");
1926 lua_pushnumber(L
, c
->size_hints
.max_aspect_den
);
1927 lua_setfield(L
, -2, "max_aspect_den");
1930 if(c
->size_hints
.flags
& XCB_ICCCM_SIZE_HINT_BASE_SIZE
)
1932 lua_pushnumber(L
, c
->size_hints
.base_width
);
1933 lua_setfield(L
, -2, "base_width");
1934 lua_pushnumber(L
, c
->size_hints
.base_height
);
1935 lua_setfield(L
, -2, "base_height");
1938 if(c
->size_hints
.flags
& XCB_ICCCM_SIZE_HINT_P_WIN_GRAVITY
)
1940 switch(c
->size_hints
.win_gravity
)
1943 lua_pushliteral(L
, "north_west");
1945 case XCB_GRAVITY_NORTH
:
1946 lua_pushliteral(L
, "north");
1948 case XCB_GRAVITY_NORTH_EAST
:
1949 lua_pushliteral(L
, "north_east");
1951 case XCB_GRAVITY_WEST
:
1952 lua_pushliteral(L
, "west");
1954 case XCB_GRAVITY_CENTER
:
1955 lua_pushliteral(L
, "center");
1957 case XCB_GRAVITY_EAST
:
1958 lua_pushliteral(L
, "east");
1960 case XCB_GRAVITY_SOUTH_WEST
:
1961 lua_pushliteral(L
, "south_west");
1963 case XCB_GRAVITY_SOUTH
:
1964 lua_pushliteral(L
, "south");
1966 case XCB_GRAVITY_SOUTH_EAST
:
1967 lua_pushliteral(L
, "south_east");
1969 case XCB_GRAVITY_STATIC
:
1970 lua_pushliteral(L
, "static");
1973 lua_setfield(L
, -2, "win_gravity");
1979 /** Set the client's bounding shape.
1980 * \param L The Lua VM state.
1981 * \param client The client object.
1982 * \return The number of elements pushed on stack.
1985 luaA_client_set_shape_bounding(lua_State
*L
, client_t
*c
)
1987 cairo_surface_t
*surf
= NULL
;
1988 if(!lua_isnil(L
, -1))
1989 surf
= (cairo_surface_t
*)lua_touserdata(L
, -1);
1990 xwindow_set_shape(c
->frame_window
,
1991 c
->geometry
.width
+ (c
->border_width
* 2),
1992 c
->geometry
.height
+ (c
->border_width
* 2),
1993 XCB_SHAPE_SK_BOUNDING
, surf
, -c
->border_width
);
1997 /** Set the client's clip shape.
1998 * \param L The Lua VM state.
1999 * \param client The client object.
2000 * \return The number of elements pushed on stack.
2003 luaA_client_set_shape_clip(lua_State
*L
, client_t
*c
)
2005 cairo_surface_t
*surf
= NULL
;
2006 if(!lua_isnil(L
, -1))
2007 surf
= (cairo_surface_t
*)lua_touserdata(L
, -1);
2008 xwindow_set_shape(c
->frame_window
, c
->geometry
.width
, c
->geometry
.height
,
2009 XCB_SHAPE_SK_CLIP
, surf
, 0);
2013 /** Get or set keys bindings for a client.
2014 * \param L The Lua VM state.
2015 * \return The number of element pushed on stack.
2018 * \lparam An array of key bindings objects, or nothing.
2019 * \return The array of key bindings objects of this client.
2022 luaA_client_keys(lua_State
*L
)
2024 client_t
*c
= luaA_checkudata(L
, 1, &client_class
);
2025 key_array_t
*keys
= &c
->keys
;
2027 if(lua_gettop(L
) == 2)
2029 luaA_key_array_set(L
, 1, 2, keys
);
2030 luaA_object_emit_signal(L
, 1, "property::keys", 0);
2031 xcb_ungrab_key(globalconf
.connection
, XCB_GRAB_ANY
, c
->frame_window
, XCB_BUTTON_MASK_ANY
);
2032 xwindow_grabkeys(c
->frame_window
, keys
);
2035 return luaA_key_array_get(L
, 1, keys
);
2039 * \param L The Lua VM state.
2040 * \return The number of pushed elements.
2043 luaA_client_module_index(lua_State
*L
)
2045 const char *buf
= luaL_checkstring(L
, 2);
2047 if (A_STREQ(buf
, "focus"))
2048 return luaA_object_push(globalconf
.L
, globalconf
.focus
.client
);
2052 /* Client module new index.
2053 * \param L The Lua VM state.
2054 * \return The number of pushed elements.
2057 luaA_client_module_newindex(lua_State
*L
)
2059 const char *buf
= luaL_checkstring(L
, 2);
2062 if (A_STREQ(buf
, "focus"))
2064 c
= luaA_checkudata(L
, 3, &client_class
);
2072 client_checker(client_t
*c
)
2074 return c
->window
!= XCB_NONE
;
2078 client_class_setup(lua_State
*L
)
2080 static const struct luaL_Reg client_methods
[] =
2082 LUA_CLASS_METHODS(client
)
2083 { "get", luaA_client_get
},
2084 { "__index", luaA_client_module_index
},
2085 { "__newindex", luaA_client_module_newindex
},
2089 static const struct luaL_Reg client_meta
[] =
2091 LUA_OBJECT_META(client
)
2093 { "keys", luaA_client_keys
},
2094 { "isvisible", luaA_client_isvisible
},
2095 { "geometry", luaA_client_geometry
},
2096 { "tags", luaA_client_tags
},
2097 { "kill", luaA_client_kill
},
2098 { "swap", luaA_client_swap
},
2099 { "raise", luaA_client_raise
},
2100 { "lower", luaA_client_lower
},
2101 { "unmanage", luaA_client_unmanage
},
2102 { "titlebar_top", luaA_client_titlebar_top
},
2103 { "titlebar_right", luaA_client_titlebar_right
},
2104 { "titlebar_bottom", luaA_client_titlebar_bottom
},
2105 { "titlebar_left", luaA_client_titlebar_left
},
2109 luaA_class_setup(L
, &client_class
, "client", &window_class
,
2110 (lua_class_allocator_t
) client_new
,
2111 (lua_class_collector_t
) client_wipe
,
2112 (lua_class_checker_t
) client_checker
,
2113 luaA_class_index_miss_property
, luaA_class_newindex_miss_property
,
2114 client_methods
, client_meta
);
2115 luaA_class_add_property(&client_class
, "name",
2117 (lua_class_propfunc_t
) luaA_client_get_name
,
2119 luaA_class_add_property(&client_class
, "transient_for",
2121 (lua_class_propfunc_t
) luaA_client_get_transient_for
,
2123 luaA_class_add_property(&client_class
, "skip_taskbar",
2124 (lua_class_propfunc_t
) luaA_client_set_skip_taskbar
,
2125 (lua_class_propfunc_t
) luaA_client_get_skip_taskbar
,
2126 (lua_class_propfunc_t
) luaA_client_set_skip_taskbar
);
2127 luaA_class_add_property(&client_class
, "content",
2129 (lua_class_propfunc_t
) luaA_client_get_content
,
2131 luaA_class_add_property(&client_class
, "type",
2133 (lua_class_propfunc_t
) luaA_window_get_type
,
2135 luaA_class_add_property(&client_class
, "class",
2137 (lua_class_propfunc_t
) luaA_client_get_class
,
2139 luaA_class_add_property(&client_class
, "instance",
2141 (lua_class_propfunc_t
) luaA_client_get_instance
,
2143 luaA_class_add_property(&client_class
, "role",
2145 (lua_class_propfunc_t
) luaA_client_get_role
,
2147 luaA_class_add_property(&client_class
, "pid",
2149 (lua_class_propfunc_t
) luaA_client_get_pid
,
2151 luaA_class_add_property(&client_class
, "leader_window",
2153 (lua_class_propfunc_t
) luaA_client_get_leader_window
,
2155 luaA_class_add_property(&client_class
, "machine",
2157 (lua_class_propfunc_t
) luaA_client_get_machine
,
2159 luaA_class_add_property(&client_class
, "icon_name",
2161 (lua_class_propfunc_t
) luaA_client_get_icon_name
,
2163 luaA_class_add_property(&client_class
, "screen",
2165 (lua_class_propfunc_t
) luaA_client_get_screen
,
2166 (lua_class_propfunc_t
) luaA_client_set_screen
);
2167 luaA_class_add_property(&client_class
, "hidden",
2168 (lua_class_propfunc_t
) luaA_client_set_hidden
,
2169 (lua_class_propfunc_t
) luaA_client_get_hidden
,
2170 (lua_class_propfunc_t
) luaA_client_set_hidden
);
2171 luaA_class_add_property(&client_class
, "minimized",
2172 (lua_class_propfunc_t
) luaA_client_set_minimized
,
2173 (lua_class_propfunc_t
) luaA_client_get_minimized
,
2174 (lua_class_propfunc_t
) luaA_client_set_minimized
);
2175 luaA_class_add_property(&client_class
, "fullscreen",
2176 (lua_class_propfunc_t
) luaA_client_set_fullscreen
,
2177 (lua_class_propfunc_t
) luaA_client_get_fullscreen
,
2178 (lua_class_propfunc_t
) luaA_client_set_fullscreen
);
2179 luaA_class_add_property(&client_class
, "modal",
2180 (lua_class_propfunc_t
) luaA_client_set_modal
,
2181 (lua_class_propfunc_t
) luaA_client_get_modal
,
2182 (lua_class_propfunc_t
) luaA_client_set_modal
);
2183 luaA_class_add_property(&client_class
, "group_window",
2185 (lua_class_propfunc_t
) luaA_client_get_group_window
,
2187 luaA_class_add_property(&client_class
, "maximized_horizontal",
2188 (lua_class_propfunc_t
) luaA_client_set_maximized_horizontal
,
2189 (lua_class_propfunc_t
) luaA_client_get_maximized_horizontal
,
2190 (lua_class_propfunc_t
) luaA_client_set_maximized_horizontal
);
2191 luaA_class_add_property(&client_class
, "maximized_vertical",
2192 (lua_class_propfunc_t
) luaA_client_set_maximized_vertical
,
2193 (lua_class_propfunc_t
) luaA_client_get_maximized_vertical
,
2194 (lua_class_propfunc_t
) luaA_client_set_maximized_vertical
);
2195 luaA_class_add_property(&client_class
, "icon",
2196 (lua_class_propfunc_t
) luaA_client_set_icon
,
2197 (lua_class_propfunc_t
) luaA_client_get_icon
,
2198 (lua_class_propfunc_t
) luaA_client_set_icon
);
2199 luaA_class_add_property(&client_class
, "ontop",
2200 (lua_class_propfunc_t
) luaA_client_set_ontop
,
2201 (lua_class_propfunc_t
) luaA_client_get_ontop
,
2202 (lua_class_propfunc_t
) luaA_client_set_ontop
);
2203 luaA_class_add_property(&client_class
, "above",
2204 (lua_class_propfunc_t
) luaA_client_set_above
,
2205 (lua_class_propfunc_t
) luaA_client_get_above
,
2206 (lua_class_propfunc_t
) luaA_client_set_above
);
2207 luaA_class_add_property(&client_class
, "below",
2208 (lua_class_propfunc_t
) luaA_client_set_below
,
2209 (lua_class_propfunc_t
) luaA_client_get_below
,
2210 (lua_class_propfunc_t
) luaA_client_set_below
);
2211 luaA_class_add_property(&client_class
, "sticky",
2212 (lua_class_propfunc_t
) luaA_client_set_sticky
,
2213 (lua_class_propfunc_t
) luaA_client_get_sticky
,
2214 (lua_class_propfunc_t
) luaA_client_set_sticky
);
2215 luaA_class_add_property(&client_class
, "size_hints_honor",
2216 (lua_class_propfunc_t
) luaA_client_set_size_hints_honor
,
2217 (lua_class_propfunc_t
) luaA_client_get_size_hints_honor
,
2218 (lua_class_propfunc_t
) luaA_client_set_size_hints_honor
);
2219 luaA_class_add_property(&client_class
, "urgent",
2220 (lua_class_propfunc_t
) luaA_client_set_urgent
,
2221 (lua_class_propfunc_t
) luaA_client_get_urgent
,
2222 (lua_class_propfunc_t
) luaA_client_set_urgent
);
2223 luaA_class_add_property(&client_class
, "size_hints",
2225 (lua_class_propfunc_t
) luaA_client_get_size_hints
,
2227 luaA_class_add_property(&client_class
, "focusable",
2229 (lua_class_propfunc_t
) luaA_client_get_focusable
,
2231 luaA_class_add_property(&client_class
, "shape_bounding",
2232 (lua_class_propfunc_t
) luaA_client_set_shape_bounding
,
2234 (lua_class_propfunc_t
) luaA_client_set_shape_bounding
);
2235 luaA_class_add_property(&client_class
, "shape_clip",
2236 (lua_class_propfunc_t
) luaA_client_set_shape_clip
,
2238 (lua_class_propfunc_t
) luaA_client_set_shape_clip
);
2240 signal_add(&client_class
.signals
, "focus");
2241 signal_add(&client_class
.signals
, "list");
2242 signal_add(&client_class
.signals
, "manage");
2243 signal_add(&client_class
.signals
, "button::press");
2244 signal_add(&client_class
.signals
, "button::release");
2245 signal_add(&client_class
.signals
, "mouse::enter");
2246 signal_add(&client_class
.signals
, "mouse::leave");
2247 signal_add(&client_class
.signals
, "mouse::move");
2248 signal_add(&client_class
.signals
, "property::above");
2249 signal_add(&client_class
.signals
, "property::below");
2250 signal_add(&client_class
.signals
, "property::class");
2251 signal_add(&client_class
.signals
, "property::fullscreen");
2252 signal_add(&client_class
.signals
, "property::geometry");
2253 signal_add(&client_class
.signals
, "property::group_window");
2254 signal_add(&client_class
.signals
, "property::height");
2255 signal_add(&client_class
.signals
, "property::hidden");
2256 signal_add(&client_class
.signals
, "property::icon");
2257 signal_add(&client_class
.signals
, "property::icon_name");
2258 signal_add(&client_class
.signals
, "property::instance");
2259 signal_add(&client_class
.signals
, "property::keys");
2260 signal_add(&client_class
.signals
, "property::machine");
2261 signal_add(&client_class
.signals
, "property::maximized_horizontal");
2262 signal_add(&client_class
.signals
, "property::maximized_vertical");
2263 signal_add(&client_class
.signals
, "property::minimized");
2264 signal_add(&client_class
.signals
, "property::modal");
2265 signal_add(&client_class
.signals
, "property::name");
2266 signal_add(&client_class
.signals
, "property::ontop");
2267 signal_add(&client_class
.signals
, "property::pid");
2268 signal_add(&client_class
.signals
, "property::role");
2269 signal_add(&client_class
.signals
, "property::screen");
2270 signal_add(&client_class
.signals
, "property::size_hints_honor");
2271 signal_add(&client_class
.signals
, "property::skip_taskbar");
2272 signal_add(&client_class
.signals
, "property::sticky");
2273 signal_add(&client_class
.signals
, "property::struts");
2274 signal_add(&client_class
.signals
, "property::transient_for");
2275 signal_add(&client_class
.signals
, "property::type");
2276 signal_add(&client_class
.signals
, "property::urgent");
2277 signal_add(&client_class
.signals
, "property::width");
2278 signal_add(&client_class
.signals
, "property::window");
2279 signal_add(&client_class
.signals
, "property::x");
2280 signal_add(&client_class
.signals
, "property::y");
2281 signal_add(&client_class
.signals
, "request::fullscreen");
2282 signal_add(&client_class
.signals
, "request::maximized_horizontal");
2283 signal_add(&client_class
.signals
, "request::maximized_vertical");
2284 signal_add(&client_class
.signals
, "tagged");
2285 signal_add(&client_class
.signals
, "unfocus");
2286 signal_add(&client_class
.signals
, "unmanage");
2287 signal_add(&client_class
.signals
, "untagged");
2290 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80