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"
|
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
|
|
|
DO_LUA_TOSTRING(client_t, client, "client")
|
|
|
|
|
|
|
|
client_t *
|
|
|
|
luaA_client_checkudata(lua_State *L, int ud)
|
|
|
|
{
|
|
|
|
client_t *c = luaL_checkudata(L, ud, "client");
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
client_t *c = luaL_checkudata(L, 1, "client");
|
2009-05-08 09:53:20 +02:00
|
|
|
luaA_ref_array_wipe(&c->refs);
|
2009-04-10 15:23:55 +02:00
|
|
|
button_array_wipe(&c->buttons);
|
2009-04-13 12:36:23 +02:00
|
|
|
image_unref(L, c->icon);
|
2009-04-10 15:23:55 +02:00
|
|
|
p_delete(&c->class);
|
2009-04-04 13:04:19 +02:00
|
|
|
p_delete(&c->startup_id);
|
2009-04-10 15:23:55 +02:00
|
|
|
p_delete(&c->instance);
|
|
|
|
p_delete(&c->icon_name);
|
|
|
|
p_delete(&c->name);
|
|
|
|
return 0;
|
|
|
|
}
|
2008-06-18 18:31:35 +02:00
|
|
|
|
2009-02-11 18:41:58 +01:00
|
|
|
/** Change the clients urgency flag.
|
|
|
|
* \param c The client
|
|
|
|
* \param urgent The new flag state
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
client_seturgent(client_t *c, bool urgent)
|
|
|
|
{
|
|
|
|
if(c->isurgent != urgent)
|
|
|
|
{
|
|
|
|
xcb_get_property_cookie_t hints =
|
|
|
|
xcb_get_wm_hints_unchecked(globalconf.connection, c->win);
|
|
|
|
|
|
|
|
c->isurgent = urgent;
|
|
|
|
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;
|
|
|
|
|
|
|
|
xcb_set_wm_hints(globalconf.connection, c->win, &wmh);
|
|
|
|
|
|
|
|
hooks_property(c, "urgent");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2008-08-11 11:57:57 +02:00
|
|
|
if(c->screen == screen)
|
2008-06-23 17:37:19 +02:00
|
|
|
{
|
2008-09-03 14:59:18 +02:00
|
|
|
if(c->issticky || 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)
|
|
|
|
if((*tag)->selected && 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-12-29 15:21:00 +01:00
|
|
|
/** Return the content of a client as an image.
|
|
|
|
* That's just take a screenshot.
|
|
|
|
* \param c The client.
|
2009-04-09 11:38:56 +02:00
|
|
|
* \return 1 if the image has been pushed on stack, false otherwise.
|
2008-12-29 15:21:00 +01:00
|
|
|
*/
|
2009-04-09 11:38:56 +02:00
|
|
|
static int
|
2008-12-29 15:21:00 +01:00
|
|
|
client_getcontent(client_t *c)
|
|
|
|
{
|
|
|
|
xcb_image_t *ximage = xcb_image_get(globalconf.connection,
|
|
|
|
c->win,
|
|
|
|
0, 0,
|
|
|
|
c->geometries.internal.width,
|
|
|
|
c->geometries.internal.height,
|
|
|
|
~0, XCB_IMAGE_FORMAT_Z_PIXMAP);
|
2009-04-09 11:38:56 +02:00
|
|
|
int retval = 0;
|
2008-12-29 15:21:00 +01:00
|
|
|
|
2009-04-09 11:38:56 +02:00
|
|
|
if(ximage)
|
|
|
|
{
|
|
|
|
if(ximage->bpp >= 24)
|
2008-12-29 15:21:00 +01:00
|
|
|
{
|
2009-04-09 11:38:56 +02:00
|
|
|
uint32_t *data = p_alloca(uint32_t, ximage->width * ximage->height);
|
2008-12-29 15:21:00 +01:00
|
|
|
|
2009-04-09 11:38:56 +02:00
|
|
|
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 */
|
|
|
|
}
|
2008-12-29 15:21:00 +01:00
|
|
|
|
2009-04-09 11:38:56 +02:00
|
|
|
retval = image_new_from_argb32(ximage->width, ximage->height, data);
|
|
|
|
}
|
|
|
|
xcb_image_destroy(ximage);
|
|
|
|
}
|
2008-12-29 15:21:00 +01:00
|
|
|
|
2009-04-09 11:38:56 +02:00
|
|
|
return retval;
|
2008-12-29 15:21:00 +01: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)
|
|
|
|
if((*c)->win == w)
|
|
|
|
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-04-10 15:23:55 +02:00
|
|
|
client_push(globalconf.L, c);
|
2009-02-11 18:32:27 +01:00
|
|
|
luaA_dofunction(globalconf.L, globalconf.hooks.unfocus, 1, 0);
|
|
|
|
}
|
2009-04-07 14:20:22 +02:00
|
|
|
|
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;
|
2008-11-20 22:11:13 +01:00
|
|
|
/* Set focus on root window, so no events leak to the current window. */
|
2009-04-07 14:20:22 +02:00
|
|
|
window_setfocus(root_win, true);
|
2009-04-28 10:54:10 +02:00
|
|
|
|
|
|
|
client_unfocus_update(c);
|
2008-01-25 12:55:44 +01: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)
|
|
|
|
{
|
|
|
|
/* Move all clients out of the physical viewport into negative coordinate space. */
|
|
|
|
/* They will all be put on top of each other. */
|
2008-12-12 00:01:43 +01:00
|
|
|
uint32_t request[2] = { - (c->geometries.internal.width + 2 * c->border),
|
|
|
|
- (c->geometries.internal.height + 2 * c->border) };
|
2008-11-20 22:11:13 +01:00
|
|
|
|
|
|
|
xcb_configure_window(globalconf.connection, c->win,
|
|
|
|
XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y,
|
|
|
|
request);
|
|
|
|
|
|
|
|
c->isbanned = true;
|
2008-12-06 23:41:33 +01:00
|
|
|
|
|
|
|
/* All the wiboxes (may) need to be repositioned. */
|
|
|
|
if(client_hasstrut(c))
|
|
|
|
wibox_update_positions();
|
2007-09-05 20:15:00 +02: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-04-07 14:20:22 +02:00
|
|
|
/** Record that a client got focus.
|
|
|
|
* \param c Client being focused.
|
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-04-07 14:20:22 +02:00
|
|
|
/* stop hiding client */
|
2008-08-11 11:51:54 +02:00
|
|
|
c->ishidden = false;
|
2008-09-18 13:51:10 +02:00
|
|
|
client_setminimized(c, 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
|
|
|
|
2008-08-11 11:51:54 +02:00
|
|
|
/* Some layouts use focused client differently, so call them back.
|
|
|
|
* And anyway, we have maybe unhidden */
|
2008-08-21 15:36:54 +02:00
|
|
|
client_need_arrange(c);
|
2008-08-11 11:51:54 +02:00
|
|
|
|
2009-02-11 18:41:58 +01:00
|
|
|
/* according to EWMH, we have to remove the urgent state from a client */
|
|
|
|
client_seturgent(c, false);
|
|
|
|
|
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-04-10 15:23:55 +02:00
|
|
|
client_push(globalconf.L, c);
|
2009-04-07 14:20:22 +02:00
|
|
|
luaA_dofunction(globalconf.L, globalconf.hooks.focus, 1, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Give focus to client, or to first client if client is NULL.
|
|
|
|
* \param c The client or NULL.
|
|
|
|
*/
|
|
|
|
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
|
|
|
|
|
|
|
window_setfocus(c->win, !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.
|
|
|
|
* \param return The next-previous!
|
|
|
|
*/
|
|
|
|
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
|
|
|
|
2008-11-18 10:39:42 +01:00
|
|
|
xcb_configure_window(globalconf.connection, c->win,
|
|
|
|
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
|
|
|
|
config_win_vals);
|
|
|
|
|
|
|
|
config_win_vals[0] = c->win;
|
|
|
|
|
2008-09-24 12:13:21 +02:00
|
|
|
if(c->titlebar)
|
2008-08-21 17:52:44 +02:00
|
|
|
{
|
|
|
|
xcb_configure_window(globalconf.connection,
|
2008-09-20 21:24:16 +02:00
|
|
|
c->titlebar->sw.window,
|
2008-08-21 17:52:44 +02:00
|
|
|
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
|
|
|
|
config_win_vals);
|
2008-11-18 10:39:42 +01:00
|
|
|
previous = c->titlebar->sw.window;
|
2008-08-21 17:52:44 +02:00
|
|
|
}
|
2008-11-18 10:39:42 +01:00
|
|
|
else
|
|
|
|
previous = c->win;
|
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 */
|
2008-08-21 17:52:44 +02:00
|
|
|
if(c->isontop)
|
|
|
|
return LAYER_ONTOP;
|
|
|
|
else if(c->isfullscreen)
|
|
|
|
return LAYER_FULLSCREEN;
|
|
|
|
else if(c->isabove)
|
|
|
|
return LAYER_ABOVE;
|
2008-11-17 09:56:34 +01:00
|
|
|
else if(c->isbelow)
|
|
|
|
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-04-10 18:15:48 +02:00
|
|
|
static void
|
|
|
|
client_real_stack(void)
|
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
|
|
|
|
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-04-17 16:14:09 +02:00
|
|
|
foreach(s, globalconf.screens)
|
|
|
|
foreach(_sb, s->wiboxes)
|
2008-09-20 16:45:43 +02:00
|
|
|
{
|
2009-04-11 00:27:06 +02:00
|
|
|
wibox_t *sb = *_sb;
|
2008-11-03 11:46:57 +01:00
|
|
|
if(!sb->ontop)
|
2008-09-22 19:23:28 +02:00
|
|
|
{
|
|
|
|
xcb_configure_window(globalconf.connection,
|
|
|
|
sb->sw.window,
|
|
|
|
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
|
|
|
|
config_win_vals);
|
|
|
|
config_win_vals[0] = sb->sw.window;
|
|
|
|
}
|
2008-09-20 16:45:43 +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-04-17 16:14:09 +02:00
|
|
|
foreach(s, globalconf.screens)
|
|
|
|
foreach(_sb, s->wiboxes)
|
2008-09-22 19:23:28 +02:00
|
|
|
{
|
2009-04-11 00:27:06 +02:00
|
|
|
wibox_t *sb = *_sb;
|
2008-11-03 11:46:57 +01:00
|
|
|
if(sb->ontop)
|
2008-09-22 19:23:28 +02:00
|
|
|
{
|
|
|
|
xcb_configure_window(globalconf.connection,
|
|
|
|
sb->sw.window,
|
|
|
|
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
|
|
|
|
config_win_vals);
|
|
|
|
config_win_vals[0] = sb->sw.window;
|
|
|
|
}
|
|
|
|
}
|
2008-06-27 22:49:54 +02:00
|
|
|
}
|
|
|
|
|
2009-04-10 18:15:48 +02:00
|
|
|
void
|
|
|
|
client_stack_refresh()
|
|
|
|
{
|
|
|
|
if (!globalconf.client_need_stack_refresh)
|
|
|
|
return;
|
|
|
|
globalconf.client_need_stack_refresh = false;
|
|
|
|
client_real_stack();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2008-08-13 02:02:19 +02:00
|
|
|
xcb_get_property_cookie_t ewmh_icon_cookie;
|
2009-02-03 12:20:17 +01:00
|
|
|
client_t *c, *tc = NULL;
|
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;
|
|
|
|
}
|
|
|
|
|
2008-12-07 11:05:21 +01:00
|
|
|
/* Send request to get NET_WM_ICON property as soon as possible... */
|
|
|
|
ewmh_icon_cookie = ewmh_window_icon_get_unchecked(w);
|
|
|
|
xcb_change_window_attributes(globalconf.connection, w, XCB_CW_EVENT_MASK, select_input_val);
|
2009-04-10 15:23:55 +02:00
|
|
|
|
|
|
|
c = client_new(globalconf.L);
|
|
|
|
/* Push client in client list */
|
|
|
|
client_array_push(&globalconf.clients, client_ref(globalconf.L));
|
|
|
|
|
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
|
|
|
|
2008-01-13 16:30:43 +01:00
|
|
|
/* Initial values */
|
2007-09-05 20:15:00 +02:00
|
|
|
c->win = 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;
|
2008-07-30 10:40:21 +02:00
|
|
|
client_setborder(c, wgeom->border_width);
|
2009-04-09 11:38:56 +02:00
|
|
|
|
|
|
|
if(ewmh_window_icon_get_reply(ewmh_icon_cookie))
|
|
|
|
c->icon = image_ref(globalconf.L);
|
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);
|
2008-09-16 18:07:42 +02:00
|
|
|
|
2008-12-04 15:16:38 +01:00
|
|
|
/* Recursively find the parent. */
|
|
|
|
for(tc = c; tc->transient_for; tc = tc->transient_for);
|
2009-02-03 12:20:17 +01:00
|
|
|
if(tc != c && tc->phys_screen == c->phys_screen)
|
2008-12-04 15:16:38 +01:00
|
|
|
screen = tc->screen;
|
2007-12-28 20:48:29 +01: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-02-03 12:20:17 +01:00
|
|
|
/* move client to screen, but do not tag it */
|
2008-11-05 10:24:23 +01:00
|
|
|
screen_client_moveto(c, screen, false, true);
|
|
|
|
|
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 */
|
2008-09-16 14:09:56 +02:00
|
|
|
property_update_wm_name(c);
|
2008-10-21 15:12:55 +02:00
|
|
|
property_update_wm_icon_name(c);
|
2009-04-18 14:20:06 +02:00
|
|
|
property_update_wm_class(c, NULL);
|
2008-06-05 09:25:38 +02:00
|
|
|
|
2009-04-04 13:04:19 +02:00
|
|
|
xutil_text_prop_get(globalconf.connection, c->win, _NET_STARTUP_ID, &c->startup_id, NULL);
|
|
|
|
|
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
|
|
|
|
* visibility events may continue to proces data (when banned).
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
window_state_set(c->win, XCB_WM_STATE_NORMAL);
|
|
|
|
|
|
|
|
/* Move window outside the viewport before mapping it. */
|
|
|
|
client_ban(c);
|
|
|
|
xcb_map_window(globalconf.connection, c->win);
|
|
|
|
|
2009-04-03 16:30:18 +02:00
|
|
|
if(!startup)
|
|
|
|
spawn_start_notify(c);
|
|
|
|
|
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)
|
|
|
|
luaA_dofunction(globalconf.L, globalconf.hooks.clients, 0, 0);
|
2008-10-20 15:01:16 +02:00
|
|
|
|
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-04-10 15:23:55 +02:00
|
|
|
client_push(globalconf.L, c);
|
2008-12-29 12:23:37 +01:00
|
|
|
lua_pushboolean(globalconf.L, startup);
|
|
|
|
luaA_dofunction(globalconf.L, globalconf.hooks.manage, 2, 0);
|
2008-11-20 17:48:23 +01:00
|
|
|
}
|
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-01-10 10:01:51 +01:00
|
|
|
* The sizse 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 */
|
|
|
|
area = display_area_get(c->phys_screen, NULL,
|
2009-04-17 16:14:09 +02:00
|
|
|
&c->screen->padding);
|
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. */
|
|
|
|
geometry_internal = titlebar_geometry_remove(c->titlebar, c->border, geometry);
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
/* Also let client hints propegate to the "official" geometry. */
|
|
|
|
geometry = titlebar_geometry_add(c->titlebar, c->border, geometry_internal);
|
|
|
|
|
|
|
|
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
|
|
|
|
2008-11-20 22:11:13 +01:00
|
|
|
/* The idea is to give a client a resize even when banned. */
|
|
|
|
/* We just have to move the (x,y) to keep it out of the viewport. */
|
|
|
|
/* This at least doesn't break expectations about events. */
|
2009-03-29 20:26:39 +02:00
|
|
|
if(c->isbanned)
|
2008-11-20 22:11:13 +01:00
|
|
|
{
|
2009-02-02 20:16:57 +01:00
|
|
|
geometry_internal.x = values[0] = - (geometry_internal.width + 2 * c->border);
|
|
|
|
geometry_internal.y = values[1] = - (geometry_internal.height + 2 * c->border);
|
2008-11-20 22:11:13 +01:00
|
|
|
}
|
|
|
|
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_configure_window(globalconf.connection, c->win,
|
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
|
|
|
|
2008-12-07 18:03:36 +01:00
|
|
|
screen_client_moveto(c, new_screen, true, false);
|
2008-03-26 11:03:52 +01:00
|
|
|
|
2008-09-24 12:13:21 +02:00
|
|
|
/* execute hook */
|
|
|
|
hooks_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
|
|
|
}
|
|
|
|
|
2009-03-30 19:40:01 +02:00
|
|
|
/** Update the position of all window with struts on a specific screen.
|
|
|
|
* \param screen The screen that should be processed.
|
|
|
|
*/
|
|
|
|
void
|
2009-04-17 16:14:09 +02:00
|
|
|
client_update_strut_positions(screen_t *screen)
|
2009-03-30 19:40:01 +02:00
|
|
|
{
|
|
|
|
area_t allowed_area, geom;
|
|
|
|
|
|
|
|
/* Ignore all struts for starters. */
|
2009-04-09 17:17:10 +02:00
|
|
|
foreach(_c, globalconf.clients)
|
|
|
|
{
|
|
|
|
client_t *c = *_c;
|
2009-03-30 19:40:01 +02:00
|
|
|
if(c->screen == screen && client_hasstrut(c))
|
|
|
|
c->ignore_strut = true;
|
2009-04-09 17:17:10 +02:00
|
|
|
}
|
2009-03-30 19:40:01 +02:00
|
|
|
|
|
|
|
/* Rationale:
|
|
|
|
* Top and bottom panels are common, so they take precendence.
|
|
|
|
* WINDOW_TYPE_DOCK really wants to be at the side, so choose them first.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* WINDOW_TYPE_DOCK: top + bottom. */
|
2009-04-09 17:17:10 +02:00
|
|
|
foreach(_c, globalconf.clients)
|
2009-03-30 19:40:01 +02:00
|
|
|
{
|
2009-04-09 17:17:10 +02:00
|
|
|
client_t *c = *_c;
|
2009-03-30 19:40:01 +02:00
|
|
|
if(c->screen != screen || !client_hasstrut(c) || c->type != WINDOW_TYPE_DOCK)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Screen area, minus padding, wibox'es and already processed struts. */
|
|
|
|
allowed_area = screen_area_get(c->screen,
|
2009-04-17 16:14:09 +02:00
|
|
|
&c->screen->wiboxes,
|
|
|
|
&c->screen->padding,
|
2009-03-30 19:40:01 +02:00
|
|
|
true);
|
|
|
|
|
|
|
|
geom = c->geometry;
|
|
|
|
|
|
|
|
if(c->strut.top || c->strut.top_start_x || c->strut.top_end_x)
|
|
|
|
{
|
|
|
|
geom.y = allowed_area.y;
|
|
|
|
if(geom.x < allowed_area.x
|
|
|
|
|| geom.x + geom.width > allowed_area.x + allowed_area.width)
|
|
|
|
{
|
|
|
|
geom.x = allowed_area.x;
|
|
|
|
if(geom.width > allowed_area.width)
|
|
|
|
geom.width = allowed_area.width;
|
|
|
|
}
|
|
|
|
c->ignore_strut = false;
|
|
|
|
client_resize(c, geom, false);
|
|
|
|
}
|
|
|
|
else if(c->strut.bottom || c->strut.bottom_start_x || c->strut.bottom_end_x)
|
|
|
|
{
|
|
|
|
geom.y = allowed_area.y + allowed_area.height - geom.height;
|
|
|
|
if(geom.x < allowed_area.x
|
|
|
|
|| geom.x + geom.width > allowed_area.x + allowed_area.width)
|
|
|
|
{
|
|
|
|
geom.x = allowed_area.x;
|
|
|
|
if(geom.width > allowed_area.width)
|
|
|
|
geom.width = allowed_area.width;
|
|
|
|
}
|
|
|
|
c->ignore_strut = false;
|
|
|
|
client_resize(c, geom, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* WINDOW_TYPE_DOCK: left + right. */
|
2009-04-09 17:17:10 +02:00
|
|
|
foreach(_c, globalconf.clients)
|
2009-03-30 19:40:01 +02:00
|
|
|
{
|
2009-04-09 17:17:10 +02:00
|
|
|
client_t *c = *_c;
|
2009-03-30 19:40:01 +02:00
|
|
|
if(c->screen != screen || !client_hasstrut(c) || c->type != WINDOW_TYPE_DOCK)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Screen area, minus padding, wibox'es and already processed struts. */
|
|
|
|
allowed_area = screen_area_get(c->screen,
|
2009-04-17 16:14:09 +02:00
|
|
|
&c->screen->wiboxes,
|
|
|
|
&c->screen->padding,
|
2009-03-30 19:40:01 +02:00
|
|
|
true);
|
|
|
|
|
|
|
|
geom = c->geometry;
|
|
|
|
|
|
|
|
if(c->strut.left || c->strut.left_start_y || c->strut.left_end_y)
|
|
|
|
{
|
|
|
|
geom.x = allowed_area.x;
|
|
|
|
if(geom.y < allowed_area.y
|
|
|
|
|| geom.y + geom.height > allowed_area.y + allowed_area.height)
|
|
|
|
{
|
|
|
|
geom.y = allowed_area.y;
|
|
|
|
if (geom.height > allowed_area.height)
|
|
|
|
geom.height = allowed_area.height;
|
|
|
|
}
|
|
|
|
c->ignore_strut = false;
|
|
|
|
client_resize(c, geom, false);
|
|
|
|
}
|
|
|
|
else if(c->strut.right || c->strut.right_start_y || c->strut.right_end_y)
|
|
|
|
{
|
|
|
|
geom.x = allowed_area.x + allowed_area.width - geom.width;
|
|
|
|
if(geom.y < allowed_area.y
|
|
|
|
|| geom.y + geom.height > allowed_area.y + allowed_area.height)
|
|
|
|
{
|
|
|
|
geom.y = allowed_area.y;
|
|
|
|
if (geom.height > allowed_area.height)
|
|
|
|
geom.height = allowed_area.height;
|
|
|
|
}
|
|
|
|
c->ignore_strut = false;
|
|
|
|
client_resize(c, geom, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* not WINDOW_TYPE_DOCK: top + bottom. */
|
2009-04-09 17:17:10 +02:00
|
|
|
foreach(_c, globalconf.clients)
|
2009-03-30 19:40:01 +02:00
|
|
|
{
|
2009-04-09 17:17:10 +02:00
|
|
|
client_t *c = *_c;
|
2009-03-30 19:40:01 +02:00
|
|
|
if(c->screen != screen || !client_hasstrut(c) || c->type == WINDOW_TYPE_DOCK)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Screen area, minus padding, wibox'es and already processed struts. */
|
|
|
|
allowed_area = screen_area_get(c->screen,
|
2009-04-17 16:14:09 +02:00
|
|
|
&c->screen->wiboxes,
|
|
|
|
&c->screen->padding,
|
2009-03-30 19:40:01 +02:00
|
|
|
true);
|
|
|
|
|
|
|
|
geom = c->geometry;
|
|
|
|
|
|
|
|
if(c->strut.top || c->strut.top_start_x || c->strut.top_end_x)
|
|
|
|
{
|
|
|
|
geom.y = allowed_area.y;
|
|
|
|
if(geom.x < allowed_area.x
|
|
|
|
|| geom.x + geom.width > allowed_area.x + allowed_area.width)
|
|
|
|
{
|
|
|
|
geom.x = allowed_area.x;
|
|
|
|
if(geom.width > allowed_area.width)
|
|
|
|
geom.width = allowed_area.width;
|
|
|
|
}
|
|
|
|
c->ignore_strut = false;
|
|
|
|
client_resize(c, geom, false);
|
|
|
|
}
|
|
|
|
else if(c->strut.bottom || c->strut.bottom_start_x || c->strut.bottom_end_x)
|
|
|
|
{
|
|
|
|
geom.y = allowed_area.y + allowed_area.height - geom.height;
|
|
|
|
if(geom.x < allowed_area.x
|
|
|
|
|| geom.x + geom.width > allowed_area.x + allowed_area.width)
|
|
|
|
{
|
|
|
|
geom.x = allowed_area.x;
|
|
|
|
if(geom.width > allowed_area.width)
|
|
|
|
geom.width = allowed_area.width;
|
|
|
|
}
|
|
|
|
c->ignore_strut = false;
|
|
|
|
client_resize(c, geom, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* not WINDOW_TYPE_DOCK: left + right. */
|
2009-04-09 17:17:10 +02:00
|
|
|
foreach(_c, globalconf.clients)
|
2009-03-30 19:40:01 +02:00
|
|
|
{
|
2009-04-09 17:17:10 +02:00
|
|
|
client_t *c = *_c;
|
2009-03-30 19:40:01 +02:00
|
|
|
if(c->screen != screen || !client_hasstrut(c) || c->type == WINDOW_TYPE_DOCK)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Screen area, minus padding, wibox'es and already processed struts. */
|
|
|
|
allowed_area = screen_area_get(c->screen,
|
2009-04-17 16:14:09 +02:00
|
|
|
&c->screen->wiboxes,
|
|
|
|
&c->screen->padding,
|
2009-03-30 19:40:01 +02:00
|
|
|
true);
|
|
|
|
|
|
|
|
geom = c->geometry;
|
|
|
|
|
|
|
|
if(c->strut.left || c->strut.left_start_y || c->strut.left_end_y)
|
|
|
|
{
|
|
|
|
geom.x = allowed_area.x;
|
|
|
|
if(geom.y < allowed_area.y
|
|
|
|
|| geom.y + geom.height > allowed_area.y + allowed_area.height)
|
|
|
|
{
|
|
|
|
geom.y = allowed_area.y;
|
|
|
|
if (geom.height > allowed_area.height)
|
|
|
|
geom.height = allowed_area.height;
|
|
|
|
}
|
|
|
|
c->ignore_strut = false;
|
|
|
|
client_resize(c, geom, false);
|
|
|
|
}
|
|
|
|
else if(c->strut.right || c->strut.right_start_y || c->strut.right_end_y)
|
|
|
|
{
|
|
|
|
geom.x = allowed_area.x + allowed_area.width - geom.width;
|
|
|
|
if(geom.y < allowed_area.y
|
|
|
|
|| geom.y + geom.height > allowed_area.y + allowed_area.height)
|
|
|
|
{
|
|
|
|
geom.y = allowed_area.y;
|
|
|
|
if (geom.height > allowed_area.height)
|
|
|
|
geom.height = allowed_area.height;
|
|
|
|
}
|
|
|
|
c->ignore_strut = false;
|
|
|
|
client_resize(c, geom, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-09-18 13:51:10 +02:00
|
|
|
/** Set a client minimized, or not.
|
|
|
|
* \param c The client.
|
|
|
|
* \param s Set or not the client minimized.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
client_setminimized(client_t *c, bool s)
|
|
|
|
{
|
|
|
|
if(c->isminimized != s)
|
|
|
|
{
|
2009-02-17 02:53:41 +01:00
|
|
|
client_need_arrange(c);
|
2008-09-18 13:51:10 +02:00
|
|
|
c->isminimized = s;
|
|
|
|
client_need_arrange(c);
|
|
|
|
ewmh_client_update_hints(c);
|
2008-09-22 17:54:48 +02:00
|
|
|
/* execute hook */
|
|
|
|
hooks_property(c, "minimized");
|
2008-09-18 13:51:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-21 16:29:53 +02:00
|
|
|
/** Set a client sticky, or not.
|
|
|
|
* \param c The client.
|
|
|
|
* \param s Set or not the client sticky.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
client_setsticky(client_t *c, bool s)
|
|
|
|
{
|
|
|
|
if(c->issticky != s)
|
|
|
|
{
|
2009-02-17 02:53:41 +01:00
|
|
|
client_need_arrange(c);
|
2008-08-21 16:29:53 +02:00
|
|
|
c->issticky = s;
|
|
|
|
client_need_arrange(c);
|
2008-09-18 13:51:10 +02:00
|
|
|
ewmh_client_update_hints(c);
|
2008-09-22 17:54:48 +02:00
|
|
|
hooks_property(c, "sticky");
|
2008-08-21 16:29:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-21 17:52:44 +02:00
|
|
|
/** Set a client fullscreen, or not.
|
|
|
|
* \param c The client.
|
|
|
|
* \param s Set or not the client fullscreen.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
client_setfullscreen(client_t *c, bool s)
|
|
|
|
{
|
|
|
|
if(c->isfullscreen != s)
|
|
|
|
{
|
|
|
|
area_t geometry;
|
|
|
|
|
2009-03-26 22:13:42 +01:00
|
|
|
/* Make sure the current geometry is stored without titlebar. */
|
2009-03-29 20:26:39 +02:00
|
|
|
if(s)
|
2009-03-26 22:13:42 +01:00
|
|
|
titlebar_ban(c->titlebar);
|
|
|
|
|
2008-08-21 17:52:44 +02:00
|
|
|
/* become fullscreen! */
|
|
|
|
if((c->isfullscreen = s))
|
|
|
|
{
|
2008-11-25 11:54:38 +01:00
|
|
|
/* remove any max state */
|
|
|
|
client_setmaxhoriz(c, false);
|
|
|
|
client_setmaxvert(c, false);
|
2009-02-08 23:55:30 +01:00
|
|
|
/* You can only be part of one of the special layers. */
|
|
|
|
client_setbelow(c, false);
|
|
|
|
client_setabove(c, false);
|
|
|
|
client_setontop(c, false);
|
2008-11-25 11:54:38 +01:00
|
|
|
|
2008-11-03 19:48:33 +01:00
|
|
|
geometry = screen_area_get(c->screen, NULL, NULL, false);
|
2008-11-25 11:24:25 +01:00
|
|
|
c->geometries.fullscreen = c->geometry;
|
2008-12-09 11:18:16 +01:00
|
|
|
c->border_fs = c->border;
|
2008-08-21 17:52:44 +02:00
|
|
|
client_setborder(c, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-11-25 11:24:25 +01:00
|
|
|
geometry = c->geometries.fullscreen;
|
2008-12-09 11:18:16 +01:00
|
|
|
client_setborder(c, c->border_fs);
|
2008-08-21 17:52:44 +02:00
|
|
|
}
|
|
|
|
client_resize(c, geometry, false);
|
|
|
|
client_need_arrange(c);
|
|
|
|
client_stack();
|
2008-09-18 13:51:10 +02:00
|
|
|
ewmh_client_update_hints(c);
|
2008-09-22 17:54:48 +02:00
|
|
|
hooks_property(c, "fullscreen");
|
2008-08-21 17:52:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-25 11:54:38 +01:00
|
|
|
/** Set a client horizontally maximized.
|
|
|
|
* \param c The client.
|
|
|
|
* \param s The maximized status.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
client_setmaxhoriz(client_t *c, bool s)
|
|
|
|
{
|
|
|
|
if(c->ismaxhoriz != s)
|
|
|
|
{
|
|
|
|
area_t geometry;
|
|
|
|
|
|
|
|
if((c->ismaxhoriz = s))
|
|
|
|
{
|
|
|
|
/* remove fullscreen mode */
|
|
|
|
client_setfullscreen(c, false);
|
|
|
|
|
|
|
|
geometry = screen_area_get(c->screen,
|
2009-04-17 16:14:09 +02:00
|
|
|
&c->screen->wiboxes,
|
|
|
|
&c->screen->padding,
|
2008-11-25 11:54:38 +01:00
|
|
|
true);
|
|
|
|
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_need_arrange(c);
|
|
|
|
client_stack();
|
|
|
|
ewmh_client_update_hints(c);
|
|
|
|
hooks_property(c, "maximized_horizontal");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set a client vertically maximized.
|
|
|
|
* \param c The client.
|
|
|
|
* \param s The maximized status.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
client_setmaxvert(client_t *c, bool s)
|
|
|
|
{
|
|
|
|
if(c->ismaxvert != s)
|
|
|
|
{
|
|
|
|
area_t geometry;
|
|
|
|
|
|
|
|
if((c->ismaxvert = s))
|
|
|
|
{
|
|
|
|
/* remove fullscreen mode */
|
|
|
|
client_setfullscreen(c, false);
|
|
|
|
|
|
|
|
geometry = screen_area_get(c->screen,
|
2009-04-17 16:14:09 +02:00
|
|
|
&c->screen->wiboxes,
|
|
|
|
&c->screen->padding,
|
2008-11-25 11:54:38 +01:00
|
|
|
true);
|
|
|
|
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_need_arrange(c);
|
|
|
|
client_stack();
|
|
|
|
ewmh_client_update_hints(c);
|
|
|
|
hooks_property(c, "maximized_vertical");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-21 17:52:44 +02:00
|
|
|
/** Set a client above, or not.
|
|
|
|
* \param c The client.
|
|
|
|
* \param s Set or not the client above.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
client_setabove(client_t *c, bool s)
|
|
|
|
{
|
|
|
|
if(c->isabove != s)
|
|
|
|
{
|
2009-02-08 23:55:30 +01:00
|
|
|
/* You can only be part of one of the special layers. */
|
|
|
|
if(s)
|
|
|
|
{
|
|
|
|
client_setbelow(c, false);
|
|
|
|
client_setontop(c, false);
|
|
|
|
client_setfullscreen(c, false);
|
|
|
|
}
|
2008-08-21 17:52:44 +02:00
|
|
|
c->isabove = s;
|
|
|
|
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 */
|
|
|
|
hooks_property(c, "above");
|
2008-08-21 17:52:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set a client below, or not.
|
|
|
|
* \param c The client.
|
|
|
|
* \param s Set or not the client below.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
client_setbelow(client_t *c, bool s)
|
|
|
|
{
|
|
|
|
if(c->isbelow != s)
|
|
|
|
{
|
2009-02-08 23:55:30 +01:00
|
|
|
/* You can only be part of one of the special layers. */
|
|
|
|
if(s)
|
|
|
|
{
|
|
|
|
client_setabove(c, false);
|
|
|
|
client_setontop(c, false);
|
|
|
|
client_setfullscreen(c, false);
|
|
|
|
}
|
2008-08-21 17:52:44 +02:00
|
|
|
c->isbelow = s;
|
|
|
|
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 */
|
|
|
|
hooks_property(c, "below");
|
2008-08-21 17:52:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set a client modal, or not.
|
|
|
|
* \param c The client.
|
|
|
|
* \param s Set or not the client moda.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
client_setmodal(client_t *c, bool s)
|
|
|
|
{
|
|
|
|
if(c->ismodal != s)
|
|
|
|
{
|
|
|
|
c->ismodal = s;
|
|
|
|
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 */
|
|
|
|
hooks_property(c, "modal");
|
2008-08-21 17:52:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set a client ontop, or not.
|
|
|
|
* \param c The client.
|
|
|
|
* \param s Set or not the client moda.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
client_setontop(client_t *c, bool s)
|
|
|
|
{
|
|
|
|
if(c->isontop != s)
|
|
|
|
{
|
2009-02-08 23:55:30 +01:00
|
|
|
/* You can only be part of one of the special layers. */
|
|
|
|
if(s)
|
|
|
|
{
|
|
|
|
client_setabove(c, false);
|
|
|
|
client_setbelow(c, false);
|
|
|
|
client_setfullscreen(c, false);
|
|
|
|
}
|
2008-08-21 17:52:44 +02:00
|
|
|
c->isontop = s;
|
|
|
|
client_stack();
|
2008-09-22 17:54:48 +02:00
|
|
|
/* execute hook */
|
|
|
|
hooks_property(c, "ontop");
|
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
|
|
|
{
|
2008-11-20 22:11:13 +01:00
|
|
|
/* Move the client back where it belongs. */
|
2009-01-30 15:07:49 +01:00
|
|
|
uint32_t request[] = { c->geometries.internal.x,
|
|
|
|
c->geometries.internal.y,
|
|
|
|
c->geometries.internal.width,
|
|
|
|
c->geometries.internal.height };
|
2008-11-20 22:11:13 +01:00
|
|
|
|
|
|
|
xcb_configure_window(globalconf.connection, c->win,
|
2009-01-30 15:07:49 +01:00
|
|
|
XCB_CONFIG_WINDOW_X
|
|
|
|
| XCB_CONFIG_WINDOW_Y
|
|
|
|
| XCB_CONFIG_WINDOW_WIDTH
|
|
|
|
| XCB_CONFIG_WINDOW_HEIGHT,
|
2008-11-20 22:11:13 +01:00
|
|
|
request);
|
|
|
|
|
|
|
|
c->isbanned = false;
|
2008-12-06 23:41:33 +01:00
|
|
|
|
|
|
|
/* All the wiboxes (may) need to be repositioned. */
|
|
|
|
if(client_hasstrut(c))
|
|
|
|
wibox_update_positions();
|
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-02-08 14:00:30 +01:00
|
|
|
/* Reset transient_for attributes of widows that maybe refering 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-04-10 15:23:55 +02:00
|
|
|
client_push(globalconf.L, c);
|
2008-11-20 17:48:23 +01:00
|
|
|
luaA_dofunction(globalconf.L, globalconf.hooks.unmanage, 1, 0);
|
|
|
|
}
|
2008-06-10 19:03:10 +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)
|
|
|
|
luaA_dofunction(globalconf.L, globalconf.hooks.clients, 0, 0);
|
2008-10-20 15:01:16 +02:00
|
|
|
|
2007-09-05 20:15:00 +02:00
|
|
|
/* The server grab construct avoids race conditions. */
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_grab_server(globalconf.connection);
|
2008-01-06 21:57:53 +01:00
|
|
|
|
2008-08-11 13:27:28 +02:00
|
|
|
xcb_ungrab_button(globalconf.connection, XCB_BUTTON_INDEX_ANY, c->win,
|
2008-08-19 10:59:40 +02:00
|
|
|
XCB_BUTTON_MASK_ANY);
|
2008-09-09 16:14:36 +02:00
|
|
|
window_state_set(c->win, XCB_WM_STATE_WITHDRAWN);
|
2008-01-06 21:57:53 +01:00
|
|
|
|
2008-08-26 19:39:12 +02:00
|
|
|
xcb_flush(globalconf.connection);
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_ungrab_server(globalconf.connection);
|
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-12-06 23:41:33 +01:00
|
|
|
/* All the wiboxes (may) need to be repositioned. */
|
2008-09-03 22:15:14 +02:00
|
|
|
if(client_hasstrut(c))
|
2008-12-06 23:41:33 +01:00
|
|
|
wibox_update_positions();
|
2008-09-03 22:15:14 +02:00
|
|
|
|
2008-07-31 17:29:05 +02:00
|
|
|
/* set client as invalid */
|
|
|
|
c->invalid = true;
|
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
client_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
|
|
|
{
|
2008-10-11 09:38:48 +02:00
|
|
|
if(window_hasproto(c->win, 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;
|
2008-03-21 16:50:17 +01:00
|
|
|
ev.window = c->win;
|
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
|
|
|
|
|
|
|
xcb_send_event(globalconf.connection, false, c->win,
|
|
|
|
XCB_EVENT_MASK_NO_EVENT, (char *) &ev);
|
2007-10-01 20:42:59 +02:00
|
|
|
}
|
|
|
|
else
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_kill_client(globalconf.connection, c->win);
|
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
|
2008-09-18 15:11:18 +02:00
|
|
|
* \lparam An optional screen nunmber.
|
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-04-10 15:23:55 +02:00
|
|
|
client_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-04-10 15:23:55 +02:00
|
|
|
client_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.
|
2008-06-05 09:25:38 +02:00
|
|
|
* \param c The client.
|
|
|
|
* \param width The border width.
|
2008-05-28 14:33:45 +02:00
|
|
|
*/
|
|
|
|
void
|
2008-06-11 08:12:38 +02:00
|
|
|
client_setborder(client_t *c, int width)
|
2008-05-28 14:33:45 +02:00
|
|
|
{
|
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
|
|
|
|
|| c->isfullscreen))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if(width == c->border || width < 0)
|
2008-05-28 14:33:45 +02:00
|
|
|
return;
|
|
|
|
|
2009-02-08 13:48:16 +01:00
|
|
|
/* Update geometry with the new border. */
|
2009-02-19 19:16:59 +01:00
|
|
|
c->geometry.width -= 2 * c->border;
|
|
|
|
c->geometry.height -= 2 * c->border;
|
2009-02-08 13:48:16 +01:00
|
|
|
|
2008-05-28 14:33:45 +02:00
|
|
|
c->border = width;
|
|
|
|
xcb_configure_window(globalconf.connection, c->win,
|
2008-06-11 08:12:38 +02:00
|
|
|
XCB_CONFIG_WINDOW_BORDER_WIDTH, &w);
|
2008-07-30 10:04:03 +02:00
|
|
|
|
2009-02-19 19:16:59 +01:00
|
|
|
c->geometry.width += 2 * c->border;
|
|
|
|
c->geometry.height += 2 * c->border;
|
2009-02-08 13:48:16 +01:00
|
|
|
/* Tiled clients will be resized by the layout functions. */
|
2008-11-25 17:01:06 +01:00
|
|
|
client_need_arrange(c);
|
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
|
|
|
|
2008-09-22 17:54:48 +02:00
|
|
|
hooks_property(c, "border_width");
|
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;
|
|
|
|
|
|
|
|
client_need_arrange(c);
|
|
|
|
client_need_arrange(swap);
|
2008-11-14 10:36:15 +01:00
|
|
|
|
|
|
|
/* Call hook to notify list change */
|
|
|
|
if(globalconf.hooks.clients != LUA_REFNIL)
|
|
|
|
luaA_dofunction(L, globalconf.hooks.clients, 0, 0);
|
|
|
|
}
|
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-04-11 11:45:55 +02:00
|
|
|
tag_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);
|
|
|
|
client_lower(c);
|
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-04-10 15:23:55 +02:00
|
|
|
xcb_unmap_window(globalconf.connection, c->win);
|
|
|
|
xcb_map_window(globalconf.connection, c->win);
|
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
|
|
|
/** Push a strut type to a table on stack.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param struts The struts to push.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
*/
|
|
|
|
static inline int
|
|
|
|
luaA_pushstruts(lua_State *L, strut_t struts)
|
|
|
|
{
|
2009-04-25 15:04:27 +02:00
|
|
|
lua_createtable(L, 4, 0);
|
2009-02-07 19:40:07 +01:00
|
|
|
lua_pushnumber(L, struts.left);
|
|
|
|
lua_setfield(L, -2, "left");
|
|
|
|
lua_pushnumber(L, struts.right);
|
|
|
|
lua_setfield(L, -2, "right");
|
|
|
|
lua_pushnumber(L, struts.top);
|
|
|
|
lua_setfield(L, -2, "top");
|
|
|
|
lua_pushnumber(L, struts.bottom);
|
|
|
|
lua_setfield(L, -2, "bottom");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 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)
|
|
|
|
{
|
|
|
|
strut_t struts;
|
2009-04-10 15:23:55 +02:00
|
|
|
area_t screen_area = display_area_get(c->phys_screen, NULL, NULL);
|
2009-02-07 19:40:07 +01:00
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
struts.left = luaA_getopt_number(L, 2, "left", c->strut.left);
|
|
|
|
struts.right = luaA_getopt_number(L, 2, "right", c->strut.right);
|
|
|
|
struts.top = luaA_getopt_number(L, 2, "top", c->strut.top);
|
|
|
|
struts.bottom = luaA_getopt_number(L, 2, "bottom", c->strut.bottom);
|
2009-02-07 19:40:07 +01:00
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
if(struts.left != c->strut.left || struts.right != c->strut.right ||
|
|
|
|
struts.top != c->strut.top || struts.bottom != c->strut.bottom) {
|
2009-02-07 19:40:07 +01:00
|
|
|
/* Struts are not so well defined in the context of xinerama. So we just
|
|
|
|
* give the entire root window and let the window manager decide. */
|
|
|
|
struts.left_start_y = 0;
|
|
|
|
struts.left_end_y = !struts.left ? 0 : screen_area.height;
|
|
|
|
struts.right_start_y = 0;
|
|
|
|
struts.right_end_y = !struts.right ? 0 : screen_area.height;
|
|
|
|
struts.top_start_x = 0;
|
|
|
|
struts.top_end_x = !struts.top ? 0 : screen_area.width;
|
|
|
|
struts.bottom_start_x = 0;
|
|
|
|
struts.bottom_end_x = !struts.bottom ? 0 : screen_area.width;
|
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
c->strut = struts;
|
2009-02-07 19:40:07 +01:00
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
ewmh_update_client_strut(c);
|
2009-02-07 19:40:07 +01:00
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
client_need_arrange(c);
|
2009-02-07 19:40:07 +01:00
|
|
|
/* All the wiboxes (may) need to be repositioned. */
|
|
|
|
wibox_update_positions();
|
2009-03-26 22:13:46 +01:00
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
hooks_property(c, "struts");
|
2009-02-07 19:40:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
return luaA_pushstruts(L, c->strut);
|
2009-02-07 19:40:07 +01:00
|
|
|
}
|
|
|
|
|
2008-07-01 19:37:10 +02:00
|
|
|
/** Client newindex.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
*/
|
2009-04-10 15:23:55 +02:00
|
|
|
static int
|
2008-07-01 19:37:10 +02:00
|
|
|
luaA_client_newindex(lua_State *L)
|
|
|
|
{
|
|
|
|
size_t len;
|
2009-04-10 15:23:55 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, 1);
|
2008-07-01 19:37:10 +02:00
|
|
|
const char *buf = luaL_checklstring(L, 2, &len);
|
2008-07-01 19:43:23 +02:00
|
|
|
bool b;
|
2008-07-01 19:52:25 +02:00
|
|
|
double d;
|
2008-07-01 21:39:00 +02:00
|
|
|
int i;
|
2008-07-01 19:37:10 +02:00
|
|
|
|
|
|
|
switch(a_tokenize(buf, len))
|
|
|
|
{
|
2008-07-01 21:39:00 +02:00
|
|
|
case A_TK_SCREEN:
|
2008-09-18 16:03:05 +02:00
|
|
|
if(globalconf.xinerama_is_active)
|
2008-08-10 10:32:59 +02:00
|
|
|
{
|
|
|
|
i = luaL_checknumber(L, 3) - 1;
|
|
|
|
luaA_checkscreen(i);
|
2009-04-17 16:14:09 +02:00
|
|
|
screen_client_moveto(c, &globalconf.screens.tab[i], true, true);
|
2008-08-10 10:32:59 +02:00
|
|
|
}
|
2008-07-01 21:39:00 +02:00
|
|
|
break;
|
2008-07-01 19:43:23 +02:00
|
|
|
case A_TK_HIDE:
|
|
|
|
b = luaA_checkboolean(L, 3);
|
2009-04-10 15:23:55 +02:00
|
|
|
if(b != c->ishidden)
|
2008-07-01 19:43:23 +02:00
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
client_need_arrange(c);
|
|
|
|
c->ishidden = b;
|
|
|
|
client_need_arrange(c);
|
2008-07-01 19:43:23 +02:00
|
|
|
}
|
2008-07-01 19:37:10 +02:00
|
|
|
break;
|
2008-11-25 11:55:56 +01:00
|
|
|
case A_TK_MINIMIZED:
|
2009-04-10 15:23:55 +02:00
|
|
|
client_setminimized(c, luaA_checkboolean(L, 3));
|
2008-09-06 13:52:05 +02:00
|
|
|
break;
|
2008-08-21 17:58:08 +02:00
|
|
|
case A_TK_FULLSCREEN:
|
2009-04-10 15:23:55 +02:00
|
|
|
client_setfullscreen(c, luaA_checkboolean(L, 3));
|
2008-08-21 17:58:08 +02:00
|
|
|
break;
|
2008-11-25 11:54:38 +01:00
|
|
|
case A_TK_MAXIMIZED_HORIZONTAL:
|
2009-04-10 15:23:55 +02:00
|
|
|
client_setmaxhoriz(c, luaA_checkboolean(L, 3));
|
2008-11-25 11:54:38 +01:00
|
|
|
break;
|
|
|
|
case A_TK_MAXIMIZED_VERTICAL:
|
2009-04-10 15:23:55 +02:00
|
|
|
client_setmaxvert(c, luaA_checkboolean(L, 3));
|
2008-11-25 11:54:38 +01:00
|
|
|
break;
|
2008-09-11 15:26:56 +02:00
|
|
|
case A_TK_ICON:
|
2009-04-10 15:23:55 +02:00
|
|
|
image_unref(L, c->icon);
|
|
|
|
c->icon = image_ref(L);
|
2008-10-19 19:14:55 +02:00
|
|
|
/* execute hook */
|
2009-04-10 15:23:55 +02:00
|
|
|
hooks_property(c, "icon");
|
2008-07-01 19:37:10 +02:00
|
|
|
break;
|
2008-07-01 19:52:25 +02:00
|
|
|
case A_TK_OPACITY:
|
2008-08-15 02:00:58 +02:00
|
|
|
if(lua_isnil(L, 3))
|
2009-04-10 15:23:55 +02:00
|
|
|
window_opacity_set(c->win, -1);
|
2008-08-15 02:00:58 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
d = luaL_checknumber(L, 3);
|
|
|
|
if(d >= 0 && d <= 1)
|
2009-04-10 15:23:55 +02:00
|
|
|
window_opacity_set(c->win, d);
|
2008-08-15 02:00:58 +02:00
|
|
|
}
|
2008-07-01 19:52:25 +02:00
|
|
|
break;
|
2008-08-21 16:29:53 +02:00
|
|
|
case A_TK_STICKY:
|
2009-04-10 15:23:55 +02:00
|
|
|
client_setsticky(c, luaA_checkboolean(L, 3));
|
2008-08-21 16:29:53 +02:00
|
|
|
break;
|
2009-01-11 15:48:14 +01:00
|
|
|
case A_TK_SIZE_HINTS_HONOR:
|
2009-04-10 15:23:55 +02:00
|
|
|
c->size_hints_honor = luaA_checkboolean(L, 3);
|
2009-04-17 11:43:56 +02:00
|
|
|
hooks_property(c, "size_hints_honor");
|
2008-07-01 19:59:36 +02:00
|
|
|
break;
|
2008-07-01 20:07:21 +02:00
|
|
|
case A_TK_BORDER_WIDTH:
|
2009-04-10 15:23:55 +02:00
|
|
|
client_setborder(c, luaL_checknumber(L, 3));
|
2008-07-01 20:07:21 +02:00
|
|
|
break;
|
2008-08-21 17:52:44 +02:00
|
|
|
case A_TK_ONTOP:
|
2009-04-10 15:23:55 +02:00
|
|
|
client_setontop(c, luaA_checkboolean(L, 3));
|
2008-08-21 17:52:44 +02:00
|
|
|
break;
|
2009-02-08 23:55:30 +01:00
|
|
|
case A_TK_ABOVE:
|
2009-04-10 15:23:55 +02:00
|
|
|
client_setabove(c, luaA_checkboolean(L, 3));
|
2009-02-08 23:55:30 +01:00
|
|
|
break;
|
|
|
|
case A_TK_BELOW:
|
2009-04-10 15:23:55 +02:00
|
|
|
client_setbelow(c, luaA_checkboolean(L, 3));
|
2009-02-08 23:55:30 +01:00
|
|
|
break;
|
2009-03-20 08:04:31 +01:00
|
|
|
case A_TK_URGENT:
|
2009-04-10 15:23:55 +02:00
|
|
|
client_seturgent(c, luaA_checkboolean(L, 3));
|
2009-03-20 08:04:31 +01:00
|
|
|
break;
|
2008-07-01 20:07:21 +02:00
|
|
|
case A_TK_BORDER_COLOR:
|
2008-07-10 15:30:16 +02:00
|
|
|
if((buf = luaL_checklstring(L, 3, &len))
|
2009-04-10 15:23:55 +02:00
|
|
|
&& xcolor_init_reply(xcolor_init_unchecked(&c->border_color, buf, len)))
|
|
|
|
xcb_change_window_attributes(globalconf.connection, c->win,
|
|
|
|
XCB_CW_BORDER_PIXEL, &c->border_color.pixel);
|
2008-07-01 20:07:21 +02:00
|
|
|
break;
|
2008-07-01 22:19:23 +02:00
|
|
|
case A_TK_TITLEBAR:
|
2008-09-21 20:39:23 +02:00
|
|
|
if(lua_isnil(L, 3))
|
2009-04-10 15:23:55 +02:00
|
|
|
titlebar_client_detach(c);
|
2008-09-21 20:39:23 +02:00
|
|
|
else
|
2009-04-11 00:27:06 +02:00
|
|
|
titlebar_client_attach(c);
|
2008-08-07 16:37:58 +02:00
|
|
|
break;
|
2008-07-01 19:49:14 +02:00
|
|
|
default:
|
|
|
|
return 0;
|
2008-07-01 19:37:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-07-28 16:03:38 +02:00
|
|
|
/** Client object.
|
2008-07-01 19:37:10 +02:00
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \return The number of elements pushed on stack.
|
2008-07-10 09:22:23 +02:00
|
|
|
* \luastack
|
2009-02-18 16:53:42 +01:00
|
|
|
* \lfield id The window X id.
|
2008-07-10 09:22:23 +02:00
|
|
|
* \lfield name The client title.
|
2008-10-20 17:27:18 +02:00
|
|
|
* \lfield skip_taskbar True if the client does not want to be in taskbar.
|
2008-09-03 15:11:06 +02:00
|
|
|
* \lfield type The window type (desktop, normal, dock, …).
|
2008-07-26 08:45:35 +02:00
|
|
|
* \lfield class The client class.
|
|
|
|
* \lfield instance The client instance.
|
2008-07-10 09:22:23 +02:00
|
|
|
* \lfield pid The client PID, if available.
|
2008-08-28 11:29:21 +02:00
|
|
|
* \lfield role The window role, if available.
|
2008-08-11 11:09:44 +02:00
|
|
|
* \lfield machine The machine client is running on.
|
2008-08-11 11:41:42 +02:00
|
|
|
* \lfield icon_name The client name when iconified.
|
2008-07-10 09:22:23 +02:00
|
|
|
* \lfield screen Client screen number.
|
2008-10-20 17:27:18 +02:00
|
|
|
* \lfield hide Define if the client must be hidden, i.e. never mapped,
|
2008-09-06 13:52:05 +02:00
|
|
|
* invisible in taskbar.
|
2009-04-11 18:52:46 +02:00
|
|
|
* \lfield minimized Define it the client must be iconify, i.e. only visible in
|
2008-09-06 13:52:05 +02:00
|
|
|
* taskbar.
|
2008-12-09 11:38:29 +01:00
|
|
|
* \lfield size_hints_honor Honor size hints, i.e. respect size ratio.
|
2008-07-10 09:22:23 +02:00
|
|
|
* \lfield border_width The client border width.
|
|
|
|
* \lfield border_color The client border color.
|
|
|
|
* \lfield titlebar The client titlebar.
|
2008-07-29 14:37:17 +02:00
|
|
|
* \lfield urgent The client urgent state.
|
2008-12-29 15:28:24 +01:00
|
|
|
* \lfield content An image representing the client window content (screenshot).
|
2008-08-12 12:08:20 +02:00
|
|
|
* \lfield focus The focused client.
|
2008-08-15 02:00:58 +02:00
|
|
|
* \lfield opacity The client opacity between 0 and 1.
|
2008-08-21 17:52:44 +02:00
|
|
|
* \lfield ontop The client is on top of every other windows.
|
2009-02-08 23:55:30 +01:00
|
|
|
* \lfield above The client is above normal windows.
|
|
|
|
* \lfield below The client is below normal windows.
|
2008-08-21 17:58:08 +02:00
|
|
|
* \lfield fullscreen The client is fullscreen or not.
|
2008-11-25 11:54:38 +01:00
|
|
|
* \lfield maximized_horizontal The client is maximized horizontally or not.
|
|
|
|
* \lfield maximized_vertical The client is maximized vertically or not.
|
2008-11-10 15:43:04 +01:00
|
|
|
* \lfield transient_for Return the client the window is transient for.
|
2008-12-01 19:06:35 +01:00
|
|
|
* \lfield group_id Identification unique to a group of windows.
|
2008-12-01 19:44:28 +01:00
|
|
|
* \lfield leader_id Identification unique to windows spawned by the same command.
|
2008-11-12 15:43:33 +01:00
|
|
|
* \lfield size_hints A table with size hints of the client: user_position,
|
2008-12-09 13:59:50 +01:00
|
|
|
* user_size, program_position, program_size, etc.
|
2008-07-01 19:37:10 +02:00
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_client_index(lua_State *L)
|
|
|
|
{
|
|
|
|
size_t len;
|
2008-08-11 11:09:44 +02:00
|
|
|
ssize_t slen;
|
2009-04-10 15:23:55 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, 1);
|
2008-07-01 19:37:10 +02:00
|
|
|
const char *buf = luaL_checklstring(L, 2, &len);
|
2008-08-11 11:09:44 +02:00
|
|
|
char *value;
|
2008-07-08 18:34:32 +02:00
|
|
|
void *data;
|
|
|
|
xcb_get_property_cookie_t prop_c;
|
|
|
|
xcb_get_property_reply_t *prop_r = NULL;
|
2008-08-15 02:00:58 +02:00
|
|
|
double d;
|
2008-07-01 19:37:10 +02:00
|
|
|
|
|
|
|
if(luaA_usemetatable(L, 1, 2))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
switch(a_tokenize(buf, len))
|
|
|
|
{
|
|
|
|
case A_TK_NAME:
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushstring(L, c->name);
|
2008-07-01 19:37:10 +02:00
|
|
|
break;
|
2008-11-10 15:43:04 +01:00
|
|
|
case A_TK_TRANSIENT_FOR:
|
2009-04-10 15:23:55 +02:00
|
|
|
return client_push(globalconf.L, c->transient_for);
|
2008-10-20 17:27:18 +02:00
|
|
|
case A_TK_SKIP_TASKBAR:
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushboolean(L, c->skiptb);
|
2008-10-20 17:27:18 +02:00
|
|
|
break;
|
2008-12-29 15:21:00 +01:00
|
|
|
case A_TK_CONTENT:
|
2009-04-10 15:23:55 +02:00
|
|
|
return client_getcontent(c);
|
2008-09-03 15:11:06 +02:00
|
|
|
case A_TK_TYPE:
|
2009-04-10 15:23:55 +02:00
|
|
|
switch(c->type)
|
2008-09-03 15:11:06 +02:00
|
|
|
{
|
|
|
|
case WINDOW_TYPE_DESKTOP:
|
|
|
|
lua_pushliteral(L, "desktop");
|
|
|
|
break;
|
|
|
|
case WINDOW_TYPE_DOCK:
|
|
|
|
lua_pushliteral(L, "dock");
|
|
|
|
break;
|
|
|
|
case WINDOW_TYPE_SPLASH:
|
|
|
|
lua_pushliteral(L, "splash");
|
|
|
|
break;
|
|
|
|
case WINDOW_TYPE_DIALOG:
|
|
|
|
lua_pushliteral(L, "dialog");
|
|
|
|
break;
|
2008-11-30 01:47:24 +01:00
|
|
|
case WINDOW_TYPE_MENU:
|
|
|
|
lua_pushliteral(L, "menu");
|
|
|
|
break;
|
|
|
|
case WINDOW_TYPE_TOOLBAR:
|
|
|
|
lua_pushliteral(L, "toolbar");
|
|
|
|
break;
|
|
|
|
case WINDOW_TYPE_UTILITY:
|
|
|
|
lua_pushliteral(L, "utility");
|
|
|
|
break;
|
2009-02-13 11:25:38 +01:00
|
|
|
case WINDOW_TYPE_DROPDOWN_MENU:
|
|
|
|
lua_pushliteral(L, "dropdown_menu");
|
|
|
|
break;
|
|
|
|
case WINDOW_TYPE_POPUP_MENU:
|
|
|
|
lua_pushliteral(L, "popup_menu");
|
|
|
|
break;
|
|
|
|
case WINDOW_TYPE_TOOLTIP:
|
|
|
|
lua_pushliteral(L, "tooltip");
|
|
|
|
break;
|
|
|
|
case WINDOW_TYPE_NOTIFICATION:
|
|
|
|
lua_pushliteral(L, "notification");
|
|
|
|
break;
|
|
|
|
case WINDOW_TYPE_COMBO:
|
|
|
|
lua_pushliteral(L, "combo");
|
|
|
|
break;
|
|
|
|
case WINDOW_TYPE_DND:
|
|
|
|
lua_pushliteral(L, "dnd");
|
|
|
|
break;
|
|
|
|
case WINDOW_TYPE_NORMAL:
|
2008-09-03 15:11:06 +02:00
|
|
|
lua_pushliteral(L, "normal");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2008-07-01 21:56:53 +02:00
|
|
|
case A_TK_CLASS:
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushstring(L, c->class);
|
2008-07-26 08:45:35 +02:00
|
|
|
break;
|
|
|
|
case A_TK_INSTANCE:
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushstring(L, c->instance);
|
2008-07-26 08:45:35 +02:00
|
|
|
break;
|
2008-08-28 11:29:21 +02:00
|
|
|
case A_TK_ROLE:
|
2009-04-10 15:23:55 +02:00
|
|
|
if(!xutil_text_prop_get(globalconf.connection, c->win,
|
2008-08-28 11:29:21 +02:00
|
|
|
WM_WINDOW_ROLE, &value, &slen))
|
|
|
|
return 0;
|
|
|
|
lua_pushlstring(L, value, slen);
|
|
|
|
p_delete(&value);
|
|
|
|
break;
|
2008-07-08 18:34:32 +02:00
|
|
|
case A_TK_PID:
|
2009-04-10 15:23:55 +02:00
|
|
|
prop_c = xcb_get_property_unchecked(globalconf.connection, false, c->win, _NET_WM_PID, CARDINAL, 0L, 1L);
|
2008-07-08 18:34:32 +02:00
|
|
|
prop_r = xcb_get_property_reply(globalconf.connection, prop_c, NULL);
|
|
|
|
|
|
|
|
if(prop_r && prop_r->value_len && (data = xcb_get_property_value(prop_r)))
|
|
|
|
lua_pushnumber(L, *(uint32_t *)data);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
p_delete(&prop_r);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
2009-02-18 16:53:42 +01:00
|
|
|
case A_TK_ID:
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushnumber(L, c->win);
|
2009-02-18 16:53:42 +01:00
|
|
|
break;
|
2008-12-01 19:44:28 +01:00
|
|
|
case A_TK_LEADER_ID:
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushnumber(L, c->leader_win);
|
2008-12-01 19:44:28 +01:00
|
|
|
break;
|
2008-08-11 11:09:44 +02:00
|
|
|
case A_TK_MACHINE:
|
2009-04-10 15:23:55 +02:00
|
|
|
if(!xutil_text_prop_get(globalconf.connection, c->win,
|
2008-08-11 13:27:28 +02:00
|
|
|
WM_CLIENT_MACHINE, &value, &slen))
|
2008-08-11 11:09:44 +02:00
|
|
|
return 0;
|
|
|
|
lua_pushlstring(L, value, slen);
|
|
|
|
p_delete(&value);
|
|
|
|
break;
|
2008-08-11 11:41:42 +02:00
|
|
|
case A_TK_ICON_NAME:
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushstring(L, c->icon_name);
|
2008-08-11 11:41:42 +02:00
|
|
|
break;
|
2008-07-01 21:39:00 +02:00
|
|
|
case A_TK_SCREEN:
|
2009-04-18 17:51:31 +02:00
|
|
|
lua_pushnumber(L, 1 + screen_array_indexof(&globalconf.screens, c->screen));
|
2008-07-01 21:39:00 +02:00
|
|
|
break;
|
2008-07-01 19:43:23 +02:00
|
|
|
case A_TK_HIDE:
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushboolean(L, c->ishidden);
|
2008-07-01 19:43:23 +02:00
|
|
|
break;
|
2008-11-25 11:55:56 +01:00
|
|
|
case A_TK_MINIMIZED:
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushboolean(L, c->isminimized);
|
2008-09-06 13:52:05 +02:00
|
|
|
break;
|
2008-08-21 17:58:08 +02:00
|
|
|
case A_TK_FULLSCREEN:
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushboolean(L, c->isfullscreen);
|
2008-08-21 17:58:08 +02:00
|
|
|
break;
|
2008-12-01 19:06:35 +01:00
|
|
|
case A_TK_GROUP_ID:
|
2009-04-10 15:23:55 +02:00
|
|
|
if(c->group_win)
|
|
|
|
lua_pushnumber(L, c->group_win);
|
2008-12-01 19:06:35 +01:00
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
break;
|
2008-11-25 11:54:38 +01:00
|
|
|
case A_TK_MAXIMIZED_HORIZONTAL:
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushboolean(L, c->ismaxhoriz);
|
2008-11-25 11:54:38 +01:00
|
|
|
break;
|
|
|
|
case A_TK_MAXIMIZED_VERTICAL:
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushboolean(L, c->ismaxvert);
|
2008-11-25 11:54:38 +01:00
|
|
|
break;
|
2008-09-11 15:26:56 +02:00
|
|
|
case A_TK_ICON:
|
2009-04-10 15:23:55 +02:00
|
|
|
image_push(L, c->icon);
|
2008-07-01 19:49:35 +02:00
|
|
|
break;
|
2008-08-15 02:00:58 +02:00
|
|
|
case A_TK_OPACITY:
|
2009-04-10 15:23:55 +02:00
|
|
|
if((d = window_opacity_get(c->win)) >= 0)
|
2008-08-15 02:00:58 +02:00
|
|
|
lua_pushnumber(L, d);
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
break;
|
2008-08-21 17:52:44 +02:00
|
|
|
case A_TK_ONTOP:
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushboolean(L, c->isontop);
|
2008-08-21 17:52:44 +02:00
|
|
|
break;
|
2009-02-08 23:55:30 +01:00
|
|
|
case A_TK_ABOVE:
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushboolean(L, c->isabove);
|
2009-02-08 23:55:30 +01:00
|
|
|
break;
|
|
|
|
case A_TK_BELOW:
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushboolean(L, c->isbelow);
|
2009-02-08 23:55:30 +01:00
|
|
|
break;
|
2008-08-21 16:29:53 +02:00
|
|
|
case A_TK_STICKY:
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushboolean(L, c->issticky);
|
2008-08-21 16:29:53 +02:00
|
|
|
break;
|
2008-12-09 11:38:29 +01:00
|
|
|
case A_TK_SIZE_HINTS_HONOR:
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushboolean(L, c->size_hints_honor);
|
2008-07-01 19:37:10 +02:00
|
|
|
break;
|
2008-07-01 20:07:21 +02:00
|
|
|
case A_TK_BORDER_WIDTH:
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushnumber(L, c->border);
|
2008-07-01 20:07:21 +02:00
|
|
|
break;
|
|
|
|
case A_TK_BORDER_COLOR:
|
2009-04-18 11:55:29 +02:00
|
|
|
luaA_pushxcolor(L, &c->border_color);
|
2008-07-01 22:08:27 +02:00
|
|
|
break;
|
2008-07-01 22:19:23 +02:00
|
|
|
case A_TK_TITLEBAR:
|
2009-04-11 00:27:06 +02:00
|
|
|
return wibox_push(L, c->titlebar);
|
2008-07-29 14:37:17 +02:00
|
|
|
case A_TK_URGENT:
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushboolean(L, c->isurgent);
|
2008-07-29 14:37:17 +02:00
|
|
|
break;
|
2008-11-12 15:43:33 +01:00
|
|
|
case A_TK_SIZE_HINTS:
|
2008-12-09 13:59:50 +01:00
|
|
|
{
|
|
|
|
const char *u_or_p = NULL;
|
|
|
|
|
2009-04-25 15:04:27 +02:00
|
|
|
lua_createtable(L, 0, 1);
|
2008-12-09 13:59:50 +01:00
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
if(c->size_hints.flags & XCB_SIZE_HINT_US_POSITION)
|
2008-12-09 13:59:50 +01:00
|
|
|
u_or_p = "user_position";
|
2009-04-10 15:23:55 +02:00
|
|
|
else if(c->size_hints.flags & XCB_SIZE_HINT_P_POSITION)
|
2008-12-09 13:59:50 +01:00
|
|
|
u_or_p = "program_position";
|
|
|
|
|
|
|
|
if(u_or_p)
|
|
|
|
{
|
2009-04-25 15:04:27 +02:00
|
|
|
lua_createtable(L, 0, 2);
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushnumber(L, c->size_hints.x);
|
2008-12-09 13:59:50 +01:00
|
|
|
lua_setfield(L, -2, "x");
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushnumber(L, c->size_hints.y);
|
2008-12-09 13:59:50 +01:00
|
|
|
lua_setfield(L, -2, "y");
|
|
|
|
lua_setfield(L, -2, u_or_p);
|
|
|
|
u_or_p = NULL;
|
|
|
|
}
|
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
if(c->size_hints.flags & XCB_SIZE_HINT_US_SIZE)
|
2008-12-09 13:59:50 +01:00
|
|
|
u_or_p = "user_size";
|
2009-04-10 15:23:55 +02:00
|
|
|
else if(c->size_hints.flags & XCB_SIZE_HINT_P_SIZE)
|
2008-12-09 13:59:50 +01:00
|
|
|
u_or_p = "program_size";
|
|
|
|
|
|
|
|
if(u_or_p)
|
|
|
|
{
|
2009-04-25 15:04:27 +02:00
|
|
|
lua_createtable(L, 0, 2);
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushnumber(L, c->size_hints.width);
|
2008-12-09 13:59:50 +01:00
|
|
|
lua_setfield(L, -2, "width");
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushnumber(L, c->size_hints.height);
|
2008-12-09 13:59:50 +01:00
|
|
|
lua_setfield(L, -2, "height");
|
|
|
|
lua_setfield(L, -2, u_or_p);
|
|
|
|
}
|
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
if(c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)
|
2008-12-09 13:59:50 +01:00
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushnumber(L, c->size_hints.min_width);
|
2008-12-09 13:59:50 +01:00
|
|
|
lua_setfield(L, -2, "min_width");
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushnumber(L, c->size_hints.min_height);
|
2008-12-09 13:59:50 +01:00
|
|
|
lua_setfield(L, -2, "min_height");
|
|
|
|
}
|
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
if(c->size_hints.flags & XCB_SIZE_HINT_P_MAX_SIZE)
|
2008-12-09 13:59:50 +01:00
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushnumber(L, c->size_hints.max_width);
|
2008-12-09 13:59:50 +01:00
|
|
|
lua_setfield(L, -2, "max_width");
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushnumber(L, c->size_hints.max_height);
|
2008-12-09 13:59:50 +01:00
|
|
|
lua_setfield(L, -2, "max_height");
|
|
|
|
}
|
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
if(c->size_hints.flags & XCB_SIZE_HINT_P_RESIZE_INC)
|
2008-12-09 13:59:50 +01:00
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushnumber(L, c->size_hints.width_inc);
|
2008-12-09 13:59:50 +01:00
|
|
|
lua_setfield(L, -2, "width_inc");
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushnumber(L, c->size_hints.height_inc);
|
2008-12-09 13:59:50 +01:00
|
|
|
lua_setfield(L, -2, "height_inc");
|
|
|
|
}
|
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
if(c->size_hints.flags & XCB_SIZE_HINT_P_ASPECT)
|
2008-12-09 13:59:50 +01:00
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushnumber(L, c->size_hints.min_aspect_num);
|
2008-12-09 13:59:50 +01:00
|
|
|
lua_setfield(L, -2, "min_aspect_num");
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushnumber(L, c->size_hints.min_aspect_den);
|
2008-12-09 13:59:50 +01:00
|
|
|
lua_setfield(L, -2, "min_aspect_den");
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushnumber(L, c->size_hints.max_aspect_num);
|
2008-12-09 13:59:50 +01:00
|
|
|
lua_setfield(L, -2, "max_aspect_num");
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushnumber(L, c->size_hints.max_aspect_den);
|
2008-12-09 13:59:50 +01:00
|
|
|
lua_setfield(L, -2, "max_aspect_den");
|
|
|
|
}
|
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
if(c->size_hints.flags & XCB_SIZE_HINT_BASE_SIZE)
|
2008-12-09 13:59:50 +01:00
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushnumber(L, c->size_hints.base_width);
|
2008-12-09 13:59:50 +01:00
|
|
|
lua_setfield(L, -2, "base_width");
|
2009-04-10 15:23:55 +02:00
|
|
|
lua_pushnumber(L, c->size_hints.base_height);
|
2008-12-09 13:59:50 +01:00
|
|
|
lua_setfield(L, -2, "base_height");
|
|
|
|
}
|
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
if(c->size_hints.flags & XCB_SIZE_HINT_P_WIN_GRAVITY)
|
2008-12-09 13:59:50 +01:00
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
switch(c->size_hints.win_gravity)
|
2008-12-09 13:59:50 +01:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
lua_setfield(L, -2, "win_gravity");
|
|
|
|
}
|
|
|
|
}
|
2008-09-30 11:45:41 +02:00
|
|
|
break;
|
2008-07-01 19:59:36 +02:00
|
|
|
default:
|
|
|
|
return 0;
|
2008-07-01 19:37:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-08-12 13:23:10 +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)
|
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
client_t *client = luaA_client_checkudata(L, 1);
|
|
|
|
button_array_t *buttons = &client->buttons;
|
2008-08-12 13:23:10 +02:00
|
|
|
|
|
|
|
if(lua_gettop(L) == 2)
|
|
|
|
luaA_button_array_set(L, 2, buttons);
|
|
|
|
|
2009-04-10 15:23:55 +02:00
|
|
|
window_buttons_grab(client->win, &client->buttons);
|
2009-02-24 17:32:48 +01:00
|
|
|
|
2008-08-12 13:23:10 +02:00
|
|
|
return luaA_button_array_get(L, buttons);
|
|
|
|
}
|
|
|
|
|
2009-01-05 16:59:20 +01:00
|
|
|
/** 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)
|
|
|
|
{
|
2009-04-10 15:23:55 +02:00
|
|
|
client_t *c = luaA_client_checkudata(L, 1);
|
2009-04-27 16:10:58 +02:00
|
|
|
key_array_t *keys = &c->keys;
|
2009-01-05 16:59:20 +01:00
|
|
|
|
|
|
|
if(lua_gettop(L) == 2)
|
|
|
|
{
|
|
|
|
luaA_key_array_set(L, 2, keys);
|
2009-04-10 15:23:55 +02:00
|
|
|
xcb_ungrab_key(globalconf.connection, XCB_GRAB_ANY, c->win, XCB_BUTTON_MASK_ANY);
|
|
|
|
window_grabkeys(c->win, keys);
|
2009-01-05 16:59:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return luaA_key_array_get(L, 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-04-10 15:23:55 +02:00
|
|
|
return client_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;
|
|
|
|
}
|
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
const struct luaL_reg awesome_client_methods[] =
|
|
|
|
{
|
|
|
|
{ "get", luaA_client_get },
|
2008-08-12 12:08:20 +02:00
|
|
|
{ "__index", luaA_client_module_index },
|
|
|
|
{ "__newindex", luaA_client_module_newindex },
|
2008-05-20 15:39:47 +02:00
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
const struct luaL_reg awesome_client_meta[] =
|
|
|
|
{
|
2008-09-18 15:07:34 +02:00
|
|
|
{ "isvisible", luaA_client_isvisible },
|
2008-10-21 15:31:52 +02:00
|
|
|
{ "geometry", luaA_client_geometry },
|
2009-02-07 19:40:07 +01:00
|
|
|
{ "struts", luaA_client_struts },
|
2008-08-12 13:23:10 +02:00
|
|
|
{ "buttons", luaA_client_buttons },
|
2009-01-05 16:59:20 +01:00
|
|
|
{ "keys", luaA_client_keys },
|
2008-08-13 17:49:57 +02:00
|
|
|
{ "tags", luaA_client_tags },
|
2008-05-20 15:39:47 +02:00
|
|
|
{ "kill", luaA_client_kill },
|
|
|
|
{ "swap", luaA_client_swap },
|
2008-05-26 16:17:57 +02:00
|
|
|
{ "raise", luaA_client_raise },
|
2008-11-12 11:27:58 +01:00
|
|
|
{ "lower", luaA_client_lower },
|
2008-05-20 15:39:47 +02:00
|
|
|
{ "redraw", luaA_client_redraw },
|
2008-06-02 08:31:54 +02:00
|
|
|
{ "unmanage", luaA_client_unmanage },
|
2008-07-01 19:37:10 +02:00
|
|
|
{ "__index", luaA_client_index },
|
|
|
|
{ "__newindex", luaA_client_newindex },
|
2008-07-31 17:29:05 +02:00
|
|
|
{ "__gc", luaA_client_gc },
|
2008-05-20 15:39:47 +02:00
|
|
|
{ "__tostring", luaA_client_tostring },
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
|
2007-12-18 09:24:15 +01:00
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|