2007-10-03 17:26:14 +02:00
|
|
|
/*
|
|
|
|
* client.c - client management
|
|
|
|
*
|
2009-04-11 00:27:06 +02:00
|
|
|
* Copyright © 2007-2009 Julien Danjou <julien@danjou.info>
|
2007-10-03 17:26:14 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2007-09-12 14:29:51 +02:00
|
|
|
*/
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2008-03-21 16:50:17 +01:00
|
|
|
#include <xcb/xcb_atom.h>
|
2008-12-29 15:21:00 +01:00
|
|
|
#include <xcb/xcb_image.h>
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2008-06-09 21:43:09 +02:00
|
|
|
#include "tag.h"
|
2007-12-27 18:01:36 +01:00
|
|
|
#include "ewmh.h"
|
2008-03-13 09:05:34 +01:00
|
|
|
#include "screen.h"
|
2008-03-15 13:59:04 +01:00
|
|
|
#include "titlebar.h"
|
2008-06-30 13:09:24 +02:00
|
|
|
#include "systray.h"
|
2008-09-16 14:09:56 +02:00
|
|
|
#include "property.h"
|
2009-04-03 16:30:18 +02:00
|
|
|
#include "spawn.h"
|
2009-08-17 16:38:56 +02:00
|
|
|
#include "luaa.h"
|
2008-06-30 18:55:14 +02:00
|
|
|
#include "common/atoms.h"
|
2009-04-17 16:52:25 +02:00
|
|
|
#include "common/xutil.h"
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
client_t *
|
|
|
|
luaA_client_checkudata(lua_State *L, int ud)
|
|
|
|
{
|
2009-08-17 15:52:41 +02:00
|
|
|
client_t *c = luaA_checkudata(L, ud, &client_class);
|
2009-04-10 15:23:55 +02:00
|
|
|
if(c->invalid)
|
|
|
|
luaL_error(L, "client is invalid\n");
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Collect a client.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \return The number of element pushed on stack.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_client_gc(lua_State *L)
|
|
|
|
{
|
2009-08-17 15:52:41 +02:00
|
|
|
client_t *c = luaA_checkudata(L, 1, &client_class);
|
2009-08-14 16:46:35 +02:00
|
|
|
button_array_wipe(&c->buttons);
|
|
|
|
key_array_wipe(&c->keys);
|
2009-06-24 17:59:19 +02:00
|
|
|
xcb_get_wm_protocols_reply_wipe(&c->protocols);
|
2009-04-10 15:23:55 +02:00
|
|
|
p_delete(&c->class);
|
|
|
|
p_delete(&c->instance);
|
|
|
|
p_delete(&c->icon_name);
|
2009-08-25 16:39:10 +02:00
|
|
|
p_delete(&c->alt_icon_name);
|
2009-04-10 15:23:55 +02:00
|
|
|
p_delete(&c->name);
|
2009-08-25 16:39:10 +02:00
|
|
|
p_delete(&c->alt_name);
|
2009-06-16 16:24:58 +02:00
|
|
|
return luaA_object_gc(L);
|
2009-04-10 15:23:55 +02:00
|
|
|
}
|
2008-06-18 18:31:35 +02:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
/** Change the client opacity.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param cidx The client index.
|
|
|
|
* \param opacity The opacity.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
client_set_opacity(lua_State *L, int cidx, double opacity)
|
|
|
|
{
|
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
|
|
|
|
if(c->opacity != opacity)
|
|
|
|
{
|
|
|
|
c->opacity = opacity;
|
|
|
|
window_opacity_set(c->window, opacity);
|
|
|
|
luaA_object_emit_signal(L, cidx, "property::opacity", 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-11 18:41:58 +01:00
|
|
|
/** Change the clients urgency flag.
|
2009-08-17 17:02:45 +02:00
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param cidx The client index on the stack.
|
|
|
|
* \param urgent The new flag state.
|
2009-02-11 18:41:58 +01:00
|
|
|
*/
|
|
|
|
void
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_urgent(lua_State *L, int cidx, bool urgent)
|
2009-02-11 18:41:58 +01:00
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
|
|
|
|
if(c->urgent != urgent)
|
2009-02-11 18:41:58 +01:00
|
|
|
{
|
|
|
|
xcb_get_property_cookie_t hints =
|
2009-08-17 17:02:45 +02:00
|
|
|
xcb_get_wm_hints_unchecked(globalconf.connection, c->window);
|
2009-02-11 18:41:58 +01:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
c->urgent = urgent;
|
2009-02-11 18:41:58 +01:00
|
|
|
ewmh_client_update_hints(c);
|
|
|
|
|
|
|
|
/* update ICCCM hints */
|
|
|
|
xcb_wm_hints_t wmh;
|
|
|
|
xcb_get_wm_hints_reply(globalconf.connection, hints, &wmh, NULL);
|
|
|
|
|
|
|
|
if(urgent)
|
|
|
|
wmh.flags |= XCB_WM_HINT_X_URGENCY;
|
|
|
|
else
|
|
|
|
wmh.flags &= ~XCB_WM_HINT_X_URGENCY;
|
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
xcb_set_wm_hints(globalconf.connection, c->window, &wmh);
|
2009-02-11 18:41:58 +01:00
|
|
|
|
2009-06-29 11:02:13 +02:00
|
|
|
hook_property(c, "urgent");
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_object_emit_signal(L, cidx, "property::urgent", 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
client_set_group_window(lua_State *L, int cidx, xcb_window_t window)
|
|
|
|
{
|
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
|
|
|
|
if(c->group_window != window)
|
|
|
|
{
|
|
|
|
c->group_window = window;
|
|
|
|
luaA_object_emit_signal(L, cidx, "property::group_window", 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
client_set_type(lua_State *L, int cidx, window_type_t type)
|
|
|
|
{
|
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
|
|
|
|
if(c->type != type)
|
|
|
|
{
|
|
|
|
c->type = type;
|
|
|
|
luaA_object_emit_signal(L, cidx, "property::type", 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
client_set_pid(lua_State *L, int cidx, uint32_t pid)
|
|
|
|
{
|
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
|
|
|
|
if(c->pid != pid)
|
|
|
|
{
|
|
|
|
c->pid = pid;
|
|
|
|
luaA_object_emit_signal(L, cidx, "property::pid", 0);
|
2009-02-11 18:41:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
void
|
2009-08-24 10:05:50 +02:00
|
|
|
client_set_icon_name(lua_State *L, int cidx, char *icon_name)
|
2009-08-17 17:02:45 +02:00
|
|
|
{
|
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
p_delete(&c->icon_name);
|
2009-08-24 10:05:50 +02:00
|
|
|
c->icon_name = icon_name;
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_object_emit_signal(L, cidx, "property::icon_name", 0);
|
|
|
|
hook_property(c, "icon_name");
|
|
|
|
}
|
|
|
|
|
2009-08-25 16:39:10 +02:00
|
|
|
void
|
|
|
|
client_set_alt_icon_name(lua_State *L, int cidx, char *icon_name)
|
|
|
|
{
|
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
p_delete(&c->alt_icon_name);
|
|
|
|
c->alt_icon_name = icon_name;
|
|
|
|
luaA_object_emit_signal(L, cidx, "property::icon_name", 0);
|
|
|
|
hook_property(c, "icon_name");
|
|
|
|
}
|
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
void
|
2009-08-24 10:05:50 +02:00
|
|
|
client_set_role(lua_State *L, int cidx, char *role)
|
2009-08-17 17:02:45 +02:00
|
|
|
{
|
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
p_delete(&c->role);
|
2009-08-24 10:05:50 +02:00
|
|
|
c->role = role;
|
2009-08-21 23:30:07 +02:00
|
|
|
luaA_object_emit_signal(L, cidx, "property::role", 0);
|
2009-08-17 17:02:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-08-24 10:05:50 +02:00
|
|
|
client_set_machine(lua_State *L, int cidx, char *machine)
|
2009-08-17 17:02:45 +02:00
|
|
|
{
|
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
p_delete(&c->machine);
|
2009-08-24 10:05:50 +02:00
|
|
|
c->machine = machine;
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_object_emit_signal(L, cidx, "property::machine", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
client_set_class_instance(lua_State *L, int cidx, const char *class, const char *instance)
|
|
|
|
{
|
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
p_delete(&c->class);
|
|
|
|
p_delete(&c->instance);
|
|
|
|
c->class = a_strdup(class);
|
|
|
|
c->instance = a_strdup(instance);
|
|
|
|
luaA_object_emit_signal(L, cidx, "property::class", 0);
|
|
|
|
luaA_object_emit_signal(L, cidx, "property::instance", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
client_set_transient_for(lua_State *L, int cidx, client_t *transient_for)
|
|
|
|
{
|
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
|
|
|
|
if(c->transient_for != transient_for)
|
|
|
|
{
|
|
|
|
c->transient_for = transient_for;
|
|
|
|
luaA_object_emit_signal(L, cidx, "property::transient_for", 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-08-24 10:05:50 +02:00
|
|
|
client_set_name(lua_State *L, int cidx, char *name)
|
2009-08-17 17:02:45 +02:00
|
|
|
{
|
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
p_delete(&c->name);
|
2009-08-24 10:05:50 +02:00
|
|
|
c->name = name;
|
2009-08-17 17:02:45 +02:00
|
|
|
hook_property(c, "name");
|
|
|
|
luaA_object_emit_signal(L, cidx, "property::name", 0);
|
|
|
|
}
|
|
|
|
|
2009-08-25 16:39:10 +02:00
|
|
|
void
|
|
|
|
client_set_alt_name(lua_State *L, int cidx, char *name)
|
|
|
|
{
|
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
p_delete(&c->alt_name);
|
|
|
|
c->alt_name = name;
|
|
|
|
hook_property(c, "name");
|
|
|
|
luaA_object_emit_signal(L, cidx, "property::name", 0);
|
|
|
|
}
|
|
|
|
|
2008-06-09 21:43:09 +02:00
|
|
|
/** Returns true if a client is tagged
|
|
|
|
* with one of the tags of the specified screen.
|
2008-04-29 09:14:46 +02:00
|
|
|
* \param c The client to check.
|
2009-04-17 16:14:09 +02:00
|
|
|
* \param screen Virtual screen.
|
2008-06-09 21:43:09 +02:00
|
|
|
* \return true if the client is visible, false otherwise.
|
2008-04-09 17:33:47 +02:00
|
|
|
*/
|
|
|
|
bool
|
2009-04-17 16:14:09 +02:00
|
|
|
client_maybevisible(client_t *c, screen_t *screen)
|
2008-04-09 17:33:47 +02:00
|
|
|
{
|
2009-08-20 17:43:48 +02:00
|
|
|
if(screen && c->screen == screen)
|
2008-06-23 17:37:19 +02:00
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
if(c->sticky || c->type == WINDOW_TYPE_DESKTOP)
|
2008-08-21 16:29:53 +02:00
|
|
|
return true;
|
|
|
|
|
2009-04-17 16:14:09 +02:00
|
|
|
foreach(tag, screen->tags)
|
2009-07-29 17:38:48 +02:00
|
|
|
if(tag_get_selected(*tag) && is_client_tagged(c, *tag))
|
2008-06-09 21:43:09 +02:00
|
|
|
return true;
|
2008-06-23 17:37:19 +02:00
|
|
|
}
|
2008-04-09 17:33:47 +02:00
|
|
|
return false;
|
|
|
|
}
|
2008-06-10 19:29:53 +02:00
|
|
|
|
2008-06-05 09:25:38 +02:00
|
|
|
/** Get a client by its window.
|
|
|
|
* \param w The client window to find.
|
2008-04-29 09:14:46 +02:00
|
|
|
* \return A client pointer if found, NULL otherwise.
|
2007-12-14 14:29:32 +01:00
|
|
|
*/
|
2008-04-11 11:35:11 +02:00
|
|
|
client_t *
|
2008-06-05 09:25:38 +02:00
|
|
|
client_getbywin(xcb_window_t w)
|
2007-12-14 14:29:32 +01:00
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
foreach(c, globalconf.clients)
|
2009-08-17 17:02:45 +02:00
|
|
|
if((*c)->window == w)
|
2009-04-10 15:23:55 +02:00
|
|
|
return *c;
|
|
|
|
|
2009-04-09 17:17:10 +02:00
|
|
|
return NULL;
|
2007-12-14 14:29:32 +01:00
|
|
|
}
|
|
|
|
|
2009-04-07 14:20:22 +02:00
|
|
|
/** Record that a client lost focus.
|
|
|
|
* \param c Client being unfocused
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
client_unfocus_update(client_t *c)
|
|
|
|
{
|
2009-04-17 16:14:09 +02:00
|
|
|
globalconf.screens.tab[c->phys_screen].client_focus = NULL;
|
2009-04-07 14:20:22 +02:00
|
|
|
ewmh_update_net_active_window(c->phys_screen);
|
|
|
|
|
2009-02-11 18:32:27 +01:00
|
|
|
/* Call hook */
|
|
|
|
if(globalconf.hooks.unfocus != LUA_REFNIL)
|
|
|
|
{
|
2009-06-29 11:02:13 +02:00
|
|
|
luaA_object_push(globalconf.L, c);
|
2009-05-19 17:37:35 +02:00
|
|
|
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.unfocus, 1, 0);
|
2009-02-11 18:32:27 +01:00
|
|
|
}
|
2009-04-07 14:20:22 +02:00
|
|
|
|
2009-07-10 12:44:57 +02:00
|
|
|
luaA_object_push(globalconf.L, c);
|
|
|
|
luaA_class_emit_signal(globalconf.L, &client_class, "unfocus", 1);
|
2009-02-11 18:32:27 +01:00
|
|
|
}
|
|
|
|
|
2008-06-10 19:29:53 +02:00
|
|
|
/** Unfocus a client.
|
|
|
|
* \param c The client.
|
|
|
|
*/
|
2009-04-07 14:20:22 +02:00
|
|
|
void
|
2008-04-11 11:35:11 +02:00
|
|
|
client_unfocus(client_t *c)
|
2008-01-25 12:55:44 +01:00
|
|
|
{
|
2008-07-29 14:57:18 +02:00
|
|
|
|
2009-04-28 10:54:10 +02:00
|
|
|
xcb_window_t root_win = xutil_screen_get(globalconf.connection, c->phys_screen)->root;
|
2009-06-24 18:10:55 +02:00
|
|
|
/* Set focus on root window, so no events leak to the current window.
|
2009-08-17 17:02:45 +02:00
|
|
|
* This kind of inlines client_set_focus(), but a root window will never have
|
2009-06-24 18:10:55 +02:00
|
|
|
* the WM_TAKE_FOCUS protocol.
|
|
|
|
*/
|
|
|
|
xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_PARENT,
|
|
|
|
root_win, XCB_CURRENT_TIME);
|
2009-04-28 10:54:10 +02:00
|
|
|
|
|
|
|
client_unfocus_update(c);
|
2008-01-25 12:55:44 +01:00
|
|
|
}
|
|
|
|
|
2009-08-30 07:26:19 +02:00
|
|
|
/** Check if client supports atom a protocol in WM_PROTOCOL.
|
2009-06-24 18:10:55 +02:00
|
|
|
* \param c The client.
|
2009-07-27 06:20:00 +02:00
|
|
|
* \param atom The protocol atom to check for.
|
2009-06-24 18:10:55 +02:00
|
|
|
* \return True if client has the atom in protocol, false otherwise.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
client_hasproto(client_t *c, xcb_atom_t atom)
|
|
|
|
{
|
2009-08-24 10:48:18 +02:00
|
|
|
for(uint32_t i = 0; i < c->protocols.atoms_len; i++)
|
2009-06-24 18:17:31 +02:00
|
|
|
if(c->protocols.atoms[i] == atom)
|
|
|
|
return true;
|
|
|
|
return false;
|
2009-06-24 18:10:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Sets focus on window - using xcb_set_input_focus or WM_TAKE_FOCUS
|
|
|
|
* \param c Client that should get focus
|
|
|
|
* \param set_input_focus Should we call xcb_set_input_focus
|
|
|
|
*/
|
|
|
|
void
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_focus(client_t *c, bool set_input_focus)
|
2009-06-24 18:10:55 +02:00
|
|
|
{
|
|
|
|
bool takefocus = client_hasproto(c, WM_TAKE_FOCUS);
|
|
|
|
if(set_input_focus)
|
|
|
|
xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_PARENT,
|
2009-08-17 17:02:45 +02:00
|
|
|
c->window, XCB_CURRENT_TIME);
|
2009-06-24 18:10:55 +02:00
|
|
|
if(takefocus)
|
2009-08-17 17:02:45 +02:00
|
|
|
window_takefocus(c->window);
|
2009-06-24 18:10:55 +02:00
|
|
|
}
|
|
|
|
|
2008-11-20 22:11:13 +01:00
|
|
|
/** Ban client and move it out of the viewport.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \param c The client.
|
2007-09-05 20:15:00 +02:00
|
|
|
*/
|
|
|
|
void
|
2008-04-11 11:35:11 +02:00
|
|
|
client_ban(client_t *c)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-11-20 22:11:13 +01:00
|
|
|
if(!c->isbanned)
|
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
xcb_unmap_window(globalconf.connection, c->window);
|
2008-11-20 22:11:13 +01:00
|
|
|
|
|
|
|
c->isbanned = true;
|
2008-12-06 23:41:33 +01:00
|
|
|
|
2009-04-23 18:05:30 +02:00
|
|
|
if(globalconf.screens.tab[c->phys_screen].prev_client_focus == c)
|
|
|
|
globalconf.screens.tab[c->phys_screen].prev_client_focus = NULL;
|
|
|
|
|
2009-04-07 14:20:22 +02:00
|
|
|
/* Wait until the last moment to take away the focus from the window. */
|
2009-04-17 16:14:09 +02:00
|
|
|
if(globalconf.screens.tab[c->phys_screen].client_focus == c)
|
2009-04-07 14:20:22 +02:00
|
|
|
client_unfocus(c);
|
2009-03-03 17:24:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-30 07:26:19 +02:00
|
|
|
/** This is part of The Bob Marley Algorithm: we ignore enter and leave window
|
2009-08-03 15:57:10 +02:00
|
|
|
* in certain cases, like map/unmap or move, so we don't get spurious events.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
client_ignore_enterleave_events(void)
|
|
|
|
{
|
|
|
|
foreach(c, globalconf.clients)
|
|
|
|
xcb_change_window_attributes(globalconf.connection,
|
2009-08-17 17:02:45 +02:00
|
|
|
(*c)->window,
|
2009-08-03 15:57:10 +02:00
|
|
|
XCB_CW_EVENT_MASK,
|
|
|
|
(const uint32_t []) { CLIENT_SELECT_INPUT_EVENT_MASK & ~(XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW) });
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
client_restore_enterleave_events(void)
|
|
|
|
{
|
|
|
|
foreach(c, globalconf.clients)
|
|
|
|
xcb_change_window_attributes(globalconf.connection,
|
2009-08-17 17:02:45 +02:00
|
|
|
(*c)->window,
|
2009-08-03 15:57:10 +02:00
|
|
|
XCB_CW_EVENT_MASK,
|
|
|
|
(const uint32_t []) { CLIENT_SELECT_INPUT_EVENT_MASK });
|
|
|
|
}
|
|
|
|
|
2009-04-07 14:20:22 +02:00
|
|
|
/** Record that a client got focus.
|
2009-08-17 17:02:45 +02:00
|
|
|
* \param c The client.
|
2007-09-05 20:15:00 +02:00
|
|
|
*/
|
2008-12-15 10:04:46 +01:00
|
|
|
void
|
2009-04-07 14:20:22 +02:00
|
|
|
client_focus_update(client_t *c)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2009-01-02 11:21:34 +01:00
|
|
|
if(!client_maybevisible(c, c->screen))
|
2009-04-23 18:05:30 +02:00
|
|
|
{
|
|
|
|
/* Focus previously focused client */
|
|
|
|
client_focus(globalconf.screen_focus->prev_client_focus);
|
2008-08-11 11:51:54 +02:00
|
|
|
return;
|
2009-04-23 18:05:30 +02:00
|
|
|
}
|
2007-10-03 17:26:14 +02:00
|
|
|
|
2009-04-28 10:54:10 +02:00
|
|
|
if(globalconf.screen_focus
|
|
|
|
&& globalconf.screen_focus->client_focus)
|
|
|
|
{
|
|
|
|
if (globalconf.screen_focus->client_focus != c)
|
|
|
|
client_unfocus_update(globalconf.screen_focus->client_focus);
|
|
|
|
else
|
|
|
|
/* Already focused */
|
|
|
|
return;
|
|
|
|
}
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_object_push(globalconf.L, c);
|
|
|
|
client_set_minimized(globalconf.L, -1, false);
|
2008-07-31 15:51:28 +02:00
|
|
|
|
2009-04-07 14:20:22 +02:00
|
|
|
/* unban the client before focusing for consistency */
|
2008-08-11 11:51:54 +02:00
|
|
|
client_unban(c);
|
2008-07-31 15:51:28 +02:00
|
|
|
|
2009-04-17 16:14:09 +02:00
|
|
|
globalconf.screen_focus = &globalconf.screens.tab[c->phys_screen];
|
2009-04-23 18:05:30 +02:00
|
|
|
globalconf.screen_focus->prev_client_focus = c;
|
2008-08-11 11:51:54 +02:00
|
|
|
globalconf.screen_focus->client_focus = c;
|
2008-06-09 21:43:09 +02:00
|
|
|
|
2009-02-11 18:41:58 +01:00
|
|
|
/* according to EWMH, we have to remove the urgent state from a client */
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_urgent(globalconf.L, -1, false);
|
2009-02-11 18:41:58 +01:00
|
|
|
|
2008-08-11 11:51:54 +02:00
|
|
|
ewmh_update_net_active_window(c->phys_screen);
|
2009-03-03 17:24:40 +01:00
|
|
|
|
2009-04-07 14:20:22 +02:00
|
|
|
/* execute hook */
|
|
|
|
if(globalconf.hooks.focus != LUA_REFNIL)
|
|
|
|
{
|
2009-06-29 11:02:13 +02:00
|
|
|
luaA_object_push(globalconf.L, c);
|
2009-05-19 17:37:35 +02:00
|
|
|
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.focus, 1, 0);
|
2009-04-07 14:20:22 +02:00
|
|
|
}
|
2009-07-10 12:19:08 +02:00
|
|
|
|
|
|
|
luaA_object_push(globalconf.L, c);
|
|
|
|
luaA_class_emit_signal(globalconf.L, &client_class, "focus", 1);
|
2009-04-07 14:20:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Give focus to client, or to first client if client is NULL.
|
2009-08-17 17:02:45 +02:00
|
|
|
* \param c The client.
|
2009-04-07 14:20:22 +02:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
client_focus(client_t *c)
|
|
|
|
{
|
|
|
|
/* We have to set focus on first client */
|
2009-04-10 15:23:55 +02:00
|
|
|
if(!c && globalconf.clients.len && !(c = globalconf.clients.tab[0]))
|
|
|
|
return;
|
2009-04-07 14:20:22 +02:00
|
|
|
|
|
|
|
if(!client_maybevisible(c, c->screen))
|
|
|
|
return;
|
|
|
|
|
2009-04-28 10:54:10 +02:00
|
|
|
if (!c->nofocus)
|
|
|
|
client_focus_update(c);
|
2009-04-07 14:20:22 +02:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_focus(c, !c->nofocus);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-08-21 17:52:44 +02:00
|
|
|
/** Stack a window below.
|
|
|
|
* \param c The client.
|
|
|
|
* \param previous The previous window on the stack.
|
2009-07-27 06:20:00 +02:00
|
|
|
* \return The next-previous!
|
2008-08-21 17:52:44 +02:00
|
|
|
*/
|
|
|
|
static xcb_window_t
|
2008-11-10 12:32:04 +01:00
|
|
|
client_stack_above(client_t *c, xcb_window_t previous)
|
2008-08-21 17:52:44 +02:00
|
|
|
{
|
|
|
|
uint32_t config_win_vals[2];
|
|
|
|
|
|
|
|
config_win_vals[0] = previous;
|
2008-11-10 12:32:04 +01:00
|
|
|
config_win_vals[1] = XCB_STACK_MODE_ABOVE;
|
2008-08-21 17:52:44 +02:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
xcb_configure_window(globalconf.connection, c->window,
|
2008-11-18 10:39:42 +01:00
|
|
|
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
|
|
|
|
config_win_vals);
|
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
config_win_vals[0] = c->window;
|
2008-11-18 10:39:42 +01:00
|
|
|
|
2008-09-24 12:13:21 +02:00
|
|
|
if(c->titlebar)
|
2008-08-21 17:52:44 +02:00
|
|
|
{
|
|
|
|
xcb_configure_window(globalconf.connection,
|
2009-07-28 16:04:58 +02:00
|
|
|
c->titlebar->window,
|
2008-08-21 17:52:44 +02:00
|
|
|
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
|
|
|
|
config_win_vals);
|
2009-07-28 16:04:58 +02:00
|
|
|
previous = c->titlebar->window;
|
2008-08-21 17:52:44 +02:00
|
|
|
}
|
2008-11-18 10:39:42 +01:00
|
|
|
else
|
2009-08-17 17:02:45 +02:00
|
|
|
previous = c->window;
|
2008-11-10 12:32:04 +01:00
|
|
|
|
|
|
|
/* stack transient window on top of their parents */
|
2009-04-17 23:26:26 +02:00
|
|
|
foreach(node, globalconf.stack)
|
|
|
|
if((*node)->transient_for == c)
|
|
|
|
previous = client_stack_above(*node, previous);
|
2008-11-10 12:32:04 +01:00
|
|
|
|
|
|
|
return previous;
|
2008-08-21 17:52:44 +02:00
|
|
|
}
|
|
|
|
|
2008-10-21 17:33:16 +02:00
|
|
|
/** Stacking layout layers */
|
|
|
|
typedef enum
|
|
|
|
{
|
2008-11-03 11:46:57 +01:00
|
|
|
/** This one is a special layer */
|
2008-11-10 12:32:04 +01:00
|
|
|
LAYER_IGNORE,
|
2008-11-03 11:46:57 +01:00
|
|
|
LAYER_DESKTOP,
|
2008-10-21 17:33:16 +02:00
|
|
|
LAYER_BELOW,
|
2008-12-01 16:26:41 +01:00
|
|
|
LAYER_NORMAL,
|
2008-10-21 17:33:16 +02:00
|
|
|
LAYER_ABOVE,
|
2009-01-30 10:47:54 +01:00
|
|
|
LAYER_FULLSCREEN,
|
2009-01-30 12:46:37 +01:00
|
|
|
LAYER_ONTOP,
|
2009-04-10 12:11:35 +02:00
|
|
|
/** This one only used for counting and is not a real layer */
|
|
|
|
LAYER_COUNT
|
2008-10-21 17:33:16 +02:00
|
|
|
} layer_t;
|
|
|
|
|
2008-08-21 17:52:44 +02:00
|
|
|
/** Get the real layer of a client according to its attribute (fullscreen, …)
|
|
|
|
* \param c The client.
|
|
|
|
* \return The real layer.
|
|
|
|
*/
|
|
|
|
static layer_t
|
|
|
|
client_layer_translator(client_t *c)
|
|
|
|
{
|
2008-11-17 09:56:34 +01:00
|
|
|
/* first deal with user set attributes */
|
2009-08-17 17:02:45 +02:00
|
|
|
if(c->ontop)
|
2008-08-21 17:52:44 +02:00
|
|
|
return LAYER_ONTOP;
|
2009-08-17 17:02:45 +02:00
|
|
|
else if(c->fullscreen)
|
2008-08-21 17:52:44 +02:00
|
|
|
return LAYER_FULLSCREEN;
|
2009-08-17 17:02:45 +02:00
|
|
|
else if(c->above)
|
2008-08-21 17:52:44 +02:00
|
|
|
return LAYER_ABOVE;
|
2009-08-17 17:02:45 +02:00
|
|
|
else if(c->below)
|
2008-11-17 09:56:34 +01:00
|
|
|
return LAYER_BELOW;
|
|
|
|
|
|
|
|
/* check for transient attr */
|
|
|
|
if(c->transient_for)
|
2008-11-10 12:32:04 +01:00
|
|
|
return LAYER_IGNORE;
|
2008-09-03 14:59:18 +02:00
|
|
|
|
2008-11-17 09:56:34 +01:00
|
|
|
/* then deal with windows type */
|
2008-09-03 14:59:18 +02:00
|
|
|
switch(c->type)
|
|
|
|
{
|
|
|
|
case WINDOW_TYPE_DESKTOP:
|
|
|
|
return LAYER_DESKTOP;
|
|
|
|
default:
|
2008-11-17 09:56:34 +01:00
|
|
|
break;
|
2008-09-03 14:59:18 +02:00
|
|
|
}
|
2008-11-17 09:56:34 +01:00
|
|
|
|
2008-12-01 16:26:41 +01:00
|
|
|
return LAYER_NORMAL;
|
2008-08-21 17:52:44 +02:00
|
|
|
}
|
|
|
|
|
2008-06-27 22:49:54 +02:00
|
|
|
/** Restack clients.
|
2008-05-25 19:30:54 +02:00
|
|
|
* \todo It might be worth stopping to restack everyone and only stack `c'
|
2008-06-05 09:25:38 +02:00
|
|
|
* relatively to the first matching in the list.
|
2008-05-25 19:30:54 +02:00
|
|
|
*/
|
2009-06-18 18:33:32 +02:00
|
|
|
void
|
|
|
|
client_stack_refresh()
|
2008-03-24 16:34:41 +01:00
|
|
|
{
|
2008-03-21 16:50:17 +01:00
|
|
|
uint32_t config_win_vals[2];
|
2008-04-10 11:52:03 +02:00
|
|
|
layer_t layer;
|
2008-04-08 19:52:59 +02:00
|
|
|
|
2009-06-18 18:33:32 +02:00
|
|
|
if (!globalconf.client_need_stack_refresh)
|
|
|
|
return;
|
|
|
|
globalconf.client_need_stack_refresh = false;
|
|
|
|
|
2008-06-23 14:53:31 +02:00
|
|
|
config_win_vals[0] = XCB_NONE;
|
2008-11-03 11:46:57 +01:00
|
|
|
config_win_vals[1] = XCB_STACK_MODE_ABOVE;
|
2008-06-25 13:41:25 +02:00
|
|
|
|
2008-11-17 09:58:43 +01:00
|
|
|
/* stack desktop windows */
|
|
|
|
for(layer = LAYER_DESKTOP; layer < LAYER_BELOW; layer++)
|
2009-04-17 23:26:26 +02:00
|
|
|
foreach(node, globalconf.stack)
|
|
|
|
if(client_layer_translator(*node) == layer)
|
|
|
|
config_win_vals[0] = client_stack_above(*node,
|
2008-11-17 09:58:43 +01:00
|
|
|
config_win_vals[0]);
|
|
|
|
|
2008-11-03 11:46:57 +01:00
|
|
|
/* first stack not ontop wibox window */
|
2009-05-10 14:55:13 +02:00
|
|
|
foreach(_sb, globalconf.wiboxes)
|
|
|
|
{
|
|
|
|
wibox_t *sb = *_sb;
|
|
|
|
if(!sb->ontop)
|
2008-09-20 16:45:43 +02:00
|
|
|
{
|
2009-05-10 14:55:13 +02:00
|
|
|
xcb_configure_window(globalconf.connection,
|
2009-07-28 16:04:58 +02:00
|
|
|
sb->window,
|
2009-05-10 14:55:13 +02:00
|
|
|
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
|
|
|
|
config_win_vals);
|
2009-07-28 16:04:58 +02:00
|
|
|
config_win_vals[0] = sb->window;
|
2008-09-20 16:45:43 +02:00
|
|
|
}
|
2009-05-10 14:55:13 +02:00
|
|
|
}
|
2008-06-19 19:51:58 +02:00
|
|
|
|
2009-01-30 12:46:37 +01:00
|
|
|
/* then stack clients */
|
2009-04-10 12:11:35 +02:00
|
|
|
for(layer = LAYER_BELOW; layer < LAYER_COUNT; layer++)
|
2009-04-17 23:26:26 +02:00
|
|
|
foreach(node, globalconf.stack)
|
|
|
|
if(client_layer_translator(*node) == layer)
|
|
|
|
config_win_vals[0] = client_stack_above(*node,
|
2008-11-10 12:32:04 +01:00
|
|
|
config_win_vals[0]);
|
2008-09-22 19:23:28 +02:00
|
|
|
|
2008-11-03 11:46:57 +01:00
|
|
|
/* then stack ontop wibox window */
|
2009-05-10 14:55:13 +02:00
|
|
|
foreach(_sb, globalconf.wiboxes)
|
|
|
|
{
|
|
|
|
wibox_t *sb = *_sb;
|
|
|
|
if(sb->ontop)
|
2008-09-22 19:23:28 +02:00
|
|
|
{
|
2009-05-10 14:55:13 +02:00
|
|
|
xcb_configure_window(globalconf.connection,
|
2009-07-28 16:04:58 +02:00
|
|
|
sb->window,
|
2009-05-10 14:55:13 +02:00
|
|
|
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
|
|
|
|
config_win_vals);
|
2009-07-28 16:04:58 +02:00
|
|
|
config_win_vals[0] = sb->window;
|
2008-09-22 19:23:28 +02:00
|
|
|
}
|
2009-05-10 14:55:13 +02:00
|
|
|
}
|
2008-06-27 22:49:54 +02:00
|
|
|
}
|
|
|
|
|
2008-06-05 09:25:38 +02:00
|
|
|
/** Manage a new client.
|
|
|
|
* \param w The window.
|
|
|
|
* \param wgeom Window geometry.
|
2008-09-03 22:25:24 +02:00
|
|
|
* \param phys_screen Physical screen number.
|
2008-12-29 12:23:37 +01:00
|
|
|
* \param startup True if we are managing at startup time.
|
2007-09-20 21:27:43 +02:00
|
|
|
*/
|
2007-09-05 20:15:00 +02:00
|
|
|
void
|
2008-12-29 12:26:01 +01:00
|
|
|
client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen, bool startup)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2009-04-17 16:14:09 +02:00
|
|
|
screen_t *screen;
|
2009-03-06 14:01:29 +01:00
|
|
|
const uint32_t select_input_val[] = { CLIENT_SELECT_INPUT_EVENT_MASK };
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2008-06-30 13:09:24 +02:00
|
|
|
if(systray_iskdedockapp(w))
|
|
|
|
{
|
2008-09-03 22:25:24 +02:00
|
|
|
systray_request_handle(w, phys_screen, NULL);
|
2008-06-30 13:09:24 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-08-24 10:16:52 +02:00
|
|
|
/* If this is a new client that just has been launched, then request its
|
|
|
|
* startup id. */
|
|
|
|
xcb_get_property_cookie_t startup_id_q = { 0 };
|
|
|
|
if(!startup)
|
|
|
|
startup_id_q = xcb_get_any_property(globalconf.connection,
|
|
|
|
false, w, _NET_STARTUP_ID, UINT_MAX);
|
|
|
|
|
2008-12-07 11:05:21 +01:00
|
|
|
xcb_change_window_attributes(globalconf.connection, w, XCB_CW_EVENT_MASK, select_input_val);
|
2009-04-10 15:23:55 +02:00
|
|
|
|
2009-08-08 13:11:37 +02:00
|
|
|
client_t *c = client_new(globalconf.L);
|
2009-04-10 15:23:55 +02:00
|
|
|
/* Push client in client list */
|
2009-06-29 11:02:13 +02:00
|
|
|
client_array_push(&globalconf.clients, luaA_object_ref(globalconf.L, -1));
|
2009-04-10 15:23:55 +02:00
|
|
|
|
2007-10-22 16:25:27 +02:00
|
|
|
|
2009-04-17 16:14:09 +02:00
|
|
|
screen = c->screen = screen_getbycoord(&globalconf.screens.tab[phys_screen],
|
|
|
|
wgeom->x, wgeom->y);
|
2008-01-22 09:50:24 +01:00
|
|
|
|
2008-09-03 22:25:24 +02:00
|
|
|
c->phys_screen = phys_screen;
|
2008-03-21 10:53:17 +01:00
|
|
|
|
2009-05-19 14:49:22 +02:00
|
|
|
/* consider the window banned */
|
|
|
|
c->isbanned = true;
|
|
|
|
|
2008-01-13 16:30:43 +01:00
|
|
|
/* Initial values */
|
2009-08-17 17:02:45 +02:00
|
|
|
c->window = w;
|
2008-12-01 16:26:41 +01:00
|
|
|
c->geometry.x = wgeom->x;
|
|
|
|
c->geometry.y = wgeom->y;
|
2009-02-08 13:48:16 +01:00
|
|
|
/* Border will be added later. */
|
|
|
|
c->geometry.width = wgeom->width;
|
|
|
|
c->geometry.height = wgeom->height;
|
2008-12-12 00:01:43 +01:00
|
|
|
/* Also set internal geometry (client_ban() needs it). */
|
|
|
|
c->geometries.internal.x = wgeom->x;
|
|
|
|
c->geometries.internal.y = wgeom->y;
|
|
|
|
c->geometries.internal.width = wgeom->width;
|
|
|
|
c->geometries.internal.height = wgeom->height;
|
2009-04-09 11:38:56 +02:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
/* Push client */
|
|
|
|
luaA_object_push(globalconf.L, c);
|
|
|
|
client_set_border_width(globalconf.L, -1, wgeom->border_width);
|
|
|
|
lua_pop(globalconf.L, 1);
|
2007-10-22 16:25:27 +02:00
|
|
|
|
2008-09-03 20:22:33 +02:00
|
|
|
/* we honor size hints by default */
|
2008-12-09 11:38:29 +01:00
|
|
|
c->size_hints_honor = true;
|
2008-09-03 20:22:33 +02:00
|
|
|
|
2008-01-13 16:30:43 +01:00
|
|
|
/* update hints */
|
2008-09-16 14:09:56 +02:00
|
|
|
property_update_wm_normal_hints(c, NULL);
|
|
|
|
property_update_wm_hints(c, NULL);
|
2008-09-16 18:07:42 +02:00
|
|
|
property_update_wm_transient_for(c, NULL);
|
2008-12-01 19:44:28 +01:00
|
|
|
property_update_wm_client_leader(c, NULL);
|
2009-08-22 15:05:29 +02:00
|
|
|
property_update_wm_client_machine(c, NULL);
|
2009-08-24 10:05:50 +02:00
|
|
|
property_update_wm_window_role(c, NULL);
|
2009-08-10 11:40:06 +02:00
|
|
|
property_update_net_wm_pid(c, NULL);
|
2009-08-17 17:02:45 +02:00
|
|
|
property_update_net_wm_icon(c, NULL);
|
2008-09-16 18:07:42 +02:00
|
|
|
|
2009-08-10 11:59:17 +02:00
|
|
|
/* get opacity */
|
2009-08-17 17:02:45 +02:00
|
|
|
c->opacity = window_opacity_get(c->window);
|
2009-08-10 11:59:17 +02:00
|
|
|
|
2008-03-15 14:46:45 +01:00
|
|
|
/* Then check clients hints */
|
2008-09-18 13:51:10 +02:00
|
|
|
ewmh_client_check_hints(c);
|
2008-01-13 16:30:43 +01:00
|
|
|
|
2009-08-24 16:32:19 +02:00
|
|
|
screen_client_moveto(c, screen, true);
|
2008-11-05 10:24:23 +01:00
|
|
|
|
2008-05-25 19:47:19 +02:00
|
|
|
/* Push client in stack */
|
2008-06-12 13:12:38 +02:00
|
|
|
client_raise(c);
|
2007-10-22 16:25:27 +02:00
|
|
|
|
2008-06-05 09:25:38 +02:00
|
|
|
/* update window title */
|
2009-08-24 10:05:50 +02:00
|
|
|
property_update_wm_name(c, NULL);
|
2009-08-25 16:39:10 +02:00
|
|
|
property_update_net_wm_name(c, NULL);
|
2009-08-24 10:05:50 +02:00
|
|
|
property_update_wm_icon_name(c, NULL);
|
2009-08-25 16:39:10 +02:00
|
|
|
property_update_net_wm_icon_name(c, NULL);
|
2009-04-18 14:20:06 +02:00
|
|
|
property_update_wm_class(c, NULL);
|
2009-08-24 11:11:52 +02:00
|
|
|
property_update_wm_protocols(c, NULL);
|
2008-06-05 09:25:38 +02:00
|
|
|
|
2008-09-03 22:15:14 +02:00
|
|
|
/* update strut */
|
2009-02-07 19:40:07 +01:00
|
|
|
ewmh_process_client_strut(c, NULL);
|
2008-09-03 22:15:14 +02:00
|
|
|
|
2008-06-17 23:20:03 +02:00
|
|
|
ewmh_update_net_client_list(c->phys_screen);
|
|
|
|
|
2008-11-20 22:11:13 +01:00
|
|
|
/* Always stay in NORMAL_STATE. Even though iconified seems more
|
|
|
|
* appropriate sometimes. The only possible loss is that clients not using
|
2009-08-30 07:26:19 +02:00
|
|
|
* visibility events may continue to process data (when banned).
|
2008-11-20 22:11:13 +01:00
|
|
|
* Without any exposes or other events the cost should be fairly limited though.
|
|
|
|
*
|
|
|
|
* Some clients may expect the window to be unmapped when STATE_ICONIFIED.
|
|
|
|
* Two conflicting parts of the ICCCM v2.0 (section 4.1.4):
|
|
|
|
*
|
|
|
|
* "Normal -> Iconic - The client should send a ClientMessage event as described later in this section."
|
|
|
|
* (note no explicit mention of unmapping, while Normal->Widthdrawn does mention that)
|
|
|
|
*
|
|
|
|
* "Once a client's window has left the Withdrawn state, the window will be mapped
|
|
|
|
* if it is in the Normal state and the window will be unmapped if it is in the Iconic state."
|
|
|
|
*
|
|
|
|
* At this stage it's just safer to keep it in normal state and avoid confusion.
|
|
|
|
*/
|
2009-08-17 17:02:45 +02:00
|
|
|
window_state_set(c->window, XCB_WM_STATE_NORMAL);
|
2008-11-20 22:11:13 +01:00
|
|
|
|
2009-04-03 16:30:18 +02:00
|
|
|
if(!startup)
|
2009-08-24 10:16:52 +02:00
|
|
|
{
|
|
|
|
/* Request our response */
|
|
|
|
xcb_get_property_reply_t *reply =
|
|
|
|
xcb_get_property_reply(globalconf.connection, startup_id_q, NULL);
|
|
|
|
/* Say spawn that a client has been started, with startup id as argument */
|
|
|
|
char *startup_id = xutil_get_text_property_from_reply(reply);
|
|
|
|
p_delete(&reply);
|
|
|
|
spawn_start_notify(c, startup_id);
|
|
|
|
p_delete(&startup_id);
|
|
|
|
}
|
2009-04-03 16:30:18 +02:00
|
|
|
|
2008-10-20 15:01:16 +02:00
|
|
|
/* Call hook to notify list change */
|
2008-11-20 17:48:23 +01:00
|
|
|
if(globalconf.hooks.clients != LUA_REFNIL)
|
2009-05-19 17:37:35 +02:00
|
|
|
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.clients, 0, 0);
|
2008-10-20 15:01:16 +02:00
|
|
|
|
2009-07-11 09:02:25 +02:00
|
|
|
luaA_class_emit_signal(globalconf.L, &client_class, "list", 0);
|
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
/* call hook */
|
2008-11-20 17:48:23 +01:00
|
|
|
if(globalconf.hooks.manage != LUA_REFNIL)
|
|
|
|
{
|
2009-06-29 11:02:13 +02:00
|
|
|
luaA_object_push(globalconf.L, c);
|
2008-12-29 12:23:37 +01:00
|
|
|
lua_pushboolean(globalconf.L, startup);
|
2009-05-19 17:37:35 +02:00
|
|
|
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.manage, 2, 0);
|
2008-11-20 17:48:23 +01:00
|
|
|
}
|
2009-07-10 14:36:04 +02:00
|
|
|
|
|
|
|
luaA_object_push(globalconf.L, c);
|
|
|
|
lua_pushboolean(globalconf.L, startup);
|
|
|
|
luaA_class_emit_signal(globalconf.L, &client_class, "manage", 2);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-06-10 19:29:53 +02:00
|
|
|
/** Compute client geometry with respect to its geometry hints.
|
|
|
|
* \param c The client.
|
|
|
|
* \param geometry The geometry that the client might receive.
|
2008-06-18 13:58:31 +02:00
|
|
|
* \return The geometry the client must take respecting its hints.
|
2008-06-10 19:29:53 +02:00
|
|
|
*/
|
2008-06-18 13:58:31 +02:00
|
|
|
area_t
|
2008-04-11 11:35:11 +02:00
|
|
|
client_geometry_hints(client_t *c, area_t geometry)
|
2008-03-14 14:27:56 +01:00
|
|
|
{
|
2008-12-09 11:38:29 +01:00
|
|
|
int32_t basew, baseh, minw, minh;
|
2008-03-14 14:27:56 +01:00
|
|
|
|
2008-12-09 11:38:29 +01:00
|
|
|
/* base size is substituted with min size if not specified */
|
|
|
|
if(c->size_hints.flags & XCB_SIZE_HINT_P_SIZE)
|
2008-03-14 14:27:56 +01:00
|
|
|
{
|
2008-12-09 11:38:29 +01:00
|
|
|
basew = c->size_hints.base_width;
|
|
|
|
baseh = c->size_hints.base_height;
|
|
|
|
}
|
|
|
|
else if(c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)
|
|
|
|
{
|
|
|
|
basew = c->size_hints.min_width;
|
|
|
|
baseh = c->size_hints.min_height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
basew = baseh = 0;
|
|
|
|
|
|
|
|
/* min size is substituted with base size if not specified */
|
|
|
|
if(c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)
|
|
|
|
{
|
|
|
|
minw = c->size_hints.min_width;
|
|
|
|
minh = c->size_hints.min_height;
|
|
|
|
}
|
|
|
|
else if(c->size_hints.flags & XCB_SIZE_HINT_P_SIZE)
|
|
|
|
{
|
|
|
|
minw = c->size_hints.base_width;
|
|
|
|
minh = c->size_hints.base_height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
minw = minh = 0;
|
|
|
|
|
|
|
|
if(c->size_hints.flags & XCB_SIZE_HINT_P_ASPECT
|
|
|
|
&& c->size_hints.min_aspect_num > 0
|
|
|
|
&& c->size_hints.min_aspect_den > 0
|
|
|
|
&& geometry.height - baseh > 0
|
|
|
|
&& geometry.width - basew > 0)
|
|
|
|
{
|
|
|
|
double dx = (double) (geometry.width - basew);
|
|
|
|
double dy = (double) (geometry.height - baseh);
|
|
|
|
double min = (double) c->size_hints.min_aspect_num / (double) c->size_hints.min_aspect_den;
|
|
|
|
double max = (double) c->size_hints.max_aspect_num / (double) c->size_hints.min_aspect_den;
|
|
|
|
double ratio = dx / dy;
|
2008-03-14 14:27:56 +01:00
|
|
|
if(max > 0 && min > 0 && ratio > 0)
|
|
|
|
{
|
|
|
|
if(ratio < min)
|
|
|
|
{
|
|
|
|
dy = (dx * min + dy) / (min * min + 1);
|
|
|
|
dx = dy * min;
|
2008-12-09 11:38:29 +01:00
|
|
|
geometry.width = (int) dx + basew;
|
|
|
|
geometry.height = (int) dy + baseh;
|
2008-03-14 14:27:56 +01:00
|
|
|
}
|
|
|
|
else if(ratio > max)
|
|
|
|
{
|
|
|
|
dy = (dx * min + dy) / (max * max + 1);
|
|
|
|
dx = dy * min;
|
2008-12-09 11:38:29 +01:00
|
|
|
geometry.width = (int) dx + basew;
|
|
|
|
geometry.height = (int) dy + baseh;
|
2008-03-14 14:27:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-12-09 11:38:29 +01:00
|
|
|
|
|
|
|
if(minw)
|
|
|
|
geometry.width = MAX(geometry.width, minw);
|
|
|
|
if(minh)
|
|
|
|
geometry.height = MAX(geometry.height, minh);
|
|
|
|
|
|
|
|
if(c->size_hints.flags & XCB_SIZE_HINT_P_MAX_SIZE)
|
|
|
|
{
|
|
|
|
if(c->size_hints.max_width)
|
|
|
|
geometry.width = MIN(geometry.width, c->size_hints.max_width);
|
|
|
|
if(c->size_hints.max_height)
|
|
|
|
geometry.height = MIN(geometry.height, c->size_hints.max_height);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(c->size_hints.flags & (XCB_SIZE_HINT_P_RESIZE_INC | XCB_SIZE_HINT_BASE_SIZE)
|
|
|
|
&& c->size_hints.width_inc && c->size_hints.height_inc)
|
|
|
|
{
|
2008-12-12 00:01:43 +01:00
|
|
|
uint16_t t1 = geometry.width, t2 = geometry.height;
|
|
|
|
unsigned_subtract(t1, basew);
|
|
|
|
unsigned_subtract(t2, baseh);
|
|
|
|
geometry.width -= t1 % c->size_hints.width_inc;
|
|
|
|
geometry.height -= t2 % c->size_hints.height_inc;
|
2008-12-09 11:38:29 +01:00
|
|
|
}
|
2008-03-14 14:27:56 +01:00
|
|
|
|
|
|
|
return geometry;
|
|
|
|
}
|
|
|
|
|
2008-05-27 20:17:33 +02:00
|
|
|
/** Resize client window.
|
2009-08-30 07:26:19 +02:00
|
|
|
* The sizes given as parameters are with titlebar and borders!
|
2008-05-27 20:17:33 +02:00
|
|
|
* \param c Client to resize.
|
|
|
|
* \param geometry New window geometry.
|
|
|
|
* \param hints Use size hints.
|
2009-02-08 13:48:17 +01:00
|
|
|
* \return true if an actual resize occurred.
|
2007-12-30 15:08:38 +01:00
|
|
|
*/
|
2009-02-08 13:48:17 +01:00
|
|
|
bool
|
2008-04-11 11:35:11 +02:00
|
|
|
client_resize(client_t *c, area_t geometry, bool hints)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-12-12 00:01:43 +01:00
|
|
|
area_t geometry_internal;
|
2008-06-09 21:43:09 +02:00
|
|
|
area_t area;
|
2008-03-26 10:57:06 +01:00
|
|
|
|
2008-06-09 21:43:09 +02:00
|
|
|
/* offscreen appearance fixes */
|
2009-05-05 17:32:53 +02:00
|
|
|
area = display_area_get(c->phys_screen);
|
2008-06-09 21:43:09 +02:00
|
|
|
|
|
|
|
if(geometry.x > area.width)
|
2008-12-12 00:01:43 +01:00
|
|
|
geometry.x = area.width - geometry.width;
|
2008-06-09 21:43:09 +02:00
|
|
|
if(geometry.y > area.height)
|
2008-12-12 00:01:43 +01:00
|
|
|
geometry.y = area.height - geometry.height;
|
|
|
|
if(geometry.x + geometry.width < 0)
|
2008-06-09 21:43:09 +02:00
|
|
|
geometry.x = 0;
|
2008-12-12 00:01:43 +01:00
|
|
|
if(geometry.y + geometry.height < 0)
|
2008-06-09 21:43:09 +02:00
|
|
|
geometry.y = 0;
|
|
|
|
|
2008-12-12 00:01:43 +01:00
|
|
|
/* Real client geometry, please keep it contained to C code at the very least. */
|
2009-08-17 17:02:45 +02:00
|
|
|
geometry_internal = titlebar_geometry_remove(c->titlebar, c->border_width, geometry);
|
2008-12-12 00:01:43 +01:00
|
|
|
|
|
|
|
if(hints)
|
|
|
|
geometry_internal = client_geometry_hints(c, geometry_internal);
|
|
|
|
|
|
|
|
if(geometry_internal.width == 0 || geometry_internal.height == 0)
|
2009-02-08 13:48:17 +01:00
|
|
|
return false;
|
2008-12-12 00:01:43 +01:00
|
|
|
|
2009-08-30 07:26:19 +02:00
|
|
|
/* Also let client hints propagate to the "official" geometry. */
|
2009-08-17 17:02:45 +02:00
|
|
|
geometry = titlebar_geometry_add(c->titlebar, c->border_width, geometry_internal);
|
2008-12-12 00:01:43 +01:00
|
|
|
|
|
|
|
if(c->geometries.internal.x != geometry_internal.x
|
|
|
|
|| c->geometries.internal.y != geometry_internal.y
|
|
|
|
|| c->geometries.internal.width != geometry_internal.width
|
|
|
|
|| c->geometries.internal.height != geometry_internal.height)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2009-04-17 16:14:09 +02:00
|
|
|
screen_t *new_screen = screen_getbycoord(c->screen,
|
|
|
|
geometry_internal.x, geometry_internal.y);
|
2008-01-06 14:40:23 +01:00
|
|
|
|
2008-11-15 14:09:41 +01:00
|
|
|
/* Values to configure a window is an array where values are
|
|
|
|
* stored according to 'value_mask' */
|
|
|
|
uint32_t values[4];
|
|
|
|
|
2008-12-12 00:01:43 +01:00
|
|
|
c->geometries.internal.x = values[0] = geometry_internal.x;
|
|
|
|
c->geometries.internal.y = values[1] = geometry_internal.y;
|
|
|
|
c->geometries.internal.width = values[2] = geometry_internal.width;
|
|
|
|
c->geometries.internal.height = values[3] = geometry_internal.height;
|
|
|
|
|
|
|
|
/* Also store geometry including border and titlebar. */
|
|
|
|
c->geometry = geometry;
|
2008-03-14 14:27:56 +01:00
|
|
|
|
2008-11-25 17:01:06 +01:00
|
|
|
titlebar_update_geometry(c);
|
2008-01-06 14:40:23 +01:00
|
|
|
|
2009-08-03 15:57:10 +02:00
|
|
|
/* Ignore all spurious enter/leave notify events */
|
|
|
|
client_ignore_enterleave_events();
|
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
xcb_configure_window(globalconf.connection, c->window,
|
2008-11-15 14:09:41 +01:00
|
|
|
XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y
|
|
|
|
| XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
|
2008-03-21 16:50:17 +01:00
|
|
|
values);
|
2008-01-06 14:40:23 +01:00
|
|
|
|
2009-08-03 15:57:10 +02:00
|
|
|
client_restore_enterleave_events();
|
|
|
|
|
2009-08-24 16:32:19 +02:00
|
|
|
screen_client_moveto(c, new_screen, false);
|
2008-03-26 11:03:52 +01:00
|
|
|
|
2008-09-24 12:13:21 +02:00
|
|
|
/* execute hook */
|
2009-06-29 11:02:13 +02:00
|
|
|
hook_property(c, "geometry");
|
2009-02-08 13:48:17 +01:00
|
|
|
|
|
|
|
return true;
|
2008-09-24 12:13:21 +02:00
|
|
|
}
|
2009-02-08 13:48:17 +01:00
|
|
|
|
|
|
|
return false;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-09-18 13:51:10 +02:00
|
|
|
/** Set a client minimized, or not.
|
2009-08-17 17:02:45 +02:00
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param cidx The client index.
|
2008-09-18 13:51:10 +02:00
|
|
|
* \param s Set or not the client minimized.
|
|
|
|
*/
|
|
|
|
void
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_minimized(lua_State *L, int cidx, bool s)
|
2008-09-18 13:51:10 +02:00
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
|
|
|
|
if(c->minimized != s)
|
2008-09-18 13:51:10 +02:00
|
|
|
{
|
2009-05-10 16:51:20 +02:00
|
|
|
client_need_reban(c);
|
2009-08-17 17:02:45 +02:00
|
|
|
c->minimized = s;
|
2009-05-10 16:51:20 +02:00
|
|
|
client_need_reban(c);
|
2009-06-05 14:59:51 +02:00
|
|
|
if(s)
|
2009-08-17 17:02:45 +02:00
|
|
|
window_state_set(c->window, XCB_WM_STATE_ICONIC);
|
2009-06-05 14:59:51 +02:00
|
|
|
else
|
2009-08-17 17:02:45 +02:00
|
|
|
window_state_set(c->window, XCB_WM_STATE_NORMAL);
|
2008-09-18 13:51:10 +02:00
|
|
|
ewmh_client_update_hints(c);
|
2009-08-28 17:49:28 +02:00
|
|
|
if(strut_has_value(&c->strut))
|
|
|
|
screen_emit_signal(globalconf.L, c->screen, "property::workarea", 0);
|
2008-09-22 17:54:48 +02:00
|
|
|
/* execute hook */
|
2009-06-29 11:02:13 +02:00
|
|
|
hook_property(c, "minimized");
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_object_emit_signal(L, cidx, "property::minimized", 0);
|
2008-09-18 13:51:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-21 16:29:53 +02:00
|
|
|
/** Set a client sticky, or not.
|
2009-08-17 17:02:45 +02:00
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param cidx The client index.
|
2008-08-21 16:29:53 +02:00
|
|
|
* \param s Set or not the client sticky.
|
|
|
|
*/
|
|
|
|
void
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_sticky(lua_State *L, int cidx, bool s)
|
2008-08-21 16:29:53 +02:00
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
|
|
|
|
if(c->sticky != s)
|
2008-08-21 16:29:53 +02:00
|
|
|
{
|
2009-05-10 16:51:20 +02:00
|
|
|
client_need_reban(c);
|
2009-08-17 17:02:45 +02:00
|
|
|
c->sticky = s;
|
2009-05-10 16:51:20 +02:00
|
|
|
client_need_reban(c);
|
2008-09-18 13:51:10 +02:00
|
|
|
ewmh_client_update_hints(c);
|
2009-06-29 11:02:13 +02:00
|
|
|
hook_property(c, "sticky");
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_object_emit_signal(L, cidx, "property::sticky", 0);
|
2008-08-21 16:29:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-21 17:52:44 +02:00
|
|
|
/** Set a client fullscreen, or not.
|
2009-08-17 17:02:45 +02:00
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param cidx The client index.
|
2008-08-21 17:52:44 +02:00
|
|
|
* \param s Set or not the client fullscreen.
|
|
|
|
*/
|
|
|
|
void
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_fullscreen(lua_State *L, int cidx, bool s)
|
2008-08-21 17:52:44 +02:00
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
|
|
|
|
if(c->fullscreen != s)
|
2008-08-21 17:52:44 +02:00
|
|
|
{
|
|
|
|
area_t geometry;
|
|
|
|
|
|
|
|
/* become fullscreen! */
|
2009-08-20 10:37:21 +02:00
|
|
|
if(s)
|
2008-08-21 17:52:44 +02:00
|
|
|
{
|
2009-08-20 10:37:21 +02:00
|
|
|
/* Make sure the current geometry is stored without titlebar. */
|
|
|
|
titlebar_ban(c->titlebar);
|
2008-11-25 11:54:38 +01:00
|
|
|
/* remove any max state */
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_maximized_horizontal(L, cidx, false);
|
|
|
|
client_set_maximized_vertical(L, cidx, false);
|
2009-02-08 23:55:30 +01:00
|
|
|
/* You can only be part of one of the special layers. */
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_below(L, cidx, false);
|
|
|
|
client_set_above(L, cidx, false);
|
|
|
|
client_set_ontop(L, cidx, false);
|
2008-11-25 11:54:38 +01:00
|
|
|
|
2009-05-05 17:32:53 +02:00
|
|
|
geometry = screen_area_get(c->screen, false);
|
2008-11-25 11:24:25 +01:00
|
|
|
c->geometries.fullscreen = c->geometry;
|
2009-08-17 17:02:45 +02:00
|
|
|
c->border_width_fs = c->border_width;
|
|
|
|
client_set_border_width(L, cidx, 0);
|
2009-08-20 10:37:21 +02:00
|
|
|
c->fullscreen = true;
|
2008-08-21 17:52:44 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-11-25 11:24:25 +01:00
|
|
|
geometry = c->geometries.fullscreen;
|
2009-08-20 10:37:21 +02:00
|
|
|
c->fullscreen = false;
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_border_width(L, cidx, c->border_width_fs);
|
2008-08-21 17:52:44 +02:00
|
|
|
}
|
|
|
|
client_resize(c, geometry, false);
|
|
|
|
client_stack();
|
2008-09-18 13:51:10 +02:00
|
|
|
ewmh_client_update_hints(c);
|
2009-06-29 11:02:13 +02:00
|
|
|
hook_property(c, "fullscreen");
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_object_emit_signal(L, cidx, "property::fullscreen", 0);
|
2008-08-21 17:52:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-25 11:54:38 +01:00
|
|
|
/** Set a client horizontally maximized.
|
2009-08-17 17:02:45 +02:00
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param cidx The client index.
|
2008-11-25 11:54:38 +01:00
|
|
|
* \param s The maximized status.
|
|
|
|
*/
|
|
|
|
void
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_maximized_horizontal(lua_State *L, int cidx, bool s)
|
2008-11-25 11:54:38 +01:00
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
|
|
|
|
if(c->maximized_horizontal != s)
|
2008-11-25 11:54:38 +01:00
|
|
|
{
|
|
|
|
area_t geometry;
|
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
if((c->maximized_horizontal = s))
|
2008-11-25 11:54:38 +01:00
|
|
|
{
|
|
|
|
/* remove fullscreen mode */
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_fullscreen(L, cidx, false);
|
2008-11-25 11:54:38 +01:00
|
|
|
|
2009-05-05 17:32:53 +02:00
|
|
|
geometry = screen_area_get(c->screen, true);
|
2008-11-25 11:54:38 +01:00
|
|
|
geometry.y = c->geometry.y;
|
|
|
|
geometry.height = c->geometry.height;
|
|
|
|
c->geometries.max.x = c->geometry.x;
|
|
|
|
c->geometries.max.width = c->geometry.width;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
geometry = c->geometry;
|
|
|
|
geometry.x = c->geometries.max.x;
|
|
|
|
geometry.width = c->geometries.max.width;
|
|
|
|
}
|
|
|
|
|
2008-12-09 11:38:29 +01:00
|
|
|
client_resize(c, geometry, c->size_hints_honor);
|
2008-11-25 11:54:38 +01:00
|
|
|
client_stack();
|
|
|
|
ewmh_client_update_hints(c);
|
2009-06-29 11:02:13 +02:00
|
|
|
hook_property(c, "maximized_horizontal");
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_object_emit_signal(L, cidx, "property::maximized_horizontal", 0);
|
2008-11-25 11:54:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set a client vertically maximized.
|
2009-08-17 17:02:45 +02:00
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param cidx The client index.
|
2008-11-25 11:54:38 +01:00
|
|
|
* \param s The maximized status.
|
|
|
|
*/
|
|
|
|
void
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_maximized_vertical(lua_State *L, int cidx, bool s)
|
2008-11-25 11:54:38 +01:00
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
|
|
|
|
if(c->maximized_vertical != s)
|
2008-11-25 11:54:38 +01:00
|
|
|
{
|
|
|
|
area_t geometry;
|
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
if((c->maximized_vertical = s))
|
2008-11-25 11:54:38 +01:00
|
|
|
{
|
|
|
|
/* remove fullscreen mode */
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_fullscreen(L, cidx, false);
|
2008-11-25 11:54:38 +01:00
|
|
|
|
2009-05-05 17:32:53 +02:00
|
|
|
geometry = screen_area_get(c->screen, true);
|
2008-11-25 11:54:38 +01:00
|
|
|
geometry.x = c->geometry.x;
|
|
|
|
geometry.width = c->geometry.width;
|
|
|
|
c->geometries.max.y = c->geometry.y;
|
|
|
|
c->geometries.max.height = c->geometry.height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
geometry = c->geometry;
|
|
|
|
geometry.y = c->geometries.max.y;
|
|
|
|
geometry.height = c->geometries.max.height;
|
|
|
|
}
|
|
|
|
|
2008-12-09 11:38:29 +01:00
|
|
|
client_resize(c, geometry, c->size_hints_honor);
|
2008-11-25 11:54:38 +01:00
|
|
|
client_stack();
|
|
|
|
ewmh_client_update_hints(c);
|
2009-06-29 11:02:13 +02:00
|
|
|
hook_property(c, "maximized_vertical");
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_object_emit_signal(L, cidx, "property::maximized_vertical", 0);
|
2008-11-25 11:54:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-21 17:52:44 +02:00
|
|
|
/** Set a client above, or not.
|
2009-08-17 17:02:45 +02:00
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param cidx The client index.
|
2008-08-21 17:52:44 +02:00
|
|
|
* \param s Set or not the client above.
|
|
|
|
*/
|
|
|
|
void
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_above(lua_State *L, int cidx, bool s)
|
2008-08-21 17:52:44 +02:00
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
|
|
|
|
if(c->above != s)
|
2008-08-21 17:52:44 +02:00
|
|
|
{
|
2009-02-08 23:55:30 +01:00
|
|
|
/* You can only be part of one of the special layers. */
|
|
|
|
if(s)
|
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_below(L, cidx, false);
|
|
|
|
client_set_ontop(L, cidx, false);
|
|
|
|
client_set_fullscreen(L, cidx, false);
|
2009-02-08 23:55:30 +01:00
|
|
|
}
|
2009-08-17 17:02:45 +02:00
|
|
|
c->above = s;
|
2008-08-21 17:52:44 +02:00
|
|
|
client_stack();
|
2008-09-18 13:51:10 +02:00
|
|
|
ewmh_client_update_hints(c);
|
2008-09-22 17:54:48 +02:00
|
|
|
/* execute hook */
|
2009-06-29 11:02:13 +02:00
|
|
|
hook_property(c, "above");
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_object_emit_signal(L, cidx, "property::above", 0);
|
2008-08-21 17:52:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set a client below, or not.
|
2009-08-17 17:02:45 +02:00
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param cidx The client index.
|
2008-08-21 17:52:44 +02:00
|
|
|
* \param s Set or not the client below.
|
|
|
|
*/
|
|
|
|
void
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_below(lua_State *L, int cidx, bool s)
|
2008-08-21 17:52:44 +02:00
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
|
|
|
|
if(c->below != s)
|
2008-08-21 17:52:44 +02:00
|
|
|
{
|
2009-02-08 23:55:30 +01:00
|
|
|
/* You can only be part of one of the special layers. */
|
|
|
|
if(s)
|
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_above(L, cidx, false);
|
|
|
|
client_set_ontop(L, cidx, false);
|
|
|
|
client_set_fullscreen(L, cidx, false);
|
2009-02-08 23:55:30 +01:00
|
|
|
}
|
2009-08-17 17:02:45 +02:00
|
|
|
c->below = s;
|
2008-08-21 17:52:44 +02:00
|
|
|
client_stack();
|
2008-09-18 13:51:10 +02:00
|
|
|
ewmh_client_update_hints(c);
|
2008-09-22 17:54:48 +02:00
|
|
|
/* execute hook */
|
2009-06-29 11:02:13 +02:00
|
|
|
hook_property(c, "below");
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_object_emit_signal(L, cidx, "property::below", 0);
|
2008-08-21 17:52:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set a client modal, or not.
|
2009-08-17 17:02:45 +02:00
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param cidx The client index.
|
|
|
|
* \param s Set or not the client modal attribute.
|
2008-08-21 17:52:44 +02:00
|
|
|
*/
|
|
|
|
void
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_modal(lua_State *L, int cidx, bool s)
|
2008-08-21 17:52:44 +02:00
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
|
|
|
|
if(c->modal != s)
|
2008-08-21 17:52:44 +02:00
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
c->modal = s;
|
2008-08-21 17:52:44 +02:00
|
|
|
client_stack();
|
2008-09-18 13:51:10 +02:00
|
|
|
ewmh_client_update_hints(c);
|
2008-09-22 17:54:48 +02:00
|
|
|
/* execute hook */
|
2009-06-29 11:02:13 +02:00
|
|
|
hook_property(c, "modal");
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_object_emit_signal(L, cidx, "property::modal", 0);
|
2008-08-21 17:52:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set a client ontop, or not.
|
2009-08-17 17:02:45 +02:00
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param cidx The client index.
|
|
|
|
* \param s Set or not the client ontop attribute.
|
2008-08-21 17:52:44 +02:00
|
|
|
*/
|
|
|
|
void
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_ontop(lua_State *L, int cidx, bool s)
|
2008-08-21 17:52:44 +02:00
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
|
|
|
|
if(c->ontop != s)
|
2008-08-21 17:52:44 +02:00
|
|
|
{
|
2009-02-08 23:55:30 +01:00
|
|
|
/* You can only be part of one of the special layers. */
|
|
|
|
if(s)
|
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_above(L, cidx, false);
|
|
|
|
client_set_below(L, cidx, false);
|
|
|
|
client_set_fullscreen(L, cidx, false);
|
2009-02-08 23:55:30 +01:00
|
|
|
}
|
2009-08-17 17:02:45 +02:00
|
|
|
c->ontop = s;
|
2008-08-21 17:52:44 +02:00
|
|
|
client_stack();
|
2008-09-22 17:54:48 +02:00
|
|
|
/* execute hook */
|
2009-06-29 11:02:13 +02:00
|
|
|
hook_property(c, "ontop");
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_object_emit_signal(L, cidx, "property::ontop", 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set a client skip taskbar attribute.
|
|
|
|
* \param L Tha Lua VM state.
|
|
|
|
* \param cidx The client index.
|
|
|
|
* \param s Set or not the client skip taskbar attribute.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
client_set_skip_taskbar(lua_State *L, int cidx, bool s)
|
|
|
|
{
|
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
|
|
|
|
|
|
|
if(c->skip_taskbar != s)
|
|
|
|
{
|
|
|
|
c->skip_taskbar = s;
|
2009-08-25 11:18:19 +02:00
|
|
|
ewmh_client_update_hints(c);
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_object_emit_signal(L, cidx, "property::skip_taskbar", 0);
|
2008-08-21 17:52:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-20 22:11:13 +01:00
|
|
|
/** Unban a client and move it back into the viewport.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \param c The client.
|
|
|
|
*/
|
2007-09-05 20:15:00 +02:00
|
|
|
void
|
2008-04-11 11:35:11 +02:00
|
|
|
client_unban(client_t *c)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-11-20 22:11:13 +01:00
|
|
|
if(c->isbanned)
|
2008-09-20 11:28:50 +02:00
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
xcb_map_window(globalconf.connection, c->window);
|
2008-11-20 22:11:13 +01:00
|
|
|
|
|
|
|
c->isbanned = false;
|
2008-09-20 11:28:50 +02:00
|
|
|
}
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-06-10 19:29:53 +02:00
|
|
|
/** Unmanage a client.
|
|
|
|
* \param c The client.
|
|
|
|
*/
|
2007-09-05 20:15:00 +02:00
|
|
|
void
|
2008-04-11 11:35:11 +02:00
|
|
|
client_unmanage(client_t *c)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2009-04-17 16:14:09 +02:00
|
|
|
tag_array_t *tags = &c->screen->tags;
|
2008-06-09 21:43:09 +02:00
|
|
|
|
2009-08-30 07:26:19 +02:00
|
|
|
/* Reset transient_for attributes of widows that maybe referring to us */
|
2009-04-09 17:17:10 +02:00
|
|
|
foreach(_tc, globalconf.clients)
|
|
|
|
{
|
|
|
|
client_t *tc = *_tc;
|
2009-02-08 14:00:30 +01:00
|
|
|
if(tc->transient_for == c)
|
|
|
|
tc->transient_for = NULL;
|
2009-04-09 17:17:10 +02:00
|
|
|
}
|
2009-02-08 14:00:30 +01:00
|
|
|
|
2009-04-23 18:05:30 +02:00
|
|
|
if(globalconf.screens.tab[c->phys_screen].prev_client_focus == c)
|
|
|
|
globalconf.screens.tab[c->phys_screen].prev_client_focus = NULL;
|
|
|
|
|
2009-04-17 16:14:09 +02:00
|
|
|
if(globalconf.screens.tab[c->phys_screen].client_focus == c)
|
2008-07-31 17:29:05 +02:00
|
|
|
client_unfocus(c);
|
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
/* remove client from global list and everywhere else */
|
|
|
|
foreach(elem, globalconf.clients)
|
|
|
|
if(*elem == c)
|
2009-04-09 17:17:10 +02:00
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
client_array_remove(&globalconf.clients, elem);
|
2009-04-09 17:17:10 +02:00
|
|
|
break;
|
|
|
|
}
|
2009-04-17 23:26:26 +02:00
|
|
|
stack_client_remove(c);
|
2008-10-20 15:01:16 +02:00
|
|
|
for(int i = 0; i < tags->len; i++)
|
|
|
|
untag_client(c, tags->tab[i]);
|
|
|
|
|
2008-06-10 19:03:10 +02:00
|
|
|
/* call hook */
|
2008-11-20 17:48:23 +01:00
|
|
|
if(globalconf.hooks.unmanage != LUA_REFNIL)
|
|
|
|
{
|
2009-06-29 11:02:13 +02:00
|
|
|
luaA_object_push(globalconf.L, c);
|
2009-05-19 17:37:35 +02:00
|
|
|
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.unmanage, 1, 0);
|
2008-11-20 17:48:23 +01:00
|
|
|
}
|
2008-06-10 19:03:10 +02:00
|
|
|
|
2009-07-10 14:38:37 +02:00
|
|
|
luaA_object_push(globalconf.L, c);
|
|
|
|
luaA_class_emit_signal(globalconf.L, &client_class, "unmanage", 1);
|
|
|
|
|
2008-10-20 15:01:16 +02:00
|
|
|
/* Call hook to notify list change */
|
2008-11-20 17:48:23 +01:00
|
|
|
if(globalconf.hooks.clients != LUA_REFNIL)
|
2009-05-19 17:37:35 +02:00
|
|
|
luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.clients, 0, 0);
|
2008-10-20 15:01:16 +02:00
|
|
|
|
2009-07-11 09:02:25 +02:00
|
|
|
luaA_class_emit_signal(globalconf.L, &client_class, "list", 0);
|
|
|
|
|
2009-08-28 17:49:28 +02:00
|
|
|
if(strut_has_value(&c->strut))
|
|
|
|
screen_emit_signal(globalconf.L, c->screen, "property::workarea", 0);
|
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
window_state_set(c->window, XCB_WM_STATE_WITHDRAWN);
|
2008-01-06 21:57:53 +01:00
|
|
|
|
2008-09-24 12:13:21 +02:00
|
|
|
titlebar_client_detach(c);
|
2008-03-14 14:27:56 +01:00
|
|
|
|
2008-06-17 23:20:03 +02:00
|
|
|
ewmh_update_net_client_list(c->phys_screen);
|
|
|
|
|
2008-07-31 17:29:05 +02:00
|
|
|
/* set client as invalid */
|
|
|
|
c->invalid = true;
|
|
|
|
|
2009-06-29 11:02:13 +02:00
|
|
|
luaA_object_unref(globalconf.L, c);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-10-11 09:38:48 +02:00
|
|
|
/** Kill a client via a WM_DELETE_WINDOW request or KillClient if not
|
2008-03-31 20:07:13 +02:00
|
|
|
* supported.
|
2008-06-05 09:25:38 +02:00
|
|
|
* \param c The client to kill.
|
2008-03-31 20:07:13 +02:00
|
|
|
*/
|
2007-10-01 20:42:59 +02:00
|
|
|
void
|
2008-04-11 11:35:11 +02:00
|
|
|
client_kill(client_t *c)
|
2007-10-01 20:42:59 +02:00
|
|
|
{
|
2009-06-24 18:10:55 +02:00
|
|
|
if(client_hasproto(c, WM_DELETE_WINDOW))
|
2007-10-01 20:42:59 +02:00
|
|
|
{
|
2008-10-11 09:38:48 +02:00
|
|
|
xcb_client_message_event_t ev;
|
|
|
|
|
2008-03-28 14:48:05 +01:00
|
|
|
/* Initialize all of event's fields first */
|
2008-06-05 09:25:38 +02:00
|
|
|
p_clear(&ev, 1);
|
2008-03-28 14:48:05 +01:00
|
|
|
|
|
|
|
ev.response_type = XCB_CLIENT_MESSAGE;
|
2009-08-17 17:02:45 +02:00
|
|
|
ev.window = c->window;
|
2008-03-28 14:48:05 +01:00
|
|
|
ev.format = 32;
|
2008-03-21 16:50:17 +01:00
|
|
|
ev.data.data32[1] = XCB_CURRENT_TIME;
|
2008-06-30 18:55:14 +02:00
|
|
|
ev.type = WM_PROTOCOLS;
|
|
|
|
ev.data.data32[0] = WM_DELETE_WINDOW;
|
2008-03-21 16:50:17 +01:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
xcb_send_event(globalconf.connection, false, c->window,
|
2008-03-21 16:50:17 +01:00
|
|
|
XCB_EVENT_MASK_NO_EVENT, (char *) &ev);
|
2007-10-01 20:42:59 +02:00
|
|
|
}
|
|
|
|
else
|
2009-08-17 17:02:45 +02:00
|
|
|
xcb_kill_client(globalconf.connection, c->window);
|
2007-12-27 20:49:38 +01:00
|
|
|
}
|
|
|
|
|
2008-06-05 09:25:38 +02:00
|
|
|
/** Get all clients into a table.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \param L The Lua VM state.
|
2008-09-18 15:07:34 +02:00
|
|
|
* \return The number of elements pushed on stack.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \luastack
|
2009-08-30 07:26:19 +02:00
|
|
|
* \lparam An optional screen number.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \lreturn A table with all clients.
|
2008-06-05 09:25:38 +02:00
|
|
|
*/
|
2008-05-20 15:39:47 +02:00
|
|
|
static int
|
|
|
|
luaA_client_get(lua_State *L)
|
2007-12-27 20:49:38 +01:00
|
|
|
{
|
2008-09-18 15:11:18 +02:00
|
|
|
int i = 1, screen;
|
2007-12-27 20:49:38 +01:00
|
|
|
|
2008-09-18 15:11:18 +02:00
|
|
|
screen = luaL_optnumber(L, 1, 0) - 1;
|
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
lua_newtable(L);
|
|
|
|
|
2009-04-17 16:14:09 +02:00
|
|
|
if(screen == -1)
|
2009-04-10 15:23:55 +02:00
|
|
|
foreach(c, globalconf.clients)
|
2008-09-18 15:11:18 +02:00
|
|
|
{
|
2009-06-29 11:02:13 +02:00
|
|
|
luaA_object_push(L, *c);
|
2008-09-18 15:11:18 +02:00
|
|
|
lua_rawseti(L, -2, i++);
|
|
|
|
}
|
|
|
|
else
|
2008-05-23 13:17:02 +02:00
|
|
|
{
|
2008-09-18 15:11:18 +02:00
|
|
|
luaA_checkscreen(screen);
|
2009-04-10 15:23:55 +02:00
|
|
|
foreach(c, globalconf.clients)
|
2009-04-17 16:14:09 +02:00
|
|
|
if((*c)->screen == &globalconf.screens.tab[screen])
|
2008-09-18 15:11:18 +02:00
|
|
|
{
|
2009-06-29 11:02:13 +02:00
|
|
|
luaA_object_push(L, *c);
|
2008-09-18 15:11:18 +02:00
|
|
|
lua_rawseti(L, -2, i++);
|
|
|
|
}
|
2008-05-23 13:17:02 +02:00
|
|
|
}
|
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
return 1;
|
2007-10-01 20:42:59 +02:00
|
|
|
}
|
2008-01-01 17:37:16 +01:00
|
|
|
|
2008-09-18 15:07:34 +02:00
|
|
|
/** Check if a client is visible on its screen.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
* \luastack
|
|
|
|
* \lvalue A client.
|
|
|
|
* \lreturn A boolean value, true if the client is visible, false otherwise.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_client_isvisible(lua_State *L)
|
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, 1);
|
|
|
|
lua_pushboolean(L, client_isvisible(c, c->screen));
|
2008-09-18 15:07:34 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-05-28 14:33:45 +02:00
|
|
|
/** Set client border width.
|
2009-08-17 17:02:45 +02:00
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param cidx The client index.
|
2008-06-05 09:25:38 +02:00
|
|
|
* \param width The border width.
|
2008-05-28 14:33:45 +02:00
|
|
|
*/
|
|
|
|
void
|
2009-08-17 17:02:45 +02:00
|
|
|
client_set_border_width(lua_State *L, int cidx, int width)
|
2008-05-28 14:33:45 +02:00
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
2008-06-11 08:12:38 +02:00
|
|
|
uint32_t w = width;
|
|
|
|
|
2008-09-03 14:59:18 +02:00
|
|
|
if(width > 0 && (c->type == WINDOW_TYPE_DOCK
|
|
|
|
|| c->type == WINDOW_TYPE_SPLASH
|
|
|
|
|| c->type == WINDOW_TYPE_DESKTOP
|
2009-08-17 17:02:45 +02:00
|
|
|
|| c->fullscreen))
|
2008-09-03 14:59:18 +02:00
|
|
|
return;
|
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
if(width == c->border_width || width < 0)
|
2008-05-28 14:33:45 +02:00
|
|
|
return;
|
|
|
|
|
2009-08-20 10:37:21 +02:00
|
|
|
/* disallow change of border width if the client is fullscreen */
|
|
|
|
if(c->fullscreen)
|
|
|
|
return;
|
|
|
|
|
2009-02-08 13:48:16 +01:00
|
|
|
/* Update geometry with the new border. */
|
2009-08-17 17:02:45 +02:00
|
|
|
c->geometry.width -= 2 * c->border_width;
|
|
|
|
c->geometry.height -= 2 * c->border_width;
|
2009-02-08 13:48:16 +01:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
c->border_width = width;
|
|
|
|
xcb_configure_window(globalconf.connection, c->window,
|
2008-06-11 08:12:38 +02:00
|
|
|
XCB_CONFIG_WINDOW_BORDER_WIDTH, &w);
|
2008-07-30 10:04:03 +02:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
c->geometry.width += 2 * c->border_width;
|
|
|
|
c->geometry.height += 2 * c->border_width;
|
2008-09-22 17:54:48 +02:00
|
|
|
|
2009-02-02 20:16:57 +01:00
|
|
|
/* Changing border size also affects the size of the titlebar. */
|
2009-03-26 22:13:42 +01:00
|
|
|
titlebar_update_geometry(c);
|
2009-02-02 20:16:57 +01:00
|
|
|
|
2009-06-29 11:02:13 +02:00
|
|
|
hook_property(c, "border_width");
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_object_emit_signal(L, cidx, "property::border_width", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set a client icon.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param cidx The client index on the stack.
|
2009-08-25 04:55:10 +02:00
|
|
|
* \param iidx The image index on the stack.
|
2009-08-17 17:02:45 +02:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
client_set_icon(lua_State *L, int cidx, int iidx)
|
|
|
|
{
|
|
|
|
client_t *c = luaA_client_checkudata(L, cidx);
|
2009-08-21 20:55:13 +02:00
|
|
|
/* convert index to absolute */
|
|
|
|
cidx = luaA_absindex(L, cidx);
|
|
|
|
iidx = luaA_absindex(L, iidx);
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_checkudata(L, iidx, &image_class);
|
|
|
|
luaA_object_unref_item(L, cidx, c->icon);
|
|
|
|
c->icon = luaA_object_ref_item(L, cidx, iidx);
|
2009-08-21 20:55:13 +02:00
|
|
|
luaA_object_emit_signal(L, cidx < iidx ? cidx : cidx - 1, "property::icon", 0);
|
2009-08-17 17:02:45 +02:00
|
|
|
/* execute hook */
|
|
|
|
hook_property(c, "icon");
|
2008-05-28 14:33:45 +02:00
|
|
|
}
|
|
|
|
|
2008-06-10 19:29:53 +02:00
|
|
|
/** Kill a client.
|
|
|
|
* \param L The Lua VM state.
|
2008-06-11 02:46:30 +02:00
|
|
|
*
|
|
|
|
* \luastack
|
|
|
|
* \lvalue A client.
|
2008-06-10 19:29:53 +02:00
|
|
|
*/
|
2008-05-20 15:39:47 +02:00
|
|
|
static int
|
|
|
|
luaA_client_kill(lua_State *L)
|
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, 1);
|
|
|
|
client_kill(c);
|
2008-05-20 15:39:47 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2008-02-06 08:49:31 +01:00
|
|
|
|
2008-06-10 19:29:53 +02:00
|
|
|
/** Swap a client with another one.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \luastack
|
2008-06-11 02:46:30 +02:00
|
|
|
* \lvalue A client.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \lparam A client to swap with.
|
|
|
|
*/
|
2008-05-20 15:39:47 +02:00
|
|
|
static int
|
|
|
|
luaA_client_swap(lua_State *L)
|
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, 1);
|
|
|
|
client_t *swap = luaA_client_checkudata(L, 2);
|
2008-10-20 15:01:16 +02:00
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
if(c != swap)
|
2008-11-14 10:36:15 +01:00
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
client_t **ref_c = NULL, **ref_swap = NULL;
|
|
|
|
foreach(item, globalconf.clients)
|
|
|
|
{
|
|
|
|
if(*item == c)
|
|
|
|
ref_c = item;
|
|
|
|
else if(*item == swap)
|
|
|
|
ref_swap = item;
|
|
|
|
if(ref_c && ref_swap)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* swap ! */
|
|
|
|
*ref_c = swap;
|
|
|
|
*ref_swap = c;
|
|
|
|
|
2008-11-14 10:36:15 +01:00
|
|
|
/* Call hook to notify list change */
|
|
|
|
if(globalconf.hooks.clients != LUA_REFNIL)
|
2009-05-19 17:37:35 +02:00
|
|
|
luaA_dofunction_from_registry(L, globalconf.hooks.clients, 0, 0);
|
2009-07-11 09:02:25 +02:00
|
|
|
|
|
|
|
luaA_class_emit_signal(globalconf.L, &client_class, "list", 0);
|
2008-11-14 10:36:15 +01:00
|
|
|
}
|
2008-10-20 15:01:16 +02:00
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
return 0;
|
2008-02-06 08:49:31 +01:00
|
|
|
}
|
|
|
|
|
2008-08-13 17:49:57 +02:00
|
|
|
/** Access or set the client tags.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
* \lparam A table with tags to set, or none to get the current tags table.
|
|
|
|
* \return The clients tag.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_client_tags(lua_State *L)
|
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, 1);
|
2009-04-17 16:14:09 +02:00
|
|
|
tag_array_t *tags = &c->screen->tags;
|
2008-08-17 07:52:04 +02:00
|
|
|
int j = 0;
|
2008-08-13 17:49:57 +02:00
|
|
|
|
|
|
|
if(lua_gettop(L) == 2)
|
|
|
|
{
|
|
|
|
luaA_checktable(L, 2);
|
|
|
|
for(int i = 0; i < tags->len; i++)
|
2009-04-10 15:23:55 +02:00
|
|
|
untag_client(c, tags->tab[i]);
|
2008-08-13 17:49:57 +02:00
|
|
|
lua_pushnil(L);
|
|
|
|
while(lua_next(L, 2))
|
2009-04-11 11:45:55 +02:00
|
|
|
tag_client(c);
|
2008-08-17 07:52:04 +02:00
|
|
|
lua_pop(L, 1);
|
2008-08-13 17:49:57 +02:00
|
|
|
}
|
2008-08-17 07:52:04 +02:00
|
|
|
|
2009-03-14 13:47:50 +01:00
|
|
|
lua_newtable(L);
|
2009-04-11 11:45:55 +02:00
|
|
|
foreach(tag, *tags)
|
|
|
|
if(is_client_tagged(c, *tag))
|
2008-08-17 07:52:04 +02:00
|
|
|
{
|
2009-06-29 11:02:13 +02:00
|
|
|
luaA_object_push(L, *tag);
|
2008-08-17 07:52:04 +02:00
|
|
|
lua_rawseti(L, -2, ++j);
|
|
|
|
}
|
2008-08-13 17:49:57 +02:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-05-26 16:17:57 +02:00
|
|
|
/** Raise a client on top of others which are on the same layer.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \param L The Lua VM state.
|
2008-06-11 02:46:30 +02:00
|
|
|
* \luastack
|
|
|
|
* \lvalue A client.
|
2008-05-26 16:17:57 +02:00
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_client_raise(lua_State *L)
|
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, 1);
|
|
|
|
client_raise(c);
|
2008-05-20 15:39:47 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2008-05-11 18:41:04 +02:00
|
|
|
|
2008-11-12 11:27:58 +01:00
|
|
|
/** Lower a client on bottom of others which are on the same layer.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \luastack
|
|
|
|
* \lvalue A client.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_client_lower(lua_State *L)
|
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, 1);
|
2009-08-28 17:53:48 +02:00
|
|
|
|
|
|
|
stack_client_push(c);
|
|
|
|
|
|
|
|
/* Traverse all transient layers. */
|
|
|
|
for(client_t *tc = c->transient_for; tc; tc = tc->transient_for)
|
|
|
|
stack_client_push(tc);
|
|
|
|
|
|
|
|
client_stack();
|
|
|
|
|
2008-11-12 11:27:58 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-10 19:29:53 +02:00
|
|
|
/** Redraw a client by unmapping and mapping it quickly.
|
|
|
|
* \param L The Lua VM state.
|
2008-06-11 02:46:30 +02:00
|
|
|
*
|
|
|
|
* \luastack
|
|
|
|
* \lvalue A client.
|
2008-06-10 19:29:53 +02:00
|
|
|
*/
|
2008-05-20 15:39:47 +02:00
|
|
|
static int
|
|
|
|
luaA_client_redraw(lua_State *L)
|
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, 1);
|
2008-08-20 23:57:27 +02:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
xcb_unmap_window(globalconf.connection, c->window);
|
|
|
|
xcb_map_window(globalconf.connection, c->window);
|
2008-08-20 23:57:27 +02:00
|
|
|
|
|
|
|
/* Set the focus on the current window if the redraw has been
|
|
|
|
performed on the window where the pointer is currently on
|
|
|
|
because after the unmapping/mapping, the focus is lost */
|
2009-04-10 15:23:55 +02:00
|
|
|
if(globalconf.screen_focus->client_focus == c)
|
2009-03-03 17:24:40 +01:00
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
client_unfocus(c);
|
|
|
|
client_focus(c);
|
2009-03-03 17:24:40 +01:00
|
|
|
}
|
2008-08-21 08:12:28 +02:00
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-02 08:31:54 +02:00
|
|
|
/** Stop managing a client.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \param L The Lua VM state.
|
2008-08-26 16:03:01 +02:00
|
|
|
* \return The number of elements pushed on stack.
|
2008-06-11 02:46:30 +02:00
|
|
|
* \luastack
|
|
|
|
* \lvalue A client.
|
2008-06-02 08:31:54 +02:00
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_client_unmanage(lua_State *L)
|
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, 1);
|
|
|
|
client_unmanage(c);
|
2008-06-02 08:31:54 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-10-21 15:31:52 +02:00
|
|
|
/** Return client geometry.
|
2008-08-26 16:03:01 +02:00
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \return The number of elements pushed on stack.
|
2008-12-12 00:01:43 +01:00
|
|
|
* \luastack
|
|
|
|
* \lparam A table with new coordinates, or none.
|
|
|
|
* \lreturn A table with client coordinates.
|
2008-08-26 16:03:01 +02:00
|
|
|
*/
|
2008-08-20 12:00:22 +02:00
|
|
|
static int
|
2008-12-12 00:01:43 +01:00
|
|
|
luaA_client_geometry(lua_State *L)
|
2008-08-20 12:00:22 +02:00
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, 1);
|
2008-08-20 12:00:22 +02:00
|
|
|
|
|
|
|
if(lua_gettop(L) == 2)
|
2008-11-25 17:01:06 +01:00
|
|
|
{
|
|
|
|
area_t geometry;
|
2008-08-20 12:00:22 +02:00
|
|
|
|
2008-11-25 17:01:06 +01:00
|
|
|
luaA_checktable(L, 2);
|
2009-04-10 15:23:55 +02:00
|
|
|
geometry.x = luaA_getopt_number(L, 2, "x", c->geometry.x);
|
|
|
|
geometry.y = luaA_getopt_number(L, 2, "y", c->geometry.y);
|
|
|
|
if(client_isfixed(c))
|
2008-11-25 17:01:06 +01:00
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
geometry.width = c->geometry.width;
|
|
|
|
geometry.height = c->geometry.height;
|
2008-11-25 17:01:06 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
geometry.width = luaA_getopt_number(L, 2, "width", c->geometry.width);
|
|
|
|
geometry.height = luaA_getopt_number(L, 2, "height", c->geometry.height);
|
2008-08-20 12:00:22 +02:00
|
|
|
}
|
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
client_resize(c, geometry, c->size_hints_honor);
|
2008-11-25 17:01:06 +01:00
|
|
|
}
|
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
return luaA_pusharea(L, c->geometry);
|
2008-08-20 12:00:22 +02:00
|
|
|
}
|
|
|
|
|
2009-02-07 19:40:07 +01:00
|
|
|
/** Return client struts (reserved space at the edge of the screen).
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
* \luastack
|
|
|
|
* \lparam A table with new strut values, or none.
|
|
|
|
* \lreturn A table with strut values.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_client_struts(lua_State *L)
|
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, 1);
|
2009-02-07 19:40:07 +01:00
|
|
|
|
|
|
|
if(lua_gettop(L) == 2)
|
|
|
|
{
|
2009-08-18 14:13:37 +02:00
|
|
|
luaA_tostrut(L, 2, &c->strut);
|
|
|
|
ewmh_update_strut(c->window, &c->strut);
|
|
|
|
hook_property(c, "struts");
|
|
|
|
luaA_object_emit_signal(L, 1, "property::struts", 0);
|
2009-08-18 15:53:45 +02:00
|
|
|
screen_emit_signal(L, c->screen, "property::workarea", 0);
|
2009-02-07 19:40:07 +01:00
|
|
|
}
|
|
|
|
|
2009-08-18 12:00:25 +02:00
|
|
|
return luaA_pushstrut(L, c->strut);
|
2009-02-07 19:40:07 +01:00
|
|
|
}
|
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
static int
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_client_set_screen(lua_State *L, client_t *c)
|
2008-07-01 19:37:10 +02:00
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
if(globalconf.xinerama_is_active)
|
|
|
|
{
|
|
|
|
int screen = luaL_checknumber(L, -1) - 1;
|
|
|
|
luaA_checkscreen(screen);
|
2009-08-24 16:32:19 +02:00
|
|
|
screen_client_moveto(c, &globalconf.screens.tab[screen], true);
|
2009-08-17 17:02:45 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2008-07-01 19:37:10 +02:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
static int
|
|
|
|
luaA_client_set_hidden(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
bool b = luaA_checkboolean(L, -1);
|
|
|
|
if(b != c->hidden)
|
2008-07-01 19:37:10 +02:00
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
client_need_reban(c);
|
|
|
|
c->hidden = b;
|
|
|
|
client_need_reban(c);
|
|
|
|
hook_property(c, "hidden");
|
2009-08-28 17:49:28 +02:00
|
|
|
if(strut_has_value(&c->strut))
|
|
|
|
screen_emit_signal(globalconf.L, c->screen, "property::workarea", 0);
|
2009-08-25 10:05:26 +02:00
|
|
|
luaA_object_emit_signal(L, -3, "property::hidden", 0);
|
2008-07-01 19:37:10 +02:00
|
|
|
}
|
2009-08-17 17:02:45 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2008-07-01 19:37:10 +02:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
static int
|
|
|
|
luaA_client_set_minimized(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
client_set_minimized(L, -3, luaA_checkboolean(L, -1));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_client_set_fullscreen(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
client_set_fullscreen(L, -3, luaA_checkboolean(L, -1));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_client_set_modal(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
client_set_modal(L, -3, luaA_checkboolean(L, -1));
|
2008-07-01 19:37:10 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_client_set_maximized_horizontal(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
client_set_maximized_horizontal(L, -3, luaA_checkboolean(L, -1));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_client_set_maximized_vertical(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
client_set_maximized_vertical(L, -3, luaA_checkboolean(L, -1));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_client_set_icon(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
client_set_icon(L, -3, -1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_client_set_opacity(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
if(lua_isnil(L, -1))
|
|
|
|
client_set_opacity(L, -3, -1);
|
|
|
|
else
|
|
|
|
client_set_opacity(L, -3, luaL_checknumber(L, -1));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_client_set_sticky(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
client_set_sticky(L, -3, luaA_checkboolean(L, -1));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_client_set_size_hints_honor(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
c->size_hints_honor = luaA_checkboolean(L, -1);
|
|
|
|
hook_property(c, "size_hints_honor");
|
|
|
|
luaA_object_emit_signal(L, -3, "property::size_hints_honor", 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_client_set_border_width(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
client_set_border_width(L, -3, luaL_checknumber(L, -1));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_client_set_ontop(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
client_set_ontop(L, -3, luaA_checkboolean(L, -1));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_client_set_below(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
client_set_below(L, -3, luaA_checkboolean(L, -1));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_client_set_above(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
client_set_above(L, -3, luaA_checkboolean(L, -1));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_client_set_urgent(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
client_set_urgent(L, -3, luaA_checkboolean(L, -1));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_client_set_border_color(lua_State *L, client_t *c)
|
2008-07-01 19:37:10 +02:00
|
|
|
{
|
|
|
|
size_t len;
|
2009-08-17 17:02:45 +02:00
|
|
|
const char *buf;
|
|
|
|
if((buf = luaL_checklstring(L, -1, &len))
|
|
|
|
&& xcolor_init_reply(xcolor_init_unchecked(&c->border_color, buf, len)))
|
|
|
|
{
|
|
|
|
xcb_change_window_attributes(globalconf.connection, c->window,
|
|
|
|
XCB_CW_BORDER_PIXEL, &c->border_color.pixel);
|
|
|
|
luaA_object_emit_signal(L, -3, "property::border_color", 0);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2008-07-01 19:37:10 +02:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
static int
|
|
|
|
luaA_client_set_titlebar(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
if(lua_isnil(L, -1))
|
|
|
|
titlebar_client_detach(c);
|
|
|
|
else
|
|
|
|
titlebar_client_attach(c);
|
|
|
|
return 0;
|
|
|
|
}
|
2008-07-01 19:37:10 +02:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
static int
|
|
|
|
luaA_client_set_skip_taskbar(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
client_set_skip_taskbar(L, -3, luaA_checkboolean(L, -1));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-25 16:39:10 +02:00
|
|
|
static int
|
|
|
|
luaA_client_get_name(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
lua_pushstring(L, c->name ? c->name : c->alt_name);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_client_get_icon_name(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
lua_pushstring(L, c->icon_name ? c->icon_name : c->alt_icon_name);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, class, lua_pushstring)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, instance, lua_pushstring)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, machine, lua_pushstring)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, role, lua_pushstring)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, transient_for, luaA_object_push)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, skip_taskbar, lua_pushboolean)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, window, lua_pushnumber)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, leader_window, lua_pushnumber)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, group_window, lua_pushnumber)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, pid, lua_pushnumber)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, hidden, lua_pushboolean)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, minimized, lua_pushboolean)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, fullscreen, lua_pushboolean)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, modal, lua_pushboolean)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, ontop, lua_pushboolean)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, urgent, lua_pushboolean)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, above, lua_pushboolean)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, below, lua_pushboolean)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, sticky, lua_pushboolean)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, size_hints_honor, lua_pushboolean)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, maximized_horizontal, lua_pushboolean)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, maximized_vertical, lua_pushboolean)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, opacity, lua_pushnumber)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, border_width, lua_pushnumber)
|
|
|
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, border_color, luaA_pushxcolor)
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_client_get_content(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
xcb_image_t *ximage = xcb_image_get(globalconf.connection,
|
|
|
|
c->window,
|
|
|
|
0, 0,
|
|
|
|
c->geometries.internal.width,
|
|
|
|
c->geometries.internal.height,
|
|
|
|
~0, XCB_IMAGE_FORMAT_Z_PIXMAP);
|
|
|
|
int retval = 0;
|
|
|
|
|
|
|
|
if(ximage)
|
2008-07-01 19:37:10 +02:00
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
if(ximage->bpp >= 24)
|
2008-09-03 15:11:06 +02:00
|
|
|
{
|
2009-08-17 17:02:45 +02:00
|
|
|
uint32_t *data = p_alloca(uint32_t, ximage->width * ximage->height);
|
|
|
|
|
|
|
|
for(int y = 0; y < ximage->height; y++)
|
|
|
|
for(int x = 0; x < ximage->width; x++)
|
|
|
|
{
|
|
|
|
data[y * ximage->width + x] = xcb_image_get_pixel(ximage, x, y);
|
|
|
|
data[y * ximage->width + x] |= 0xff000000; /* set alpha to 0xff */
|
|
|
|
}
|
|
|
|
|
|
|
|
retval = image_new_from_argb32(ximage->width, ximage->height, data);
|
2008-09-03 15:11:06 +02:00
|
|
|
}
|
2009-08-17 17:02:45 +02:00
|
|
|
xcb_image_destroy(ximage);
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
luaA_client_get_type(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
switch(c->type)
|
|
|
|
{
|
|
|
|
case WINDOW_TYPE_DESKTOP:
|
|
|
|
lua_pushliteral(L, "desktop");
|
2008-09-03 15:11:06 +02:00
|
|
|
break;
|
2009-08-17 17:02:45 +02:00
|
|
|
case WINDOW_TYPE_DOCK:
|
|
|
|
lua_pushliteral(L, "dock");
|
2008-08-21 17:58:08 +02:00
|
|
|
break;
|
2009-08-17 17:02:45 +02:00
|
|
|
case WINDOW_TYPE_SPLASH:
|
|
|
|
lua_pushliteral(L, "splash");
|
2008-12-01 19:06:35 +01:00
|
|
|
break;
|
2009-08-17 17:02:45 +02:00
|
|
|
case WINDOW_TYPE_DIALOG:
|
|
|
|
lua_pushliteral(L, "dialog");
|
2008-11-25 11:54:38 +01:00
|
|
|
break;
|
2009-08-17 17:02:45 +02:00
|
|
|
case WINDOW_TYPE_MENU:
|
|
|
|
lua_pushliteral(L, "menu");
|
2008-11-25 11:54:38 +01:00
|
|
|
break;
|
2009-08-17 17:02:45 +02:00
|
|
|
case WINDOW_TYPE_TOOLBAR:
|
|
|
|
lua_pushliteral(L, "toolbar");
|
2008-07-01 19:49:35 +02:00
|
|
|
break;
|
2009-08-17 17:02:45 +02:00
|
|
|
case WINDOW_TYPE_UTILITY:
|
|
|
|
lua_pushliteral(L, "utility");
|
2008-08-15 02:00:58 +02:00
|
|
|
break;
|
2009-08-17 17:02:45 +02:00
|
|
|
case WINDOW_TYPE_DROPDOWN_MENU:
|
|
|
|
lua_pushliteral(L, "dropdown_menu");
|
2008-08-21 17:52:44 +02:00
|
|
|
break;
|
2009-08-17 17:02:45 +02:00
|
|
|
case WINDOW_TYPE_POPUP_MENU:
|
|
|
|
lua_pushliteral(L, "popup_menu");
|
2009-02-08 23:55:30 +01:00
|
|
|
break;
|
2009-08-17 17:02:45 +02:00
|
|
|
case WINDOW_TYPE_TOOLTIP:
|
|
|
|
lua_pushliteral(L, "tooltip");
|
2009-02-08 23:55:30 +01:00
|
|
|
break;
|
2009-08-17 17:02:45 +02:00
|
|
|
case WINDOW_TYPE_NOTIFICATION:
|
|
|
|
lua_pushliteral(L, "notification");
|
2008-08-21 16:29:53 +02:00
|
|
|
break;
|
2009-08-17 17:02:45 +02:00
|
|
|
case WINDOW_TYPE_COMBO:
|
|
|
|
lua_pushliteral(L, "combo");
|
2008-07-01 19:37:10 +02:00
|
|
|
break;
|
2009-08-17 17:02:45 +02:00
|
|
|
case WINDOW_TYPE_DND:
|
|
|
|
lua_pushliteral(L, "dnd");
|
2008-07-01 20:07:21 +02:00
|
|
|
break;
|
2009-08-17 17:02:45 +02:00
|
|
|
case WINDOW_TYPE_NORMAL:
|
|
|
|
lua_pushliteral(L, "normal");
|
2008-07-01 22:08:27 +02:00
|
|
|
break;
|
2009-08-17 17:02:45 +02:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
2008-12-09 13:59:50 +01:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
static int
|
|
|
|
luaA_client_get_screen(lua_State *L, client_t *c)
|
|
|
|
{
|
2009-08-27 10:56:56 +02:00
|
|
|
if(!c->screen)
|
|
|
|
return 0;
|
2009-08-17 17:02:45 +02:00
|
|
|
lua_pushnumber(L, 1 + screen_array_indexof(&globalconf.screens, c->screen));
|
|
|
|
return 1;
|
|
|
|
}
|
2008-12-09 13:59:50 +01:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
static int
|
|
|
|
luaA_client_get_icon(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
return luaA_object_push_item(L, -2, c->icon);
|
|
|
|
}
|
2008-12-09 13:59:50 +01:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
static int
|
|
|
|
luaA_client_get_titlebar(lua_State *L, client_t *c)
|
|
|
|
{
|
2009-08-24 11:44:15 +02:00
|
|
|
return luaA_object_push(L, c->titlebar);
|
2009-08-17 17:02:45 +02:00
|
|
|
}
|
2008-12-09 13:59:50 +01:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
static int
|
|
|
|
luaA_client_get_size_hints(lua_State *L, client_t *c)
|
|
|
|
{
|
|
|
|
const char *u_or_p = NULL;
|
2008-12-09 13:59:50 +01:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
lua_createtable(L, 0, 1);
|
2008-12-09 13:59:50 +01:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
if(c->size_hints.flags & XCB_SIZE_HINT_US_POSITION)
|
|
|
|
u_or_p = "user_position";
|
|
|
|
else if(c->size_hints.flags & XCB_SIZE_HINT_P_POSITION)
|
|
|
|
u_or_p = "program_position";
|
2008-12-09 13:59:50 +01:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
if(u_or_p)
|
|
|
|
{
|
|
|
|
lua_createtable(L, 0, 2);
|
|
|
|
lua_pushnumber(L, c->size_hints.x);
|
|
|
|
lua_setfield(L, -2, "x");
|
|
|
|
lua_pushnumber(L, c->size_hints.y);
|
|
|
|
lua_setfield(L, -2, "y");
|
|
|
|
lua_setfield(L, -2, u_or_p);
|
|
|
|
u_or_p = NULL;
|
|
|
|
}
|
2008-12-09 13:59:50 +01:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
if(c->size_hints.flags & XCB_SIZE_HINT_US_SIZE)
|
|
|
|
u_or_p = "user_size";
|
|
|
|
else if(c->size_hints.flags & XCB_SIZE_HINT_P_SIZE)
|
|
|
|
u_or_p = "program_size";
|
2008-12-09 13:59:50 +01:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
if(u_or_p)
|
|
|
|
{
|
|
|
|
lua_createtable(L, 0, 2);
|
|
|
|
lua_pushnumber(L, c->size_hints.width);
|
|
|
|
lua_setfield(L, -2, "width");
|
|
|
|
lua_pushnumber(L, c->size_hints.height);
|
|
|
|
lua_setfield(L, -2, "height");
|
|
|
|
lua_setfield(L, -2, u_or_p);
|
|
|
|
}
|
2008-12-09 13:59:50 +01:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
if(c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)
|
|
|
|
{
|
|
|
|
lua_pushnumber(L, c->size_hints.min_width);
|
|
|
|
lua_setfield(L, -2, "min_width");
|
|
|
|
lua_pushnumber(L, c->size_hints.min_height);
|
|
|
|
lua_setfield(L, -2, "min_height");
|
|
|
|
}
|
2008-12-09 13:59:50 +01:00
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
if(c->size_hints.flags & XCB_SIZE_HINT_P_MAX_SIZE)
|
|
|
|
{
|
|
|
|
lua_pushnumber(L, c->size_hints.max_width);
|
|
|
|
lua_setfield(L, -2, "max_width");
|
|
|
|
lua_pushnumber(L, c->size_hints.max_height);
|
|
|
|
lua_setfield(L, -2, "max_height");
|
|
|
|
}
|
|
|
|
|
|
|
|
if(c->size_hints.flags & XCB_SIZE_HINT_P_RESIZE_INC)
|
|
|
|
{
|
|
|
|
lua_pushnumber(L, c->size_hints.width_inc);
|
|
|
|
lua_setfield(L, -2, "width_inc");
|
|
|
|
lua_pushnumber(L, c->size_hints.height_inc);
|
|
|
|
lua_setfield(L, -2, "height_inc");
|
|
|
|
}
|
|
|
|
|
|
|
|
if(c->size_hints.flags & XCB_SIZE_HINT_P_ASPECT)
|
|
|
|
{
|
|
|
|
lua_pushnumber(L, c->size_hints.min_aspect_num);
|
|
|
|
lua_setfield(L, -2, "min_aspect_num");
|
|
|
|
lua_pushnumber(L, c->size_hints.min_aspect_den);
|
|
|
|
lua_setfield(L, -2, "min_aspect_den");
|
|
|
|
lua_pushnumber(L, c->size_hints.max_aspect_num);
|
|
|
|
lua_setfield(L, -2, "max_aspect_num");
|
|
|
|
lua_pushnumber(L, c->size_hints.max_aspect_den);
|
|
|
|
lua_setfield(L, -2, "max_aspect_den");
|
|
|
|
}
|
|
|
|
|
|
|
|
if(c->size_hints.flags & XCB_SIZE_HINT_BASE_SIZE)
|
|
|
|
{
|
|
|
|
lua_pushnumber(L, c->size_hints.base_width);
|
|
|
|
lua_setfield(L, -2, "base_width");
|
|
|
|
lua_pushnumber(L, c->size_hints.base_height);
|
|
|
|
lua_setfield(L, -2, "base_height");
|
|
|
|
}
|
|
|
|
|
|
|
|
if(c->size_hints.flags & XCB_SIZE_HINT_P_WIN_GRAVITY)
|
|
|
|
{
|
|
|
|
switch(c->size_hints.win_gravity)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
lua_pushliteral(L, "north_west");
|
|
|
|
break;
|
|
|
|
case XCB_GRAVITY_NORTH:
|
|
|
|
lua_pushliteral(L, "north");
|
|
|
|
break;
|
|
|
|
case XCB_GRAVITY_NORTH_EAST:
|
|
|
|
lua_pushliteral(L, "north_east");
|
|
|
|
break;
|
|
|
|
case XCB_GRAVITY_WEST:
|
|
|
|
lua_pushliteral(L, "west");
|
|
|
|
break;
|
|
|
|
case XCB_GRAVITY_CENTER:
|
|
|
|
lua_pushliteral(L, "center");
|
|
|
|
break;
|
|
|
|
case XCB_GRAVITY_EAST:
|
|
|
|
lua_pushliteral(L, "east");
|
|
|
|
break;
|
|
|
|
case XCB_GRAVITY_SOUTH_WEST:
|
|
|
|
lua_pushliteral(L, "south_west");
|
|
|
|
break;
|
|
|
|
case XCB_GRAVITY_SOUTH:
|
|
|
|
lua_pushliteral(L, "south");
|
|
|
|
break;
|
|
|
|
case XCB_GRAVITY_SOUTH_EAST:
|
|
|
|
lua_pushliteral(L, "south_east");
|
|
|
|
break;
|
|
|
|
case XCB_GRAVITY_STATIC:
|
|
|
|
lua_pushliteral(L, "static");
|
|
|
|
break;
|
2008-12-09 13:59:50 +01:00
|
|
|
}
|
2009-08-17 17:02:45 +02:00
|
|
|
lua_setfield(L, -2, "win_gravity");
|
2008-07-01 19:37:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-08-14 16:46:35 +02:00
|
|
|
/** Get or set mouse buttons bindings for a client.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \return The number of element pushed on stack.
|
|
|
|
* \luastack
|
|
|
|
* \lvalue A client.
|
|
|
|
* \lparam An array of mouse button bindings objects, or nothing.
|
|
|
|
* \return The array of mouse button bindings objects of this client.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_client_buttons(lua_State *L)
|
|
|
|
{
|
|
|
|
client_t *client = luaA_client_checkudata(L, 1);
|
|
|
|
button_array_t *buttons = &client->buttons;
|
|
|
|
|
|
|
|
if(lua_gettop(L) == 2)
|
2009-08-17 17:02:45 +02:00
|
|
|
{
|
2009-08-14 16:46:35 +02:00
|
|
|
luaA_button_array_set(L, 1, 2, buttons);
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_object_emit_signal(L, 1, "property::buttons", 0);
|
|
|
|
window_buttons_grab(client->window, &client->buttons);
|
|
|
|
}
|
2009-08-14 16:52:22 +02:00
|
|
|
|
2009-08-14 16:46:35 +02:00
|
|
|
return luaA_button_array_get(L, 1, buttons);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Get or set keys bindings for a client.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \return The number of element pushed on stack.
|
|
|
|
* \luastack
|
|
|
|
* \lvalue A client.
|
|
|
|
* \lparam An array of key bindings objects, or nothing.
|
|
|
|
* \return The array of key bindings objects of this client.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_client_keys(lua_State *L)
|
|
|
|
{
|
|
|
|
client_t *c = luaA_client_checkudata(L, 1);
|
|
|
|
key_array_t *keys = &c->keys;
|
|
|
|
|
|
|
|
if(lua_gettop(L) == 2)
|
2009-08-14 16:52:22 +02:00
|
|
|
{
|
2009-08-14 16:46:35 +02:00
|
|
|
luaA_key_array_set(L, 1, 2, keys);
|
2009-08-17 17:02:45 +02:00
|
|
|
luaA_object_emit_signal(L, 1, "property::keys", 0);
|
|
|
|
xcb_ungrab_key(globalconf.connection, XCB_GRAB_ANY, c->window, XCB_BUTTON_MASK_ANY);
|
|
|
|
window_grabkeys(c->window, keys);
|
2009-08-14 16:52:22 +02:00
|
|
|
}
|
2009-08-14 16:46:35 +02:00
|
|
|
|
|
|
|
return luaA_key_array_get(L, 1, keys);
|
|
|
|
}
|
|
|
|
|
2008-08-12 12:08:20 +02:00
|
|
|
/* Client module.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \return The number of pushed elements.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_client_module_index(lua_State *L)
|
|
|
|
{
|
|
|
|
size_t len;
|
|
|
|
const char *buf = luaL_checklstring(L, 2, &len);
|
|
|
|
|
|
|
|
switch(a_tokenize(buf, len))
|
|
|
|
{
|
|
|
|
case A_TK_FOCUS:
|
2009-06-29 11:02:13 +02:00
|
|
|
return luaA_object_push(globalconf.L, globalconf.screen_focus->client_focus);
|
2008-08-12 12:08:20 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Client module new index.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \return The number of pushed elements.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_client_module_newindex(lua_State *L)
|
|
|
|
{
|
|
|
|
size_t len;
|
|
|
|
const char *buf = luaL_checklstring(L, 2, &len);
|
2009-04-10 15:23:55 +02:00
|
|
|
client_t *c;
|
2008-08-12 12:08:20 +02:00
|
|
|
|
|
|
|
switch(a_tokenize(buf, len))
|
|
|
|
{
|
|
|
|
case A_TK_FOCUS:
|
2009-04-10 15:23:55 +02:00
|
|
|
c = luaA_client_checkudata(L, 3);
|
|
|
|
client_focus(c);
|
2008-08-12 12:08:20 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-17 17:02:45 +02:00
|
|
|
void
|
|
|
|
client_class_setup(lua_State *L)
|
|
|
|
{
|
|
|
|
static const struct luaL_reg client_methods[] =
|
|
|
|
{
|
|
|
|
LUA_CLASS_METHODS(client)
|
|
|
|
{ "get", luaA_client_get },
|
|
|
|
{ "__index", luaA_client_module_index },
|
|
|
|
{ "__newindex", luaA_client_module_newindex },
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct luaL_reg client_meta[] =
|
|
|
|
{
|
|
|
|
LUA_OBJECT_META(client)
|
|
|
|
LUA_CLASS_META
|
|
|
|
{ "buttons", luaA_client_buttons },
|
|
|
|
{ "keys", luaA_client_keys },
|
|
|
|
{ "isvisible", luaA_client_isvisible },
|
|
|
|
{ "geometry", luaA_client_geometry },
|
|
|
|
{ "struts", luaA_client_struts },
|
|
|
|
{ "tags", luaA_client_tags },
|
|
|
|
{ "kill", luaA_client_kill },
|
|
|
|
{ "swap", luaA_client_swap },
|
|
|
|
{ "raise", luaA_client_raise },
|
|
|
|
{ "lower", luaA_client_lower },
|
|
|
|
{ "redraw", luaA_client_redraw },
|
|
|
|
{ "unmanage", luaA_client_unmanage },
|
|
|
|
{ "__gc", luaA_client_gc },
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
luaA_class_setup(L, &client_class, "client", (lua_class_allocator_t) client_new,
|
2009-08-20 17:37:46 +02:00
|
|
|
luaA_class_index_miss_property, luaA_class_newindex_miss_property,
|
2009-08-17 17:02:45 +02:00
|
|
|
client_methods, client_meta);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_NAME,
|
|
|
|
NULL,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_name,
|
|
|
|
NULL);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_TRANSIENT_FOR,
|
|
|
|
NULL,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_transient_for,
|
|
|
|
NULL);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_SKIP_TASKBAR,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_skip_taskbar,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_skip_taskbar,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_skip_taskbar);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_CONTENT,
|
|
|
|
NULL,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_content,
|
|
|
|
NULL);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_TYPE,
|
|
|
|
NULL,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_type,
|
|
|
|
NULL);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_CLASS,
|
|
|
|
NULL,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_class,
|
|
|
|
NULL);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_INSTANCE,
|
|
|
|
NULL,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_instance,
|
|
|
|
NULL);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_ROLE,
|
|
|
|
NULL,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_role,
|
|
|
|
NULL);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_PID,
|
|
|
|
NULL,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_pid,
|
|
|
|
NULL);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_WINDOW,
|
|
|
|
NULL,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_window,
|
|
|
|
NULL);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_LEADER_WINDOW,
|
|
|
|
NULL,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_leader_window,
|
|
|
|
NULL);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_MACHINE,
|
|
|
|
NULL,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_machine,
|
|
|
|
NULL);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_ICON_NAME,
|
|
|
|
NULL,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_icon_name,
|
|
|
|
NULL);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_SCREEN,
|
|
|
|
NULL,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_screen,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_screen);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_HIDDEN,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_hidden,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_hidden,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_hidden);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_MINIMIZED,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_minimized,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_minimized,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_minimized);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_FULLSCREEN,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_fullscreen,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_fullscreen,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_fullscreen);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_MODAL,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_modal,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_modal,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_modal);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_GROUP_WINDOW,
|
|
|
|
NULL,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_group_window,
|
|
|
|
NULL);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_MAXIMIZED_HORIZONTAL,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_maximized_horizontal,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_maximized_horizontal,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_maximized_horizontal);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_MAXIMIZED_VERTICAL,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_maximized_vertical,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_maximized_vertical,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_maximized_vertical);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_ICON,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_icon,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_icon,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_icon);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_OPACITY,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_opacity,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_opacity,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_opacity);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_ONTOP,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_ontop,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_ontop,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_ontop);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_ABOVE,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_above,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_above,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_above);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_BELOW,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_below,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_below,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_below);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_STICKY,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_sticky,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_sticky,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_sticky);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_SIZE_HINTS_HONOR,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_size_hints_honor,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_size_hints_honor,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_size_hints_honor);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_BORDER_WIDTH,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_border_width,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_border_width,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_border_width);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_BORDER_COLOR,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_border_color,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_border_color,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_border_color);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_TITLEBAR,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_titlebar,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_titlebar,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_titlebar);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_URGENT,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_urgent,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_urgent,
|
|
|
|
(lua_class_propfunc_t) luaA_client_set_urgent);
|
|
|
|
luaA_class_add_property(&client_class, A_TK_SIZE_HINTS,
|
|
|
|
NULL,
|
|
|
|
(lua_class_propfunc_t) luaA_client_get_size_hints,
|
|
|
|
NULL);
|
|
|
|
}
|
2008-05-20 15:39:47 +02:00
|
|
|
|
2007-12-18 09:24:15 +01:00
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|