2007-10-03 17:26:14 +02:00
|
|
|
/*
|
|
|
|
* client.c - client management
|
|
|
|
*
|
2008-01-02 16:59:43 +01:00
|
|
|
* Copyright © 2007-2008 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
|
|
|
|
|
|
|
#include <stdio.h>
|
2008-03-21 16:50:17 +01:00
|
|
|
|
|
|
|
#include <xcb/xcb.h>
|
|
|
|
#include <xcb/xcb_aux.h>
|
|
|
|
#include <xcb/xcb_atom.h>
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2008-01-01 17:25:48 +01:00
|
|
|
#include "client.h"
|
2008-06-09 21:43:09 +02:00
|
|
|
#include "tag.h"
|
2007-10-26 18:23:15 +02:00
|
|
|
#include "window.h"
|
2007-12-14 21:51:54 +01:00
|
|
|
#include "focus.h"
|
2007-12-27 18:01:36 +01:00
|
|
|
#include "ewmh.h"
|
2008-01-07 18:12:38 +01:00
|
|
|
#include "widget.h"
|
2008-03-13 09:05:34 +01:00
|
|
|
#include "screen.h"
|
2008-03-15 13:59:04 +01:00
|
|
|
#include "titlebar.h"
|
2008-05-20 15:39:47 +02:00
|
|
|
#include "lua.h"
|
2008-05-25 19:30:54 +02:00
|
|
|
#include "stack.h"
|
2008-05-26 16:17:57 +02:00
|
|
|
#include "mouse.h"
|
2007-09-05 20:15:00 +02:00
|
|
|
#include "layouts/floating.h"
|
2008-04-28 12:23:10 +02:00
|
|
|
#include "common/markup.h"
|
2008-03-13 09:05:34 +01:00
|
|
|
#include "common/xutil.h"
|
|
|
|
#include "common/xscreen.h"
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2008-05-24 08:59:27 +02:00
|
|
|
extern awesome_t globalconf;
|
2007-12-16 02:45:38 +01:00
|
|
|
|
2008-06-20 08:32:46 +02:00
|
|
|
/** Create a new client userdata.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param p A client pointer.
|
|
|
|
* \param The number of elements pushed on the stack.
|
|
|
|
*/
|
2008-06-18 18:31:35 +02:00
|
|
|
int
|
|
|
|
luaA_client_userdata_new(lua_State *L, client_t *p)
|
|
|
|
{
|
|
|
|
client_t **pp = lua_newuserdata(L, sizeof(client_t *));
|
|
|
|
*pp = p;
|
|
|
|
return luaA_settype(L, "client");
|
|
|
|
}
|
|
|
|
|
|
|
|
DO_LUA_EQ(client_t, client, "client")
|
|
|
|
|
2008-06-09 21:43:09 +02:00
|
|
|
/** Load windows properties, restoring client's tag
|
2008-06-05 09:25:38 +02:00
|
|
|
* and floating state before awesome was restarted if any.
|
2008-06-09 21:43:09 +02:00
|
|
|
* \todo This may bug if number of tags is != than before.
|
2008-06-05 09:25:38 +02:00
|
|
|
* \param c A client pointer.
|
2008-06-10 15:15:13 +02:00
|
|
|
* \param screen A virtual screen.
|
2008-06-05 09:25:38 +02:00
|
|
|
* \return True if client had property, false otherwise.
|
2007-10-17 11:49:54 +02:00
|
|
|
*/
|
2008-03-21 16:50:17 +01:00
|
|
|
static bool
|
2008-06-10 15:15:13 +02:00
|
|
|
client_loadprops(client_t * c, screen_t *screen)
|
2007-10-16 22:40:02 +02:00
|
|
|
{
|
2008-06-09 21:43:09 +02:00
|
|
|
int i, ntags = 0;
|
|
|
|
tag_t *tag;
|
2008-04-28 22:56:16 +02:00
|
|
|
char *prop = NULL;
|
2008-03-21 16:50:17 +01:00
|
|
|
bool result = false;
|
2007-10-16 22:40:02 +02:00
|
|
|
|
2008-06-10 15:15:13 +02:00
|
|
|
for(tag = screen->tags; tag; tag = tag->next)
|
2008-06-09 21:43:09 +02:00
|
|
|
ntags++;
|
2007-12-14 14:29:32 +01:00
|
|
|
|
2008-05-11 00:30:20 +02:00
|
|
|
if(xutil_gettextprop(globalconf.connection, c->win, &globalconf.atoms,
|
2008-06-09 21:43:09 +02:00
|
|
|
xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms,
|
|
|
|
xutil_intern_atom(globalconf.connection,
|
|
|
|
&globalconf.atoms,
|
|
|
|
"_AWESOME_PROPERTIES")),
|
2008-04-28 22:56:16 +02:00
|
|
|
&prop))
|
2007-12-14 14:29:32 +01:00
|
|
|
{
|
2008-06-10 15:15:13 +02:00
|
|
|
for(i = 0, tag = screen->tags; tag && i < ntags && prop[i]; i++, tag = tag->next)
|
2007-12-14 14:29:32 +01:00
|
|
|
if(prop[i] == '1')
|
|
|
|
{
|
2008-06-09 21:43:09 +02:00
|
|
|
tag_client(c, tag);
|
2008-03-21 16:50:17 +01:00
|
|
|
result = true;
|
2007-12-14 14:29:32 +01:00
|
|
|
}
|
2008-06-09 21:43:09 +02:00
|
|
|
else
|
|
|
|
untag_client(c, tag);
|
2007-12-14 14:29:32 +01:00
|
|
|
|
2008-04-08 19:52:59 +02:00
|
|
|
if(prop[i])
|
2008-06-05 09:25:38 +02:00
|
|
|
client_setfloating(c, prop[i] == '1',
|
|
|
|
(prop[i + 1] >= 0 && prop[i + 1] <= LAYER_FULLSCREEN) ? atoi(&prop[i + 1]) : prop[i] == '1' ? LAYER_FLOAT : LAYER_TILE);
|
2007-12-14 14:29:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
p_delete(&prop);
|
|
|
|
|
|
|
|
return result;
|
2007-10-16 22:40:02 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 08:32:46 +02:00
|
|
|
/** Check if client supports protocol WM_DELETE_WINDOW.
|
2008-04-29 09:14:46 +02:00
|
|
|
* \param win The window.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \return True if client has WM_DELETE_WINDOW, false otherwise.
|
2007-09-05 20:15:00 +02:00
|
|
|
*/
|
2008-03-21 16:50:17 +01:00
|
|
|
static bool
|
2008-06-05 09:25:38 +02:00
|
|
|
window_isprotodel(xcb_window_t win)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-03-21 16:50:17 +01:00
|
|
|
uint32_t i, n;
|
2008-05-11 00:30:20 +02:00
|
|
|
xcb_atom_t wm_delete_win_atom;
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_atom_t *protocols;
|
|
|
|
bool ret = false;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2008-04-29 09:14:46 +02:00
|
|
|
if(xcb_get_wm_protocols(globalconf.connection, win, &n, &protocols))
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-05-11 00:30:20 +02:00
|
|
|
wm_delete_win_atom = xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms,
|
|
|
|
xutil_intern_atom(globalconf.connection,
|
|
|
|
&globalconf.atoms,
|
|
|
|
"WM_DELETE_WINDOW"));
|
|
|
|
|
2007-09-05 20:15:00 +02:00
|
|
|
for(i = 0; !ret && i < n; i++)
|
2008-05-11 00:30:20 +02:00
|
|
|
if(protocols[i] == wm_delete_win_atom)
|
2008-03-21 16:50:17 +01:00
|
|
|
ret = true;
|
|
|
|
p_delete(&protocols);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
* \param screen Virtual screen number.
|
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
|
2008-04-11 11:35:11 +02:00
|
|
|
client_isvisible(client_t *c, int screen)
|
2008-04-09 17:33:47 +02:00
|
|
|
{
|
2008-06-09 21:43:09 +02:00
|
|
|
tag_t *tag;
|
|
|
|
|
|
|
|
if(c && !c->ishidden && c->screen == screen)
|
|
|
|
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
|
|
|
|
if(tag->selected && is_client_tagged(c, tag))
|
|
|
|
return true;
|
2008-04-09 17:33:47 +02:00
|
|
|
return false;
|
|
|
|
}
|
2008-06-10 19:29:53 +02:00
|
|
|
|
2008-06-05 09:25:38 +02:00
|
|
|
/** Get a client by its window.
|
|
|
|
* \param w The client window to find.
|
2008-04-29 09:14:46 +02:00
|
|
|
* \return A client pointer if found, NULL otherwise.
|
2007-12-14 14:29:32 +01:00
|
|
|
*/
|
2008-04-11 11:35:11 +02:00
|
|
|
client_t *
|
2008-06-05 09:25:38 +02:00
|
|
|
client_getbywin(xcb_window_t w)
|
2007-12-14 14:29:32 +01:00
|
|
|
{
|
2008-04-11 11:35:11 +02:00
|
|
|
client_t *c;
|
2008-06-05 09:25:38 +02:00
|
|
|
for(c = globalconf.clients; c && c->win != w; c = c->next);
|
2007-12-14 14:29:32 +01:00
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2008-04-29 09:14:46 +02:00
|
|
|
/** Update client name attribute with its new title.
|
|
|
|
* \param c The client.
|
2007-12-30 15:08:38 +01:00
|
|
|
*/
|
2007-10-01 20:44:02 +02:00
|
|
|
void
|
2008-04-11 11:35:11 +02:00
|
|
|
client_updatetitle(client_t *c)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-04-28 22:56:16 +02:00
|
|
|
char *name;
|
2008-06-20 16:42:07 +02:00
|
|
|
xutil_intern_atom_request_t net_wm_name_q;
|
|
|
|
xcb_atom_t net_wm_name;
|
2008-04-23 13:22:58 +02:00
|
|
|
|
2008-06-15 20:34:15 +02:00
|
|
|
net_wm_name_q = xutil_intern_atom(globalconf.connection, &globalconf.atoms, "_NET_WM_NAME");
|
|
|
|
net_wm_name = xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms, net_wm_name_q);
|
|
|
|
|
|
|
|
if(!xutil_gettextprop(globalconf.connection, c->win, &globalconf.atoms, net_wm_name, &name))
|
2008-06-20 16:42:07 +02:00
|
|
|
if(!xutil_gettextprop(globalconf.connection, c->win, &globalconf.atoms, WM_NAME, &name))
|
2008-04-28 22:56:16 +02:00
|
|
|
return;
|
2008-04-30 20:13:49 +02:00
|
|
|
|
2008-04-28 22:56:16 +02:00
|
|
|
p_delete(&c->name);
|
2008-06-10 07:32:35 +02:00
|
|
|
a_iso2utf8(name, &c->name);
|
2008-05-25 17:51:45 +02:00
|
|
|
|
|
|
|
/* call hook */
|
2008-06-18 18:31:35 +02:00
|
|
|
luaA_client_userdata_new(globalconf.L, c);
|
2008-05-25 17:51:45 +02:00
|
|
|
luaA_dofunction(globalconf.L, globalconf.hooks.titleupdate, 1);
|
|
|
|
|
2008-06-09 21:43:09 +02:00
|
|
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-06-10 19:29:53 +02:00
|
|
|
/** Unfocus a client.
|
|
|
|
* \param c The client.
|
|
|
|
*/
|
2008-01-25 12:55:44 +01:00
|
|
|
static void
|
2008-04-11 11:35:11 +02:00
|
|
|
client_unfocus(client_t *c)
|
2008-01-25 12:55:44 +01:00
|
|
|
{
|
2008-05-20 15:39:47 +02:00
|
|
|
/* Call hook */
|
2008-06-18 18:31:35 +02:00
|
|
|
luaA_client_userdata_new(globalconf.L, globalconf.focus->client);
|
2008-05-20 15:39:47 +02:00
|
|
|
luaA_dofunction(globalconf.L, globalconf.hooks.unfocus, 1);
|
|
|
|
|
2008-05-23 22:40:17 +02:00
|
|
|
focus_client_push(NULL);
|
2008-06-09 21:43:09 +02:00
|
|
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
2008-06-17 23:20:03 +02:00
|
|
|
ewmh_update_net_active_window(c->phys_screen);
|
2008-01-25 12:55:44 +01:00
|
|
|
}
|
|
|
|
|
2008-06-10 19:29:53 +02:00
|
|
|
/** Ban client and unmap it.
|
|
|
|
* \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-01-25 12:55:44 +01:00
|
|
|
if(globalconf.focus->client == c)
|
|
|
|
client_unfocus(c);
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_unmap_window(globalconf.connection, c->win);
|
2008-06-19 19:53:15 +02:00
|
|
|
if(c->ishidden)
|
|
|
|
window_setstate(c->win, XCB_WM_ICONIC_STATE);
|
|
|
|
else
|
|
|
|
window_setstate(c->win, XCB_WM_WITHDRAWN_STATE);
|
2008-06-04 11:50:21 +02:00
|
|
|
if(c->titlebar && c->titlebar->position && c->titlebar->sw)
|
|
|
|
xcb_unmap_window(globalconf.connection, c->titlebar->sw->window);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-06-20 08:32:46 +02:00
|
|
|
/** Give focus to client, or to first client if client is NULL.
|
2008-06-05 09:25:38 +02:00
|
|
|
* \param c The client or NULL.
|
2008-06-09 21:43:09 +02:00
|
|
|
* \param screen Virtual screen number.
|
|
|
|
* \return True if a window (even root) has received focus, false otherwise.
|
2007-09-05 20:15:00 +02:00
|
|
|
*/
|
2008-03-21 16:50:17 +01:00
|
|
|
bool
|
2008-06-09 21:43:09 +02:00
|
|
|
client_focus(client_t *c, int screen)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-03-25 18:20:39 +01:00
|
|
|
int phys_screen;
|
|
|
|
|
2008-06-09 21:43:09 +02:00
|
|
|
/* if c is NULL or invisible, take next client in the focus history */
|
|
|
|
if((!c || (c && (!client_isvisible(c, screen))))
|
|
|
|
&& !(c = focus_get_current_client(screen)))
|
|
|
|
/* if c is still NULL take next client in the stack */
|
|
|
|
for(c = globalconf.clients; c && (c->skip || !client_isvisible(c, screen)); c = c->next);
|
2007-10-03 17:26:14 +02:00
|
|
|
|
2008-01-25 12:55:44 +01:00
|
|
|
/* unfocus current selected client */
|
|
|
|
if(globalconf.focus->client)
|
|
|
|
client_unfocus(globalconf.focus->client);
|
2007-12-14 21:51:54 +01:00
|
|
|
|
2008-06-09 21:43:09 +02:00
|
|
|
if(c)
|
|
|
|
{
|
|
|
|
/* unban the client before focusing or it will fail */
|
|
|
|
client_unban(c);
|
|
|
|
/* save sel in focus history */
|
|
|
|
focus_client_push(c);
|
|
|
|
xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_POINTER_ROOT,
|
|
|
|
c->win, XCB_CURRENT_TIME);
|
|
|
|
phys_screen = c->phys_screen;
|
|
|
|
|
|
|
|
/* Some layouts use focused client differently, so call them back. */
|
|
|
|
globalconf.screens[c->screen].need_arrange = true;
|
|
|
|
|
|
|
|
/* execute hook */
|
2008-06-18 18:31:35 +02:00
|
|
|
luaA_client_userdata_new(globalconf.L, globalconf.focus->client);
|
2008-06-09 21:43:09 +02:00
|
|
|
luaA_dofunction(globalconf.L, globalconf.hooks.focus, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
phys_screen = screen_virttophys(screen);
|
|
|
|
xcb_set_input_focus(globalconf.connection,
|
|
|
|
XCB_INPUT_FOCUS_POINTER_ROOT,
|
2008-06-17 16:55:24 +02:00
|
|
|
xutil_screen_get(globalconf.connection, phys_screen)->root,
|
2008-06-09 21:43:09 +02:00
|
|
|
XCB_CURRENT_TIME);
|
|
|
|
}
|
2007-12-28 13:43:47 +01:00
|
|
|
|
2008-03-25 18:20:39 +01:00
|
|
|
ewmh_update_net_active_window(phys_screen);
|
2008-06-09 21:43:09 +02:00
|
|
|
widget_invalidate_cache(screen, WIDGET_CACHE_CLIENTS);
|
2008-03-25 11:28:07 +01:00
|
|
|
|
2008-03-21 16:50:17 +01:00
|
|
|
return true;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-05-25 19:30:54 +02:00
|
|
|
/** Restack clients and puts c in top of its layer.
|
|
|
|
* \param c The client to stack on top of others.
|
|
|
|
* \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
|
|
|
*/
|
2008-03-24 16:34:41 +01:00
|
|
|
void
|
2008-05-26 16:17:57 +02:00
|
|
|
client_raise(client_t *c)
|
2008-03-24 16:34:41 +01:00
|
|
|
{
|
2008-03-21 16:50:17 +01:00
|
|
|
uint32_t config_win_vals[2];
|
2008-05-25 19:30:54 +02:00
|
|
|
client_node_t *node;
|
2008-04-10 11:52:03 +02:00
|
|
|
layer_t layer;
|
2008-06-19 19:51:58 +02:00
|
|
|
statusbar_t *sb;
|
|
|
|
int screen;
|
2008-03-24 16:34:41 +01:00
|
|
|
|
2008-03-21 16:50:17 +01:00
|
|
|
config_win_vals[0] = XCB_NONE;
|
2008-05-25 19:30:54 +02:00
|
|
|
config_win_vals[1] = XCB_STACK_MODE_BELOW;
|
2008-04-08 19:52:59 +02:00
|
|
|
|
2008-06-05 09:25:38 +02:00
|
|
|
/* Push c on top of the stack. */
|
2008-05-25 19:30:54 +02:00
|
|
|
stack_client_push(c);
|
|
|
|
|
2008-06-19 19:51:58 +02:00
|
|
|
for(screen = 0; screen < globalconf.screens_info->nscreen; screen++)
|
|
|
|
for(sb = globalconf.screens[screen].statusbar; sb; sb = sb->next)
|
|
|
|
{
|
|
|
|
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-13 14:41:10 +02:00
|
|
|
for(layer = LAYER_OUTOFSPACE - 1; layer >= LAYER_DESKTOP; layer--)
|
2008-05-25 19:30:54 +02:00
|
|
|
for(node = globalconf.stack; node; node = node->next)
|
2008-06-19 19:51:58 +02:00
|
|
|
if(node->client->layer == layer)
|
2008-03-24 16:34:41 +01:00
|
|
|
{
|
2008-06-04 11:50:21 +02:00
|
|
|
if(node->client->titlebar
|
|
|
|
&& node->client->titlebar->sw
|
|
|
|
&& node->client->titlebar->position)
|
2008-03-24 16:34:41 +01:00
|
|
|
{
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_configure_window(globalconf.connection,
|
2008-06-04 11:50:21 +02:00
|
|
|
node->client->titlebar->sw->window,
|
2008-03-21 16:50:17 +01:00
|
|
|
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
|
|
|
|
config_win_vals);
|
2008-06-04 11:50:21 +02:00
|
|
|
config_win_vals[0] = node->client->titlebar->sw->window;
|
2008-03-24 16:34:41 +01:00
|
|
|
}
|
2008-05-25 19:30:54 +02:00
|
|
|
xcb_configure_window(globalconf.connection, node->client->win,
|
2008-03-21 16:50:17 +01:00
|
|
|
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
|
|
|
|
config_win_vals);
|
2008-05-25 19:30:54 +02:00
|
|
|
config_win_vals[0] = node->client->win;
|
2008-03-24 16:34:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-05 09:25:38 +02:00
|
|
|
/** Manage a new client.
|
|
|
|
* \param w The window.
|
|
|
|
* \param wgeom Window geometry.
|
|
|
|
* \param screen Virtual screen number where to manage client.
|
2007-09-20 21:27:43 +02:00
|
|
|
*/
|
2007-09-05 20:15:00 +02:00
|
|
|
void
|
2008-03-22 14:59:03 +01:00
|
|
|
client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int screen)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-05-23 22:49:39 +02:00
|
|
|
client_t *c, *t = NULL;
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_window_t trans;
|
|
|
|
bool rettrans, retloadprops;
|
2008-06-09 21:43:09 +02:00
|
|
|
tag_t *tag;
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_size_hints_t *u_size_hints;
|
2008-06-05 09:25:38 +02:00
|
|
|
const uint32_t select_input_val[] = {
|
|
|
|
XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE |
|
|
|
|
XCB_EVENT_MASK_ENTER_WINDOW };
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2008-04-11 11:35:11 +02:00
|
|
|
c = p_new(client_t, 1);
|
2007-10-22 16:25:27 +02:00
|
|
|
|
2008-06-09 21:43:09 +02:00
|
|
|
c->screen = screen_get_bycoord(globalconf.screens_info, screen, wgeom->x, wgeom->y);
|
2008-01-22 09:50:24 +01:00
|
|
|
|
2008-03-21 10:53:17 +01:00
|
|
|
if(globalconf.screens_info->xinerama_is_active)
|
2008-03-21 16:50:17 +01:00
|
|
|
c->phys_screen = globalconf.default_screen;
|
2008-03-21 10:53:17 +01:00
|
|
|
else
|
2008-06-09 21:43:09 +02:00
|
|
|
c->phys_screen = c->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-03-22 14:59:03 +01:00
|
|
|
c->geometry.x = c->f_geometry.x = c->m_geometry.x = wgeom->x;
|
|
|
|
c->geometry.y = c->f_geometry.y = c->m_geometry.y = wgeom->y;
|
|
|
|
c->geometry.width = c->f_geometry.width = c->m_geometry.width = wgeom->width;
|
|
|
|
c->geometry.height = c->f_geometry.height = c->m_geometry.height = wgeom->height;
|
|
|
|
c->oldborder = wgeom->border_width;
|
2008-04-08 19:52:59 +02:00
|
|
|
c->layer = c->oldlayer = LAYER_TILE;
|
2007-10-22 16:25:27 +02:00
|
|
|
|
2008-01-13 16:30:43 +01:00
|
|
|
/* update hints */
|
2008-03-21 16:50:17 +01:00
|
|
|
u_size_hints = client_updatesizehints(c);
|
2008-01-13 16:30:43 +01:00
|
|
|
client_updatewmhints(c);
|
2007-12-28 20:48:29 +01:00
|
|
|
|
2008-03-15 14:46:45 +01:00
|
|
|
/* Try to load props if any */
|
2008-06-10 15:15:13 +02:00
|
|
|
if(!(retloadprops = client_loadprops(c, &globalconf.screens[screen])))
|
2008-06-09 21:43:09 +02:00
|
|
|
screen_client_moveto(c, screen, true);
|
2008-03-15 14:46:45 +01:00
|
|
|
|
|
|
|
/* Then check clients hints */
|
2007-12-28 20:48:29 +01:00
|
|
|
ewmh_check_client_hints(c);
|
2008-01-13 16:30:43 +01:00
|
|
|
|
2008-06-09 21:43:09 +02:00
|
|
|
/* check for transient and set tags like its parent */
|
2008-03-26 19:58:30 +01:00
|
|
|
if((rettrans = xutil_get_transient_for_hint(globalconf.connection, w, &trans))
|
2008-06-05 09:25:38 +02:00
|
|
|
&& (t = client_getbywin(trans)))
|
2008-06-09 21:43:09 +02:00
|
|
|
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
|
|
|
|
if(is_client_tagged(t, tag))
|
|
|
|
tag_client(c, tag);
|
2008-02-12 10:19:59 +01:00
|
|
|
|
|
|
|
/* should be floating if transsient or fixed */
|
2008-03-28 11:35:56 +01:00
|
|
|
if(rettrans || c->isfixed)
|
2008-03-21 16:50:17 +01:00
|
|
|
client_setfloating(c, true, c->layer != LAYER_TILE ? c->layer : LAYER_FLOAT);
|
2008-02-12 10:19:59 +01:00
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
if(globalconf.floating_placement
|
|
|
|
&& !retloadprops
|
2008-03-21 16:50:17 +01:00
|
|
|
&& u_size_hints
|
2008-04-27 13:26:39 +02:00
|
|
|
&& !(xcb_size_hints_get_flags(u_size_hints) & (XCB_SIZE_US_POSITION_HINT |
|
|
|
|
XCB_SIZE_P_POSITION_HINT)))
|
2008-04-03 09:04:18 +02:00
|
|
|
{
|
2008-05-23 13:11:47 +02:00
|
|
|
if(c->isfloating)
|
2008-05-20 15:39:47 +02:00
|
|
|
client_resize(c, globalconf.floating_placement(c), false);
|
2008-04-03 20:11:38 +02:00
|
|
|
else
|
2008-05-20 15:39:47 +02:00
|
|
|
c->f_geometry = globalconf.floating_placement(c);
|
2008-04-03 09:04:18 +02:00
|
|
|
}
|
2008-02-13 06:53:08 +01:00
|
|
|
|
2008-06-05 09:25:38 +02:00
|
|
|
if(u_size_hints)
|
|
|
|
xcb_free_size_hints(u_size_hints);
|
2008-03-22 18:47:13 +01:00
|
|
|
|
|
|
|
xcb_change_window_attributes(globalconf.connection, w, XCB_CW_EVENT_MASK,
|
|
|
|
select_input_val);
|
2007-10-22 16:25:27 +02:00
|
|
|
|
2008-05-23 22:40:17 +02:00
|
|
|
/* Push client in client list */
|
2008-05-20 15:39:47 +02:00
|
|
|
client_list_push(&globalconf.clients, c);
|
2008-05-23 22:40:17 +02:00
|
|
|
/* Append client in history: it'll be last. */
|
|
|
|
focus_client_append(c);
|
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 */
|
|
|
|
client_updatetitle(c);
|
|
|
|
|
2008-06-17 23:20:03 +02:00
|
|
|
ewmh_update_net_client_list(c->phys_screen);
|
|
|
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
/* call hook */
|
2008-06-18 18:31:35 +02:00
|
|
|
luaA_client_userdata_new(globalconf.L, c);
|
2008-06-10 19:03:10 +02:00
|
|
|
luaA_dofunction(globalconf.L, globalconf.hooks.manage, 1);
|
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
|
|
|
{
|
|
|
|
double dx, dy, max, min, ratio;
|
|
|
|
|
|
|
|
if(c->minay > 0 && c->maxay > 0 && (geometry.height - c->baseh) > 0
|
|
|
|
&& (geometry.width - c->basew) > 0)
|
|
|
|
{
|
|
|
|
dx = (double) (geometry.width - c->basew);
|
|
|
|
dy = (double) (geometry.height - c->baseh);
|
|
|
|
min = (double) (c->minax) / (double) (c->minay);
|
|
|
|
max = (double) (c->maxax) / (double) (c->maxay);
|
|
|
|
ratio = dx / dy;
|
|
|
|
if(max > 0 && min > 0 && ratio > 0)
|
|
|
|
{
|
|
|
|
if(ratio < min)
|
|
|
|
{
|
|
|
|
dy = (dx * min + dy) / (min * min + 1);
|
|
|
|
dx = dy * min;
|
|
|
|
geometry.width = (int) dx + c->basew;
|
|
|
|
geometry.height = (int) dy + c->baseh;
|
|
|
|
}
|
|
|
|
else if(ratio > max)
|
|
|
|
{
|
|
|
|
dy = (dx * min + dy) / (max * max + 1);
|
|
|
|
dx = dy * min;
|
|
|
|
geometry.width = (int) dx + c->basew;
|
|
|
|
geometry.height = (int) dy + c->baseh;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(c->minw && geometry.width < c->minw)
|
|
|
|
geometry.width = c->minw;
|
|
|
|
if(c->minh && geometry.height < c->minh)
|
|
|
|
geometry.height = c->minh;
|
|
|
|
if(c->maxw && geometry.width > c->maxw)
|
|
|
|
geometry.width = c->maxw;
|
|
|
|
if(c->maxh && geometry.height > c->maxh)
|
|
|
|
geometry.height = c->maxh;
|
|
|
|
if(c->incw)
|
|
|
|
geometry.width -= (geometry.width - c->basew) % c->incw;
|
|
|
|
if(c->inch)
|
|
|
|
geometry.height -= (geometry.height - c->baseh) % c->inch;
|
|
|
|
|
|
|
|
return geometry;
|
|
|
|
}
|
|
|
|
|
2008-05-27 20:17:33 +02:00
|
|
|
/** Resize client window.
|
|
|
|
* \param c Client to resize.
|
|
|
|
* \param geometry New window geometry.
|
|
|
|
* \param hints Use size hints.
|
|
|
|
* \return True if the client has been resized.
|
2007-12-30 15:08:38 +01:00
|
|
|
*/
|
2008-03-21 16:50: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-06-09 21:43:09 +02:00
|
|
|
int new_screen;
|
|
|
|
area_t area;
|
|
|
|
layout_t *layout = layout_get_current(c->screen);
|
2008-03-21 16:50:17 +01:00
|
|
|
bool resized = false;
|
2008-05-27 20:17:33 +02:00
|
|
|
/* Values to configure a window is an array where values are
|
|
|
|
* stored according to 'value_mask' */
|
|
|
|
uint32_t values[5];
|
2008-06-03 18:41:54 +02:00
|
|
|
|
2008-06-09 21:43:09 +02:00
|
|
|
if(c->titlebar && !c->ismoving && !c->isfloating && layout != layout_floating)
|
2008-06-18 17:05:10 +02:00
|
|
|
geometry = titlebar_geometry_remove(c->titlebar, c->border, geometry);
|
2008-03-26 10:57:06 +01:00
|
|
|
|
2008-03-16 10:01:55 +01:00
|
|
|
if(hints)
|
|
|
|
geometry = client_geometry_hints(c, geometry);
|
|
|
|
|
2008-01-05 20:18:30 +01:00
|
|
|
if(geometry.width <= 0 || geometry.height <= 0)
|
2008-03-21 16:50:17 +01:00
|
|
|
return false;
|
2008-03-14 14:27:56 +01:00
|
|
|
|
2008-06-09 21:43:09 +02:00
|
|
|
/* offscreen appearance fixes */
|
|
|
|
area = display_area_get(c->phys_screen, NULL,
|
|
|
|
&globalconf.screens[c->screen].padding);
|
|
|
|
|
|
|
|
if(geometry.x > area.width)
|
|
|
|
geometry.x = area.width - geometry.width - 2 * c->border;
|
|
|
|
if(geometry.y > area.height)
|
|
|
|
geometry.y = area.height - geometry.height - 2 * c->border;
|
|
|
|
if(geometry.x + geometry.width + 2 * c->border < 0)
|
|
|
|
geometry.x = 0;
|
|
|
|
if(geometry.y + geometry.height + 2 * c->border < 0)
|
|
|
|
geometry.y = 0;
|
|
|
|
|
2008-01-05 20:18:30 +01:00
|
|
|
if(c->geometry.x != geometry.x || c->geometry.y != geometry.y
|
|
|
|
|| c->geometry.width != geometry.width || c->geometry.height != geometry.height)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-03-16 10:01:55 +01:00
|
|
|
new_screen =
|
2008-06-09 21:43:09 +02:00
|
|
|
screen_get_bycoord(globalconf.screens_info, c->screen, geometry.x, geometry.y);
|
2008-01-06 14:40:23 +01:00
|
|
|
|
2008-03-21 16:50:17 +01:00
|
|
|
c->geometry.x = values[0] = geometry.x;
|
|
|
|
c->geometry.width = values[2] = geometry.width;
|
|
|
|
c->geometry.y = values[1] = geometry.y;
|
|
|
|
c->geometry.height = values[3] = geometry.height;
|
|
|
|
values[4] = c->border;
|
2008-03-14 14:27:56 +01:00
|
|
|
|
2008-01-11 17:54:48 +01:00
|
|
|
/* save the floating geometry if the window is floating but not
|
|
|
|
* maximized */
|
2008-03-16 17:51:46 +01:00
|
|
|
if(c->ismoving || c->isfloating
|
2008-06-09 21:43:09 +02:00
|
|
|
|| layout_get_current(new_screen) == layout_floating)
|
2008-05-25 08:25:51 +02:00
|
|
|
{
|
2008-06-04 11:50:21 +02:00
|
|
|
titlebar_update_geometry_floating(c);
|
2008-05-25 17:42:20 +02:00
|
|
|
if(!c->ismax)
|
|
|
|
c->f_geometry = geometry;
|
2008-05-25 08:25:51 +02:00
|
|
|
}
|
2008-01-06 14:40:23 +01:00
|
|
|
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_configure_window(globalconf.connection, c->win,
|
|
|
|
XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y |
|
|
|
|
XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT |
|
|
|
|
XCB_CONFIG_WINDOW_BORDER_WIDTH,
|
|
|
|
values);
|
2008-01-06 14:40:23 +01:00
|
|
|
window_configure(c->win, geometry, c->border);
|
|
|
|
|
2008-06-09 21:43:09 +02:00
|
|
|
if(c->screen != new_screen)
|
|
|
|
screen_client_moveto(c, new_screen, false);
|
|
|
|
|
2008-03-21 16:50:17 +01:00
|
|
|
resized = true;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
2008-03-26 11:03:52 +01:00
|
|
|
|
|
|
|
/* call it again like it was floating,
|
|
|
|
* we want it to be sticked to the window */
|
2008-06-09 21:43:09 +02:00
|
|
|
if(!c->ismoving && !c->isfloating && layout != layout_floating)
|
2008-06-18 14:04:24 +02:00
|
|
|
titlebar_update_geometry_floating(c);
|
2008-03-26 11:03:52 +01:00
|
|
|
|
|
|
|
return resized;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-06-05 09:25:38 +02:00
|
|
|
/** Set a clinet floating.
|
|
|
|
* \param c The client.
|
|
|
|
* \param floating Set floating, or not.
|
|
|
|
* \param layer Layer to put the floating window onto.
|
|
|
|
*/
|
2008-01-17 10:40:39 +01:00
|
|
|
void
|
2008-04-11 11:35:11 +02:00
|
|
|
client_setfloating(client_t *c, bool floating, layer_t layer)
|
2008-01-17 10:40:39 +01:00
|
|
|
{
|
|
|
|
if(c->isfloating != floating)
|
2008-01-17 19:17:53 +01:00
|
|
|
{
|
2008-01-17 10:40:39 +01:00
|
|
|
if((c->isfloating = floating))
|
2008-03-21 16:50:17 +01:00
|
|
|
client_resize(c, c->f_geometry, false);
|
2008-05-25 17:42:20 +02:00
|
|
|
else if(c->ismax)
|
|
|
|
{
|
|
|
|
c->ismax = false;
|
|
|
|
client_resize(c, c->m_geometry, false);
|
|
|
|
}
|
2008-06-09 21:43:09 +02:00
|
|
|
if(client_isvisible(c, c->screen))
|
|
|
|
globalconf.screens[c->screen].need_arrange = true;
|
|
|
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
2008-04-08 19:52:59 +02:00
|
|
|
if(floating)
|
|
|
|
{
|
|
|
|
c->oldlayer = c->layer;
|
|
|
|
c->layer = layer;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
c->layer = c->oldlayer;
|
2008-05-26 16:17:57 +02:00
|
|
|
client_raise(c);
|
2008-01-24 20:07:17 +01:00
|
|
|
client_saveprops(c);
|
2008-01-17 19:17:53 +01:00
|
|
|
}
|
2008-01-17 10:40:39 +01:00
|
|
|
}
|
|
|
|
|
2008-06-05 09:25:38 +02:00
|
|
|
/** Save client properties as an X property.
|
|
|
|
* \param c The client.
|
2007-12-30 15:08:38 +01:00
|
|
|
*/
|
2007-09-05 20:15:00 +02:00
|
|
|
void
|
2008-04-11 11:35:11 +02:00
|
|
|
client_saveprops(client_t *c)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-06-09 21:43:09 +02:00
|
|
|
int i = 0, ntags = 0;
|
2007-09-07 11:18:27 +02:00
|
|
|
char *prop;
|
2008-06-09 21:43:09 +02:00
|
|
|
tag_t *tag;
|
2008-06-05 09:25:38 +02:00
|
|
|
xutil_intern_atom_request_t atom_q;
|
|
|
|
|
|
|
|
atom_q = xutil_intern_atom(globalconf.connection, &globalconf.atoms, "_AWESOME_PROPERTIES");
|
2007-12-14 19:02:38 +01:00
|
|
|
|
2008-06-09 21:43:09 +02:00
|
|
|
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
|
|
|
|
ntags++;
|
2007-09-07 11:18:27 +02:00
|
|
|
|
2008-06-09 21:43:09 +02:00
|
|
|
prop = p_new(char, ntags + 3);
|
2007-09-06 22:02:50 +02:00
|
|
|
|
2008-06-09 21:43:09 +02:00
|
|
|
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next, i++)
|
|
|
|
prop[i] = is_client_tagged(c, tag) ? '1' : '0';
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2008-04-08 19:52:59 +02:00
|
|
|
prop[i] = c->isfloating ? '1' : '0';
|
|
|
|
|
|
|
|
sprintf(&prop[++i], "%d", c->layer);
|
2007-09-07 11:18:27 +02:00
|
|
|
|
|
|
|
prop[++i] = '\0';
|
|
|
|
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, c->win,
|
2008-06-05 09:25:38 +02:00
|
|
|
xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms, atom_q),
|
2008-03-21 16:50:17 +01:00
|
|
|
STRING, 8, i, (unsigned char *) prop);
|
2007-09-07 11:18:27 +02:00
|
|
|
|
|
|
|
p_delete(&prop);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-06-10 19:29:53 +02:00
|
|
|
/** Unban a client.
|
|
|
|
* \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-03-21 16:50:17 +01:00
|
|
|
xcb_map_window(globalconf.connection, c->win);
|
|
|
|
window_setstate(c->win, XCB_WM_NORMAL_STATE);
|
2008-06-04 11:50:21 +02:00
|
|
|
if(c->titlebar && c->titlebar->sw && c->titlebar->position)
|
|
|
|
xcb_map_window(globalconf.connection, c->titlebar->sw->window);
|
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
|
|
|
{
|
2008-06-09 21:43:09 +02:00
|
|
|
tag_t *tag;
|
|
|
|
|
2008-06-10 19:03:10 +02:00
|
|
|
/* call hook */
|
2008-06-18 18:31:35 +02:00
|
|
|
luaA_client_userdata_new(globalconf.L, c);
|
2008-06-10 19:03:10 +02:00
|
|
|
luaA_dofunction(globalconf.L, globalconf.hooks.unmanage, 1);
|
|
|
|
|
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-03-21 16:50:17 +01:00
|
|
|
xcb_configure_window(globalconf.connection, c->win,
|
|
|
|
XCB_CONFIG_WINDOW_BORDER_WIDTH,
|
|
|
|
(uint32_t *) &c->oldborder);
|
2008-01-06 21:57:53 +01:00
|
|
|
|
|
|
|
/* remove client everywhere */
|
2008-01-12 17:01:21 +01:00
|
|
|
client_list_detach(&globalconf.clients, c);
|
2008-05-23 22:40:17 +02:00
|
|
|
focus_client_delete(c);
|
2008-05-25 19:30:54 +02:00
|
|
|
stack_client_delete(c);
|
2008-06-09 21:43:09 +02:00
|
|
|
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
|
|
|
|
untag_client(c, tag);
|
2008-01-06 21:57:53 +01:00
|
|
|
|
|
|
|
if(globalconf.focus->client == c)
|
2008-06-09 21:43:09 +02:00
|
|
|
client_focus(NULL, c->screen);
|
2008-01-06 21:57:53 +01:00
|
|
|
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_ungrab_button(globalconf.connection, XCB_BUTTON_INDEX_ANY, c->win, ANY_MODIFIER);
|
|
|
|
window_setstate(c->win, XCB_WM_WITHDRAWN_STATE);
|
2008-01-06 21:57:53 +01:00
|
|
|
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_aux_sync(globalconf.connection);
|
|
|
|
xcb_ungrab_server(globalconf.connection);
|
2008-01-06 21:57:53 +01:00
|
|
|
|
2008-06-04 11:50:21 +02:00
|
|
|
if(c->titlebar)
|
2008-06-03 18:41:54 +02:00
|
|
|
{
|
2008-06-04 11:50:21 +02:00
|
|
|
simplewindow_delete(&c->titlebar->sw);
|
|
|
|
titlebar_unref(&c->titlebar);
|
2008-06-03 18:41:54 +02:00
|
|
|
}
|
2008-03-14 14:27:56 +01:00
|
|
|
|
2008-06-17 23:20:03 +02:00
|
|
|
ewmh_update_net_client_list(c->phys_screen);
|
|
|
|
|
2007-09-05 20:15:00 +02:00
|
|
|
p_delete(&c);
|
|
|
|
}
|
|
|
|
|
2008-06-05 09:25:38 +02:00
|
|
|
/** Update the WM hints of a client.
|
|
|
|
* \param c The client.
|
|
|
|
*/
|
2007-12-23 15:16:10 +01:00
|
|
|
void
|
2008-04-11 11:35:11 +02:00
|
|
|
client_updatewmhints(client_t *c)
|
2007-12-23 15:16:10 +01:00
|
|
|
{
|
2008-03-26 19:58:30 +01:00
|
|
|
xcb_wm_hints_t *wmh = NULL;
|
2008-06-05 09:25:38 +02:00
|
|
|
uint32_t wm_hints_flags;
|
2007-12-23 15:16:10 +01:00
|
|
|
|
2008-03-21 16:50:17 +01:00
|
|
|
if((wmh = xcb_get_wm_hints(globalconf.connection, c->win)))
|
2007-12-23 15:16:10 +01:00
|
|
|
{
|
2008-06-05 09:25:38 +02:00
|
|
|
wm_hints_flags = xcb_wm_hints_get_flags(wmh);
|
2008-05-28 11:08:48 +02:00
|
|
|
if((c->isurgent = (wm_hints_flags & XCB_WM_X_URGENCY_HINT)))
|
2008-04-04 10:26:46 +02:00
|
|
|
{
|
2008-05-28 11:08:48 +02:00
|
|
|
/* execute hook */
|
2008-06-18 18:31:35 +02:00
|
|
|
luaA_client_userdata_new(globalconf.L, c);
|
2008-05-28 11:08:48 +02:00
|
|
|
luaA_dofunction(globalconf.L, globalconf.hooks.urgent, 1);
|
2008-06-05 09:25:38 +02:00
|
|
|
|
2008-06-09 21:43:09 +02:00
|
|
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
2008-04-04 10:26:46 +02:00
|
|
|
}
|
2008-04-27 13:26:39 +02:00
|
|
|
if((wm_hints_flags & XCB_WM_STATE_HINT) &&
|
|
|
|
(xcb_wm_hints_get_initial_state(wmh) == XCB_WM_WITHDRAWN_STATE))
|
2008-01-14 14:18:29 +01:00
|
|
|
{
|
2008-06-05 09:25:38 +02:00
|
|
|
client_setborder(c, 0);
|
2008-03-21 16:50:17 +01:00
|
|
|
c->skip = true;
|
2008-01-14 14:18:29 +01:00
|
|
|
}
|
2008-04-09 16:12:15 +02:00
|
|
|
xcb_free_wm_hints(wmh);
|
2007-12-23 15:16:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-05 09:25:38 +02:00
|
|
|
/** Update the size hintz of a client.
|
2008-06-20 08:32:46 +02:00
|
|
|
* \param c The client.
|
2008-06-05 09:25:38 +02:00
|
|
|
* \return A pointer to a xcb_size_hints_t.
|
|
|
|
*/
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_size_hints_t *
|
2008-04-11 11:35:11 +02:00
|
|
|
client_updatesizehints(client_t *c)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
long msize;
|
2008-06-05 09:25:38 +02:00
|
|
|
xcb_size_hints_t *size;
|
|
|
|
uint32_t size_flags;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2008-04-09 16:12:15 +02:00
|
|
|
if(!(size = xcb_get_wm_normal_hints(globalconf.connection, c->win, &msize)))
|
2008-03-21 16:50:17 +01:00
|
|
|
return NULL;
|
2008-02-01 10:42:16 +01:00
|
|
|
|
2008-06-05 09:25:38 +02:00
|
|
|
size_flags = xcb_size_hints_get_flags(size);
|
2008-04-27 13:26:39 +02:00
|
|
|
|
|
|
|
if((size_flags & XCB_SIZE_P_SIZE_HINT))
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_size_hints_get_base_size(size, &c->basew, &c->baseh);
|
2008-04-27 13:26:39 +02:00
|
|
|
else if((size_flags & XCB_SIZE_P_MIN_SIZE_HINT))
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_size_hints_get_min_size(size, &c->basew, &c->baseh);
|
2007-09-05 20:15:00 +02:00
|
|
|
else
|
|
|
|
c->basew = c->baseh = 0;
|
2008-04-27 13:26:39 +02:00
|
|
|
if((size_flags & XCB_SIZE_P_RESIZE_INC_HINT))
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_size_hints_get_increase(size, &c->incw, &c->inch);
|
2007-09-05 20:15:00 +02:00
|
|
|
else
|
|
|
|
c->incw = c->inch = 0;
|
|
|
|
|
2008-04-27 13:26:39 +02:00
|
|
|
if((size_flags & XCB_SIZE_P_MAX_SIZE_HINT))
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_size_hints_get_max_size(size, &c->maxw, &c->maxh);
|
2007-09-05 20:15:00 +02:00
|
|
|
else
|
|
|
|
c->maxw = c->maxh = 0;
|
|
|
|
|
2008-04-27 13:26:39 +02:00
|
|
|
if((size_flags & XCB_SIZE_P_MIN_SIZE_HINT))
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_size_hints_get_min_size(size, &c->minw, &c->minh);
|
2008-04-27 13:26:39 +02:00
|
|
|
else if((size_flags & XCB_SIZE_BASE_SIZE_HINT))
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_size_hints_get_base_size(size, &c->minw, &c->minh);
|
2007-09-05 20:15:00 +02:00
|
|
|
else
|
|
|
|
c->minw = c->minh = 0;
|
|
|
|
|
2008-04-27 13:26:39 +02:00
|
|
|
if((size_flags & XCB_SIZE_P_ASPECT_HINT))
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_size_hints_get_min_aspect(size, &c->minax, &c->minay);
|
|
|
|
xcb_size_hints_get_max_aspect(size, &c->maxax, &c->maxay);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
c->minax = c->maxax = c->minay = c->maxay = 0;
|
|
|
|
|
2007-12-28 20:48:29 +01:00
|
|
|
if(c->maxw && c->minw && c->maxh && c->minh
|
|
|
|
&& c->maxw == c->minw && c->maxh == c->minh)
|
2008-03-21 16:50:17 +01:00
|
|
|
c->isfixed = true;
|
2008-02-01 10:42:16 +01:00
|
|
|
|
2008-06-18 13:56:03 +02:00
|
|
|
c->hassizehints = !(!c->basew && !c->baseh && !c->incw && !c->inch
|
|
|
|
&& !c->maxw && !c->maxh && !c->minw && !c->minh
|
|
|
|
&& !c->minax && !c->maxax && !c->minax && !c->minay);
|
2008-03-21 16:50:17 +01:00
|
|
|
return size;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-06-22 17:45:45 +02:00
|
|
|
/** Markup parsing hook.
|
|
|
|
* For now only substitute <title />
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
client_markup_on_elem(markup_parser_data_t *p, const char *elem,
|
|
|
|
const char **names, const char **values)
|
|
|
|
{
|
|
|
|
assert (!strcmp(elem, "title"));
|
|
|
|
buffer_add_xmlescaped(&p->text, p->priv);
|
|
|
|
}
|
|
|
|
|
2008-06-05 09:25:38 +02:00
|
|
|
/** Parse a markup string which contains special markup sequence relative to a
|
|
|
|
* client, i.e. its title, etc.
|
|
|
|
* \param c The client concerned by the markup string.
|
|
|
|
* \param str The markup string.
|
|
|
|
* \param len The string length.
|
|
|
|
*/
|
2008-04-28 12:23:10 +02:00
|
|
|
char *
|
|
|
|
client_markup_parse(client_t *c, const char *str, ssize_t len)
|
|
|
|
{
|
2008-06-22 17:45:45 +02:00
|
|
|
static char const * const elements[] = { "title", NULL };
|
|
|
|
markup_parser_data_t p = {
|
|
|
|
.elements = elements,
|
|
|
|
.priv = c->name,
|
|
|
|
.on_element = client_markup_on_elem,
|
|
|
|
};
|
2008-04-28 17:00:26 +02:00
|
|
|
char *ret;
|
2008-04-28 12:23:10 +02:00
|
|
|
|
2008-06-22 17:45:45 +02:00
|
|
|
markup_parser_data_init(&p);
|
2008-04-28 12:23:10 +02:00
|
|
|
|
2008-06-22 16:17:12 +02:00
|
|
|
if(markup_parse(&p, str, len))
|
|
|
|
ret = buffer_detach(&p.text);
|
2008-04-28 17:00:26 +02:00
|
|
|
else
|
2008-04-28 22:22:38 +02:00
|
|
|
ret = a_strdup(str);
|
2008-04-28 12:23:10 +02:00
|
|
|
|
2008-06-22 16:17:12 +02:00
|
|
|
markup_parser_data_wipe(&p);
|
2008-04-28 17:00:26 +02:00
|
|
|
|
|
|
|
return ret;
|
2008-04-28 12:23:10 +02:00
|
|
|
}
|
|
|
|
|
2008-03-31 20:07:13 +02:00
|
|
|
/** Kill a client via a WM_DELETE_WINDOW request or XKillClient if not
|
|
|
|
* 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-03-21 16:50:17 +01:00
|
|
|
xcb_client_message_event_t ev;
|
2008-06-15 20:37:34 +02:00
|
|
|
xutil_intern_atom_request_t wm_protocols_q, wm_delete_window_q;
|
2007-10-01 20:42:59 +02:00
|
|
|
|
2008-06-05 09:25:38 +02:00
|
|
|
if(window_isprotodel(c->win))
|
2007-10-01 20:42:59 +02:00
|
|
|
{
|
2008-06-15 20:37:34 +02:00
|
|
|
wm_protocols_q = xutil_intern_atom(globalconf.connection, &globalconf.atoms, "WM_PROTOCOLS");
|
|
|
|
wm_delete_window_q = xutil_intern_atom(globalconf.connection, &globalconf.atoms, "WM_DELETE_WINDOW");
|
|
|
|
|
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-15 20:37:34 +02:00
|
|
|
ev.type = xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms, wm_protocols_q);
|
|
|
|
ev.data.data32[0] = xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms, wm_delete_window_q);
|
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.
|
|
|
|
* \luastack
|
|
|
|
* \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-05-23 13:17:02 +02:00
|
|
|
int i = 1;
|
2008-05-23 22:49:39 +02:00
|
|
|
client_t *c;
|
2007-12-27 20:49:38 +01:00
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
lua_newtable(L);
|
|
|
|
|
|
|
|
for(c = globalconf.clients; c; c = c->next)
|
2008-05-23 13:17:02 +02:00
|
|
|
{
|
2008-06-18 18:31:35 +02:00
|
|
|
luaA_client_userdata_new(globalconf.L, c);
|
2008-05-23 13:17:02 +02:00
|
|
|
lua_rawseti(L, -2, i++);
|
|
|
|
}
|
|
|
|
|
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-06-05 09:25:38 +02:00
|
|
|
/** Add mouse bindings over clients's window.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \luastack
|
2008-06-13 15:35:47 +02:00
|
|
|
* \lvalue A client.
|
|
|
|
* \lparam A button binding.
|
2008-06-05 09:25:38 +02:00
|
|
|
*/
|
2008-05-20 15:39:47 +02:00
|
|
|
static int
|
2008-06-13 15:35:47 +02:00
|
|
|
luaA_client_mouse_add(lua_State *L)
|
2008-01-01 17:37:16 +01:00
|
|
|
{
|
2008-06-13 15:35:47 +02:00
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
|
|
|
button_t **b = luaA_checkudata(L, 2, "mouse");
|
|
|
|
button_list_push(&(*c)->buttons, *b);
|
|
|
|
button_ref(b);
|
|
|
|
return 0;
|
|
|
|
}
|
2008-05-20 15:39:47 +02:00
|
|
|
|
2008-06-13 15:35:47 +02:00
|
|
|
/** Remove mouse bindings over clients's window.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \luastack
|
|
|
|
* \lvalue A client.
|
|
|
|
* \lparam A button binding.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_client_mouse_remove(lua_State *L)
|
|
|
|
{
|
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
|
|
|
button_t **b = luaA_checkudata(L, 1, "mouse");
|
|
|
|
button_list_detach(&(*c)->buttons, *b);
|
|
|
|
button_unref(b);
|
2008-05-20 15:39:47 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-05 09:25:38 +02:00
|
|
|
/** Get only visible clients for a screen.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \param L The Lua VM state.
|
2008-06-10 20:48:38 +02:00
|
|
|
* \luastack
|
2008-06-10 19:29:53 +02:00
|
|
|
* \lparam A screen number.
|
|
|
|
* \lreturn A table with all visible clients for this screen.
|
2008-06-05 09:25:38 +02:00
|
|
|
*/
|
2008-05-20 15:39:47 +02:00
|
|
|
static int
|
|
|
|
luaA_client_visible_get(lua_State *L)
|
|
|
|
{
|
2008-05-23 13:17:02 +02:00
|
|
|
int i = 1;
|
2008-05-23 22:49:39 +02:00
|
|
|
client_t *c;
|
2008-05-20 15:39:47 +02:00
|
|
|
int screen = luaL_checknumber(L, 1) - 1;
|
|
|
|
|
|
|
|
luaA_checkscreen(screen);
|
|
|
|
|
|
|
|
lua_newtable(L);
|
|
|
|
|
|
|
|
for(c = globalconf.clients; c; c = c->next)
|
2008-06-09 18:24:12 +02:00
|
|
|
if(!c->skip && !c->ishidden && client_isvisible(c, screen))
|
2008-05-20 15:39:47 +02:00
|
|
|
{
|
2008-06-18 18:31:35 +02:00
|
|
|
luaA_client_userdata_new(globalconf.L, c);
|
2008-05-20 15:39:47 +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;
|
2008-01-01 17:37:16 +01:00
|
|
|
}
|
|
|
|
|
2008-06-05 09:25:38 +02:00
|
|
|
/** Get the currently focused client.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \param L The Lua VM state.
|
2008-06-10 20:48:38 +02:00
|
|
|
* \luastack
|
2008-06-10 19:29:53 +02:00
|
|
|
* \lreturn The currently focused client.
|
2008-06-05 09:25:38 +02:00
|
|
|
*/
|
2008-05-20 15:39:47 +02:00
|
|
|
static int
|
2008-05-23 22:49:39 +02:00
|
|
|
luaA_client_focus_get(lua_State *L __attribute__ ((unused)))
|
2008-01-01 17:37:16 +01:00
|
|
|
{
|
2008-06-05 09:25:38 +02:00
|
|
|
if(globalconf.focus->client)
|
2008-06-18 18:31:35 +02:00
|
|
|
return luaA_client_userdata_new(globalconf.L, globalconf.focus->client);
|
2008-06-05 09:25:38 +02:00
|
|
|
return 0;
|
2008-05-20 15:39:47 +02:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
if((c->noborder && width > 0) || width == c->border || width < 0)
|
2008-05-28 14:33:45 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
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-06-09 21:43:09 +02:00
|
|
|
globalconf.screens[c->screen].need_arrange = true;
|
2008-05-28 14:33:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Set the client border width and color.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \param L The Lua VM state.
|
2008-06-10 20:48:38 +02:00
|
|
|
* \luastack
|
2008-06-11 02:46:30 +02:00
|
|
|
* \lvalue A client.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \lparam A table with `width' key for the border width in pixel and `color' key
|
2008-05-29 09:50:49 +02:00
|
|
|
* for the border color.
|
2008-05-28 14:33:45 +02:00
|
|
|
*/
|
2008-05-20 15:39:47 +02:00
|
|
|
static int
|
|
|
|
luaA_client_border_set(lua_State *L)
|
|
|
|
{
|
2008-06-04 18:27:10 +02:00
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
2008-06-11 08:12:38 +02:00
|
|
|
int width = luaA_getopt_number(L, 2, "width", (*c)->border);
|
2008-05-20 15:39:47 +02:00
|
|
|
const char *colorstr = luaA_getopt_string(L, 2, "color", NULL);
|
|
|
|
xcolor_t color;
|
|
|
|
|
2008-05-28 14:33:45 +02:00
|
|
|
client_setborder(*c, width);
|
2008-05-20 15:39:47 +02:00
|
|
|
|
|
|
|
if(colorstr
|
2008-05-30 12:34:38 +02:00
|
|
|
&& xcolor_new(globalconf.connection, (*c)->phys_screen, colorstr, &color))
|
2008-05-20 15:39:47 +02:00
|
|
|
xcb_change_window_attributes(globalconf.connection, (*c)->win, XCB_CW_BORDER_PIXEL,
|
|
|
|
&color.pixel);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-09 21:43:09 +02:00
|
|
|
/** Move the client to another screen.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \param L The Lua VM state.
|
2008-06-10 20:48:38 +02:00
|
|
|
* \luastack
|
2008-06-11 02:46:30 +02:00
|
|
|
* \lvalue A client.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \lparam A screen number.
|
2008-06-09 21:43:09 +02:00
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_client_screen_set(lua_State *L)
|
|
|
|
{
|
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
|
|
|
int screen = luaL_checknumber(L, 2) - 1;
|
|
|
|
luaA_checkscreen(screen);
|
|
|
|
screen_client_moveto(*c, screen, true);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Get the screen number the client is onto.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \param L The Lua VM state.
|
2008-06-10 20:48:38 +02:00
|
|
|
* \luastack
|
2008-06-11 02:46:30 +02:00
|
|
|
* \lvalue A client.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \lreturn A screen number.
|
2008-06-09 21:43:09 +02:00
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_client_screen_get(lua_State *L)
|
|
|
|
{
|
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
|
|
|
lua_pushnumber(L, 1 + (*c)->screen);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Tag a client with a specified tag.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \param L The Lua VM state.
|
2008-06-10 20:48:38 +02:00
|
|
|
* \luastack
|
2008-06-11 02:46:30 +02:00
|
|
|
* \lvalue A client.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \lparam A tag object.
|
|
|
|
* \lparam A boolean value: true to add this tag to clients, false to remove.
|
2008-06-05 09:25:38 +02:00
|
|
|
*/
|
2008-05-20 15:39:47 +02:00
|
|
|
static int
|
2008-06-09 21:43:09 +02:00
|
|
|
luaA_client_tag(lua_State *L)
|
2008-01-17 14:16:45 +01:00
|
|
|
{
|
2008-06-04 18:27:10 +02:00
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
2008-06-09 21:43:09 +02:00
|
|
|
tag_t **tag = luaA_checkudata(L, 2, "tag");
|
|
|
|
bool tag_the_client = luaA_checkboolean(L, 3);
|
|
|
|
|
|
|
|
if((*tag)->screen != (*c)->screen)
|
|
|
|
luaL_error(L, "tag and client are on different screens");
|
|
|
|
|
|
|
|
if(tag_the_client)
|
|
|
|
tag_client(*c, *tag);
|
|
|
|
else
|
|
|
|
untag_client(*c, *tag);
|
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2008-05-03 12:17:49 +02:00
|
|
|
|
2008-06-09 21:43:09 +02:00
|
|
|
/** Check if a client is tagged with the specified tag.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \param L The Lua VM state.
|
2008-06-10 20:48:38 +02:00
|
|
|
* \luastack
|
2008-06-11 02:46:30 +02:00
|
|
|
* \lvalue A client.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \lparam A tag object.
|
|
|
|
* \lreturn A boolean value, true if the client is tagged with this tag, false
|
2008-06-09 21:43:09 +02:00
|
|
|
* otherwise.
|
2008-06-05 09:25:38 +02:00
|
|
|
*/
|
2008-05-20 15:39:47 +02:00
|
|
|
static int
|
2008-06-09 21:43:09 +02:00
|
|
|
luaA_client_istagged(lua_State *L)
|
2008-05-20 15:39:47 +02:00
|
|
|
{
|
2008-06-04 18:27:10 +02:00
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
2008-06-09 21:43:09 +02:00
|
|
|
tag_t **tag = luaA_checkudata(L, 2, "tag");
|
|
|
|
lua_pushboolean(L, is_client_tagged(*c, *tag));
|
|
|
|
return 1;
|
2008-05-20 15:39:47 +02:00
|
|
|
}
|
2008-05-02 16:11:21 +02:00
|
|
|
|
2008-06-05 09:25:38 +02:00
|
|
|
/** Get the client coordinates on the display.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \param L The Lua VM state.
|
2008-06-10 20:48:38 +02:00
|
|
|
* \luastack
|
2008-06-11 02:46:30 +02:00
|
|
|
* \lvalue A client.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \lreturn A table with keys `width', `height', `x' and `y'.
|
2008-06-05 09:25:38 +02:00
|
|
|
*/
|
2008-05-20 15:39:47 +02:00
|
|
|
static int
|
|
|
|
luaA_client_coords_get(lua_State *L)
|
|
|
|
{
|
2008-06-04 18:27:10 +02:00
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
2008-05-20 15:39:47 +02:00
|
|
|
lua_newtable(L);
|
|
|
|
lua_pushnumber(L, (*c)->geometry.width);
|
|
|
|
lua_setfield(L, -2, "width");
|
|
|
|
lua_pushnumber(L, (*c)->geometry.height);
|
|
|
|
lua_setfield(L, -2, "height");
|
|
|
|
lua_pushnumber(L, (*c)->geometry.x);
|
|
|
|
lua_setfield(L, -2, "x");
|
|
|
|
lua_pushnumber(L, (*c)->geometry.y);
|
|
|
|
lua_setfield(L, -2, "y");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-06-10 19:29:53 +02:00
|
|
|
/** Set client coordinates. This only operates if the client is floating.
|
|
|
|
* \param L The Lua VM state.
|
2008-06-10 20:48:38 +02:00
|
|
|
* \luastack
|
2008-06-11 02:46:30 +02:00
|
|
|
* \lvalue A client.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \lparam A table with keys: x, y, width, height.
|
|
|
|
*/
|
2008-05-20 15:39:47 +02:00
|
|
|
static int
|
|
|
|
luaA_client_coords_set(lua_State *L)
|
|
|
|
{
|
2008-06-04 18:27:10 +02:00
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
2008-05-20 15:39:47 +02:00
|
|
|
area_t geometry;
|
2008-05-23 13:17:02 +02:00
|
|
|
|
2008-06-09 21:43:09 +02:00
|
|
|
if((*c)->isfloating || layout_get_current((*c)->screen) == layout_floating)
|
2008-05-20 15:39:47 +02:00
|
|
|
{
|
|
|
|
luaA_checktable(L, 2);
|
|
|
|
geometry.x = luaA_getopt_number(L, 2, "x", (*c)->geometry.x);
|
|
|
|
geometry.y = luaA_getopt_number(L, 2, "y", (*c)->geometry.y);
|
|
|
|
geometry.width = luaA_getopt_number(L, 2, "width", (*c)->geometry.width);
|
|
|
|
geometry.height = luaA_getopt_number(L, 2, "height", (*c)->geometry.height);
|
|
|
|
client_resize(*c, geometry, false);
|
|
|
|
}
|
2008-05-02 16:11:21 +02:00
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
return 0;
|
2008-01-17 14:16:45 +01:00
|
|
|
}
|
|
|
|
|
2008-06-10 19:29:53 +02:00
|
|
|
/** Set the client opacity.
|
|
|
|
* Note: this requires an external composite manager.
|
|
|
|
* \param L The Lua VM state.
|
2008-06-10 20:48:38 +02:00
|
|
|
* \luastack
|
2008-06-11 02:46:30 +02:00
|
|
|
* \lvalue A client.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \lparam A floating value between 0 and 1.
|
|
|
|
*/
|
2008-05-20 15:39:47 +02:00
|
|
|
static int
|
|
|
|
luaA_client_opacity_set(lua_State *L)
|
2008-02-06 08:49:31 +01:00
|
|
|
{
|
2008-06-04 18:27:10 +02:00
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
2008-05-20 15:39:47 +02:00
|
|
|
double opacity = luaL_checknumber(L, 2);
|
2008-02-06 08:49:31 +01:00
|
|
|
|
2008-06-10 19:29:53 +02:00
|
|
|
if(opacity == -1 || (opacity >= 0 && opacity <= 1))
|
2008-05-20 15:39:47 +02:00
|
|
|
window_settrans((*c)->win, opacity);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2008-06-04 18:27:10 +02:00
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
2008-05-20 15:39:47 +02:00
|
|
|
client_kill(*c);
|
|
|
|
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)
|
|
|
|
{
|
2008-06-04 18:27:10 +02:00
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
|
|
|
client_t **swap = luaA_checkudata(L, 2, "client");
|
2008-05-20 15:39:47 +02:00
|
|
|
client_list_swap(&globalconf.clients, *swap, *c);
|
2008-06-09 21:43:09 +02:00
|
|
|
globalconf.screens[(*c)->screen].need_arrange = true;
|
|
|
|
globalconf.screens[(*swap)->screen].need_arrange = true;
|
|
|
|
widget_invalidate_cache((*c)->screen, WIDGET_CACHE_CLIENTS);
|
|
|
|
widget_invalidate_cache((*swap)->screen, WIDGET_CACHE_CLIENTS);
|
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
|
|
|
/** Focus 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_focus_set(lua_State *L)
|
2008-05-11 18:41:04 +02:00
|
|
|
{
|
2008-06-04 18:27:10 +02:00
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
2008-06-09 21:43:09 +02:00
|
|
|
client_focus(*c, (*c)->screen);
|
2008-05-26 16:17:57 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 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)
|
|
|
|
{
|
2008-06-04 18:27:10 +02:00
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
2008-05-26 16:17:57 +02:00
|
|
|
client_raise(*c);
|
2008-05-20 15:39:47 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2008-05-11 18:41:04 +02:00
|
|
|
|
2008-06-10 19:29:53 +02:00
|
|
|
/** Set the client floating attribute.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \luastack
|
2008-06-11 02:46:30 +02:00
|
|
|
* \lparam A client.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \lparam A boolean, true to set, false to unset.
|
|
|
|
*/
|
2008-05-20 15:39:47 +02:00
|
|
|
static int
|
|
|
|
luaA_client_floating_set(lua_State *L)
|
|
|
|
{
|
2008-06-04 18:27:10 +02:00
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
2008-05-20 15:39:47 +02:00
|
|
|
bool f = luaA_checkboolean(L, 2);
|
|
|
|
client_setfloating(*c, f, (*c)->layer == LAYER_FLOAT ? LAYER_TILE : LAYER_FLOAT);
|
|
|
|
return 0;
|
2008-05-11 18:41:04 +02:00
|
|
|
}
|
|
|
|
|
2008-06-10 19:29:53 +02:00
|
|
|
/** Check if a client has the floating attribute.
|
|
|
|
* \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
|
|
|
* \lreturn A boolean, true if the client has the floating attribute set, false
|
|
|
|
* otherwise.
|
|
|
|
*/
|
2008-05-20 15:39:47 +02:00
|
|
|
static int
|
|
|
|
luaA_client_floating_get(lua_State *L)
|
2008-02-06 08:49:31 +01:00
|
|
|
{
|
2008-06-04 18:27:10 +02:00
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
2008-05-20 15:39:47 +02:00
|
|
|
lua_pushboolean(L, (*c)->isfloating);
|
|
|
|
return 1;
|
2008-02-06 08:49:31 +01:00
|
|
|
}
|
2008-03-15 13:59:04 +01:00
|
|
|
|
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)
|
|
|
|
{
|
2008-06-04 18:27:10 +02:00
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
2008-05-20 15:39:47 +02:00
|
|
|
xcb_unmap_window(globalconf.connection, (*c)->win);
|
|
|
|
xcb_map_window(globalconf.connection, (*c)->win);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-10 19:29:53 +02:00
|
|
|
/** Return a formated string for a client.
|
|
|
|
* \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
|
|
|
* \lreturn A string.
|
|
|
|
*/
|
2008-05-20 15:39:47 +02:00
|
|
|
static int
|
|
|
|
luaA_client_tostring(lua_State *L)
|
|
|
|
{
|
2008-06-04 18:27:10 +02:00
|
|
|
client_t **p = luaA_checkudata(L, 1, "client");
|
2008-05-20 15:39:47 +02:00
|
|
|
lua_pushfstring(L, "[client udata(%p) name(%s)]", *p, (*p)->name);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-06-05 04:48:05 +02:00
|
|
|
/** Get the client name.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \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
|
|
|
* \lreturn A string with the client class.
|
2008-06-05 04:48:05 +02:00
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_client_class_get(lua_State *L)
|
|
|
|
{
|
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
|
|
|
class_hint_t *hint=xutil_get_class_hint(globalconf.connection, (*c)->win);
|
|
|
|
if (hint)
|
|
|
|
lua_pushstring(L, hint->res_class);
|
|
|
|
else
|
|
|
|
luaL_error(L, "Unable to get the class property for client");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-06-10 19:29:53 +02:00
|
|
|
/** Set the default icon for this client.
|
|
|
|
* \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 path to an icon image, or nil to remove.
|
|
|
|
*/
|
2008-05-20 22:37:08 +02:00
|
|
|
static int
|
|
|
|
luaA_client_icon_set(lua_State *L)
|
|
|
|
{
|
2008-06-04 18:27:10 +02:00
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
2008-05-20 22:37:08 +02:00
|
|
|
const char *icon = luaL_optstring(L, 2, NULL);
|
|
|
|
|
|
|
|
p_delete(&(*c)->icon_path);
|
|
|
|
(*c)->icon_path = a_strdup(icon);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-04 11:50:21 +02:00
|
|
|
/** Get the client name.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \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
|
|
|
* \lreturn A string with the client name.
|
2008-06-04 11:50:21 +02:00
|
|
|
*/
|
2008-05-23 13:49:59 +02:00
|
|
|
static int
|
|
|
|
luaA_client_name_get(lua_State *L)
|
|
|
|
{
|
2008-06-04 18:27:10 +02:00
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
2008-05-23 13:49:59 +02:00
|
|
|
lua_pushstring(L, (*c)->name);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-06-04 11:50:21 +02:00
|
|
|
/** Change the client name. It'll change it only from awesome point of view.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \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 string with the new client name.
|
2008-06-04 11:50:21 +02:00
|
|
|
*/
|
2008-05-25 17:51:45 +02:00
|
|
|
static int
|
|
|
|
luaA_client_name_set(lua_State *L)
|
|
|
|
{
|
2008-06-04 18:27:10 +02:00
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
2008-05-25 17:51:45 +02:00
|
|
|
const char *name = luaL_checkstring(L, 2);
|
|
|
|
p_delete(&(*c)->name);
|
2008-06-10 07:32:35 +02:00
|
|
|
a_iso2utf8(name, &(*c)->name);
|
2008-05-25 17:51:45 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-04 11:50:21 +02:00
|
|
|
/** Set the client's titlebar.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \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 titlebar.
|
2008-06-04 11:50:21 +02:00
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_client_titlebar_set(lua_State *L)
|
|
|
|
{
|
2008-06-04 18:27:10 +02:00
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
2008-06-10 19:35:38 +02:00
|
|
|
titlebar_t **t = NULL;
|
|
|
|
|
2008-06-10 20:32:26 +02:00
|
|
|
if(lua_gettop(L) == 2 && !lua_isnil(L, 2))
|
2008-06-10 19:35:38 +02:00
|
|
|
{
|
|
|
|
t = luaA_checkudata(L, 2, "titlebar");
|
|
|
|
if(client_getbytitlebar(*t))
|
|
|
|
luaL_error(L, "titlebar is already used by another client");
|
|
|
|
}
|
2008-06-04 11:50:21 +02:00
|
|
|
|
|
|
|
/* If client had a titlebar, unref it */
|
|
|
|
if((*c)->titlebar)
|
2008-06-10 19:35:38 +02:00
|
|
|
{
|
|
|
|
simplewindow_delete(&(*c)->titlebar->sw);
|
2008-06-11 07:38:40 +02:00
|
|
|
titlebar_unref(&(*c)->titlebar);
|
2008-06-10 19:35:38 +02:00
|
|
|
}
|
2008-06-04 11:50:21 +02:00
|
|
|
|
2008-06-10 19:35:38 +02:00
|
|
|
if(t)
|
|
|
|
{
|
|
|
|
/* Attach titlebar to client */
|
|
|
|
(*c)->titlebar = *t;
|
|
|
|
titlebar_ref(t);
|
|
|
|
titlebar_init(*c);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
(*c)->titlebar = NULL;
|
2008-06-04 11:50:21 +02:00
|
|
|
|
2008-06-09 21:43:09 +02:00
|
|
|
if((*c)->isfloating || layout_get_current((*c)->screen) == layout_floating)
|
2008-06-04 11:50:21 +02:00
|
|
|
titlebar_update_geometry_floating(*c);
|
|
|
|
else
|
2008-06-09 21:43:09 +02:00
|
|
|
globalconf.screens[(*c)->screen].need_arrange = true;
|
2008-06-04 11:50:21 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-04 13:36:13 +02:00
|
|
|
/** Get the titlebar of a client.
|
2008-06-10 19:29:53 +02:00
|
|
|
* \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
|
|
|
* \lreturn A titlebar or nil if the client has no titlebar.
|
2008-06-04 13:36:13 +02:00
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_client_titlebar_get(lua_State *L)
|
|
|
|
{
|
2008-06-04 18:27:10 +02:00
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
2008-06-04 13:36:13 +02:00
|
|
|
|
|
|
|
if((*c)->titlebar)
|
2008-06-18 18:31:35 +02:00
|
|
|
return luaA_titlebar_userdata_new(globalconf.L, (*c)->titlebar);
|
2008-06-04 13:36:13 +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-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)
|
|
|
|
{
|
2008-06-04 18:27:10 +02:00
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
2008-06-02 08:31:54 +02:00
|
|
|
client_unmanage(*c);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-09 18:24:12 +02:00
|
|
|
/** Hide a client.
|
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-06-09 18:24:12 +02:00
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_client_hide(lua_State *L)
|
|
|
|
{
|
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
|
|
|
(*c)->ishidden = true;
|
2008-06-09 21:43:09 +02:00
|
|
|
globalconf.screens[(*c)->screen].need_arrange = true;
|
2008-06-09 18:24:12 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Unhide a client.
|
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-06-09 18:24:12 +02:00
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_client_unhide(lua_State *L)
|
|
|
|
{
|
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
|
|
|
(*c)->ishidden = false;
|
2008-06-09 21:43:09 +02:00
|
|
|
globalconf.screens[(*c)->screen].need_arrange = true;
|
2008-06-09 18:24:12 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-10 19:17:12 +02:00
|
|
|
/** Guess if a client has been hidden.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
*
|
|
|
|
* \luastack
|
2008-06-11 02:46:30 +02:00
|
|
|
* \lvalue A client.
|
2008-06-10 19:17:12 +02:00
|
|
|
* \lreturn A boolean, true if the client has been hidden with hide(), false
|
|
|
|
* otherwise.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_client_ishidden(lua_State *L)
|
|
|
|
{
|
|
|
|
client_t **c = luaA_checkudata(L, 1, "client");
|
|
|
|
lua_pushboolean(L, (*c)->ishidden);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
const struct luaL_reg awesome_client_methods[] =
|
|
|
|
{
|
|
|
|
{ "get", luaA_client_get },
|
|
|
|
{ "focus_get", luaA_client_focus_get },
|
|
|
|
{ "visible_get", luaA_client_visible_get },
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
const struct luaL_reg awesome_client_meta[] =
|
|
|
|
{
|
2008-06-04 11:50:21 +02:00
|
|
|
{ "titlebar_set", luaA_client_titlebar_set },
|
2008-06-04 13:36:13 +02:00
|
|
|
{ "titlebar_get", luaA_client_titlebar_get },
|
2008-05-23 13:49:59 +02:00
|
|
|
{ "name_get", luaA_client_name_get },
|
2008-05-25 17:51:45 +02:00
|
|
|
{ "name_set", luaA_client_name_set },
|
2008-06-09 21:43:09 +02:00
|
|
|
{ "screen_set", luaA_client_screen_set },
|
|
|
|
{ "screen_get", luaA_client_screen_get },
|
2008-05-20 15:39:47 +02:00
|
|
|
{ "border_set", luaA_client_border_set },
|
2008-06-09 21:43:09 +02:00
|
|
|
{ "tag", luaA_client_tag },
|
|
|
|
{ "istagged", luaA_client_istagged },
|
2008-05-20 15:39:47 +02:00
|
|
|
{ "coords_get", luaA_client_coords_get },
|
|
|
|
{ "coords_set", luaA_client_coords_set },
|
|
|
|
{ "opacity_set", luaA_client_opacity_set },
|
|
|
|
{ "kill", luaA_client_kill },
|
|
|
|
{ "swap", luaA_client_swap },
|
|
|
|
{ "focus_set", luaA_client_focus_set },
|
2008-05-26 16:17:57 +02:00
|
|
|
{ "raise", luaA_client_raise },
|
2008-05-20 15:39:47 +02:00
|
|
|
{ "redraw", luaA_client_redraw },
|
|
|
|
{ "floating_set", luaA_client_floating_set },
|
|
|
|
{ "floating_get", luaA_client_floating_get },
|
2008-05-20 22:37:08 +02:00
|
|
|
{ "icon_set", luaA_client_icon_set },
|
2008-06-05 04:48:05 +02:00
|
|
|
{ "class_get", luaA_client_class_get },
|
2008-05-26 16:17:57 +02:00
|
|
|
{ "mouse_resize", luaA_client_mouse_resize },
|
|
|
|
{ "mouse_move", luaA_client_mouse_move },
|
2008-06-02 08:31:54 +02:00
|
|
|
{ "unmanage", luaA_client_unmanage },
|
2008-06-09 18:24:12 +02:00
|
|
|
{ "hide", luaA_client_hide },
|
|
|
|
{ "unhide", luaA_client_unhide },
|
2008-06-10 19:17:12 +02:00
|
|
|
{ "ishidden", luaA_client_ishidden },
|
2008-06-13 15:35:47 +02:00
|
|
|
{ "mouse_add", luaA_client_mouse_add },
|
|
|
|
{ "mouse_remove", luaA_client_mouse_remove },
|
2008-05-20 15:39:47 +02:00
|
|
|
{ "__eq", luaA_client_eq },
|
|
|
|
{ "__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
|