[client] Various documentation update and fixes
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
e5222ce55a
commit
6ba90facb0
194
client.c
194
client.c
|
@ -45,11 +45,11 @@
|
||||||
extern awesome_t globalconf;
|
extern awesome_t globalconf;
|
||||||
|
|
||||||
/** Load windows properties, restoring client's tag
|
/** Load windows properties, restoring client's tag
|
||||||
* and floating state before awesome was restarted if any,
|
* and floating state before awesome was restarted if any.
|
||||||
* \todo This may bug if number of tags is != than before,
|
* \todo This may bug if number of tags is != than before.
|
||||||
* \param c A client pointer
|
* \param c A client pointer.
|
||||||
* \param screen A virtual screen number.
|
* \param screen A virtual screen number.
|
||||||
* \return true if client had property, false otherwise.
|
* \return True if client had property, false otherwise.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
client_loadprops(client_t * c, int screen)
|
client_loadprops(client_t * c, int screen)
|
||||||
|
@ -79,7 +79,8 @@ client_loadprops(client_t * c, int screen)
|
||||||
untag_client(c, tag);
|
untag_client(c, tag);
|
||||||
|
|
||||||
if(prop[i])
|
if(prop[i])
|
||||||
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);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
p_delete(&prop);
|
p_delete(&prop);
|
||||||
|
@ -92,7 +93,7 @@ client_loadprops(client_t * c, int screen)
|
||||||
* \return true if client has WM_DELETE_WINDOW, false otherwise.
|
* \return true if client has WM_DELETE_WINDOW, false otherwise.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
client_isprotodel(xcb_window_t win)
|
window_isprotodel(xcb_window_t win)
|
||||||
{
|
{
|
||||||
uint32_t i, n;
|
uint32_t i, n;
|
||||||
xcb_atom_t wm_delete_win_atom;
|
xcb_atom_t wm_delete_win_atom;
|
||||||
|
@ -114,9 +115,10 @@ client_isprotodel(xcb_window_t win)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if a client is tagged
|
/** Returns true if a client is tagged with one of the tags visibl
|
||||||
* with one of the tags in any screen.
|
* on any screen.
|
||||||
* \return true if client is tagged, false otherwise.
|
* \param c The client.
|
||||||
|
* \return True if client is tagged, false otherwise.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
client_isvisible_anyscreen(client_t *c)
|
client_isvisible_anyscreen(client_t *c)
|
||||||
|
@ -124,13 +126,11 @@ client_isvisible_anyscreen(client_t *c)
|
||||||
tag_t *tag;
|
tag_t *tag;
|
||||||
int screen;
|
int screen;
|
||||||
|
|
||||||
if(!c)
|
if(c)
|
||||||
return false;
|
for(screen = 0; screen < globalconf.screens_info->nscreen; screen++)
|
||||||
|
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
|
||||||
for(screen = 0; screen < globalconf.screens_info->nscreen; screen++)
|
if(tag->selected && is_client_tagged(c, tag))
|
||||||
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
|
return true;
|
||||||
if(tag->selected && is_client_tagged(c, tag))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -146,25 +146,23 @@ client_isvisible(client_t *c, int screen)
|
||||||
{
|
{
|
||||||
tag_t *tag;
|
tag_t *tag;
|
||||||
|
|
||||||
if(!c || c->screen != screen)
|
if(c && c->screen == screen)
|
||||||
return false;
|
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
|
||||||
|
if(tag->selected && is_client_tagged(c, tag))
|
||||||
|
return true;
|
||||||
|
|
||||||
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
|
|
||||||
if(tag->selected && is_client_tagged(c, tag))
|
|
||||||
return true;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/** Get a client by its window ID.
|
/** Get a client by its window.
|
||||||
* \param list A client_t list to look into.
|
* \param list A client_t list to look into.
|
||||||
* \param w The client_t window to find.
|
* \param w The client window to find.
|
||||||
* \return A client pointer if found, NULL otherwise.
|
* \return A client pointer if found, NULL otherwise.
|
||||||
*/
|
*/
|
||||||
client_t *
|
client_t *
|
||||||
client_get_bywin(client_t *list, xcb_window_t w)
|
client_getbywin(xcb_window_t w)
|
||||||
{
|
{
|
||||||
client_t *c;
|
client_t *c;
|
||||||
|
for(c = globalconf.clients; c && c->win != w; c = c->next);
|
||||||
for(c = list; c && c->win != w; c = c->next);
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +196,6 @@ client_updatetitle(client_t *c)
|
||||||
luaA_client_userdata_new(c);
|
luaA_client_userdata_new(c);
|
||||||
luaA_dofunction(globalconf.L, globalconf.hooks.titleupdate, 1);
|
luaA_dofunction(globalconf.L, globalconf.hooks.titleupdate, 1);
|
||||||
|
|
||||||
titlebar_draw(c);
|
|
||||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +208,6 @@ client_unfocus(client_t *c)
|
||||||
|
|
||||||
focus_client_push(NULL);
|
focus_client_push(NULL);
|
||||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||||
titlebar_draw(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Ban client and unmap it
|
/** Ban client and unmap it
|
||||||
|
@ -228,10 +224,10 @@ client_ban(client_t *c)
|
||||||
xcb_unmap_window(globalconf.connection, c->titlebar->sw->window);
|
xcb_unmap_window(globalconf.connection, c->titlebar->sw->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Give focus to client, or to first client if c is NULL
|
/** Give focus to client, or to first client if client is NULL,
|
||||||
* \param c client
|
* \param c The client or NULL.
|
||||||
* \param screen Screen ID
|
* \param screen Virtual screen number.
|
||||||
* \return true if a window (even root) has received focus, false otherwise
|
* \return True if a window (even root) has received focus, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
client_focus(client_t *c, int screen)
|
client_focus(client_t *c, int screen)
|
||||||
|
@ -254,7 +250,6 @@ client_focus(client_t *c, int screen)
|
||||||
client_unban(c);
|
client_unban(c);
|
||||||
/* save sel in focus history */
|
/* save sel in focus history */
|
||||||
focus_client_push(c);
|
focus_client_push(c);
|
||||||
titlebar_draw(c);
|
|
||||||
xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_POINTER_ROOT,
|
xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_POINTER_ROOT,
|
||||||
c->win, XCB_CURRENT_TIME);
|
c->win, XCB_CURRENT_TIME);
|
||||||
/* since we're dropping EnterWindow events and sometimes the window
|
/* since we're dropping EnterWindow events and sometimes the window
|
||||||
|
@ -287,7 +282,7 @@ client_focus(client_t *c, int screen)
|
||||||
/** Restack clients and puts c in top of its layer.
|
/** Restack clients and puts c in top of its layer.
|
||||||
* \param c The client to stack on top of others.
|
* \param c The client to stack on top of others.
|
||||||
* \todo It might be worth stopping to restack everyone and only stack `c'
|
* \todo It might be worth stopping to restack everyone and only stack `c'
|
||||||
* relatively to the first matching in the list
|
* relatively to the first matching in the list.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
client_raise(client_t *c)
|
client_raise(client_t *c)
|
||||||
|
@ -299,6 +294,7 @@ client_raise(client_t *c)
|
||||||
config_win_vals[0] = XCB_NONE;
|
config_win_vals[0] = XCB_NONE;
|
||||||
config_win_vals[1] = XCB_STACK_MODE_BELOW;
|
config_win_vals[1] = XCB_STACK_MODE_BELOW;
|
||||||
|
|
||||||
|
/* Push c on top of the stack. */
|
||||||
stack_client_push(c);
|
stack_client_push(c);
|
||||||
|
|
||||||
for(layer = LAYER_FULLSCREEN; layer >= LAYER_DESKTOP; layer--)
|
for(layer = LAYER_FULLSCREEN; layer >= LAYER_DESKTOP; layer--)
|
||||||
|
@ -323,10 +319,10 @@ client_raise(client_t *c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Manage a new client
|
/** Manage a new client.
|
||||||
* \param w The window
|
* \param w The window.
|
||||||
* \param wgeom Window geometry
|
* \param wgeom Window geometry.
|
||||||
* \param screen Screen ID
|
* \param screen Virtual screen number where to manage client.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int screen)
|
client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int screen)
|
||||||
|
@ -336,6 +332,9 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int screen)
|
||||||
bool rettrans, retloadprops;
|
bool rettrans, retloadprops;
|
||||||
tag_t *tag;
|
tag_t *tag;
|
||||||
xcb_size_hints_t *u_size_hints;
|
xcb_size_hints_t *u_size_hints;
|
||||||
|
const uint32_t select_input_val[] = {
|
||||||
|
XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE |
|
||||||
|
XCB_EVENT_MASK_ENTER_WINDOW };
|
||||||
|
|
||||||
c = p_new(client_t, 1);
|
c = p_new(client_t, 1);
|
||||||
|
|
||||||
|
@ -355,9 +354,6 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int screen)
|
||||||
c->oldborder = wgeom->border_width;
|
c->oldborder = wgeom->border_width;
|
||||||
c->layer = c->oldlayer = LAYER_TILE;
|
c->layer = c->oldlayer = LAYER_TILE;
|
||||||
|
|
||||||
/* update window title */
|
|
||||||
client_updatetitle(c);
|
|
||||||
|
|
||||||
/* update hints */
|
/* update hints */
|
||||||
u_size_hints = client_updatesizehints(c);
|
u_size_hints = client_updatesizehints(c);
|
||||||
client_updatewmhints(c);
|
client_updatewmhints(c);
|
||||||
|
@ -371,7 +367,7 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int screen)
|
||||||
|
|
||||||
/* check for transient and set tags like its parent */
|
/* check for transient and set tags like its parent */
|
||||||
if((rettrans = xutil_get_transient_for_hint(globalconf.connection, w, &trans))
|
if((rettrans = xutil_get_transient_for_hint(globalconf.connection, w, &trans))
|
||||||
&& (t = client_get_bywin(globalconf.clients, trans)))
|
&& (t = client_getbywin(trans)))
|
||||||
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
|
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
|
||||||
if(is_client_tagged(t, tag))
|
if(is_client_tagged(t, tag))
|
||||||
tag_client(c, tag);
|
tag_client(c, tag);
|
||||||
|
@ -390,13 +386,10 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int screen)
|
||||||
client_resize(c, globalconf.floating_placement(c), false);
|
client_resize(c, globalconf.floating_placement(c), false);
|
||||||
else
|
else
|
||||||
c->f_geometry = globalconf.floating_placement(c);
|
c->f_geometry = globalconf.floating_placement(c);
|
||||||
|
|
||||||
xcb_free_size_hints(u_size_hints);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32_t select_input_val[] = {
|
if(u_size_hints)
|
||||||
XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE |
|
xcb_free_size_hints(u_size_hints);
|
||||||
XCB_EVENT_MASK_ENTER_WINDOW };
|
|
||||||
|
|
||||||
xcb_change_window_attributes(globalconf.connection, w, XCB_CW_EVENT_MASK,
|
xcb_change_window_attributes(globalconf.connection, w, XCB_CW_EVENT_MASK,
|
||||||
select_input_val);
|
select_input_val);
|
||||||
|
@ -418,6 +411,9 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int screen)
|
||||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||||
ewmh_update_net_client_list(c->phys_screen);
|
ewmh_update_net_client_list(c->phys_screen);
|
||||||
|
|
||||||
|
/* update window title */
|
||||||
|
client_updatetitle(c);
|
||||||
|
|
||||||
/* call hook */
|
/* call hook */
|
||||||
luaA_client_userdata_new(c);
|
luaA_client_userdata_new(c);
|
||||||
luaA_dofunction(globalconf.L, globalconf.hooks.newclient, 1);
|
luaA_dofunction(globalconf.L, globalconf.hooks.newclient, 1);
|
||||||
|
@ -555,6 +551,11 @@ client_resize(client_t *c, area_t geometry, bool hints)
|
||||||
return resized;
|
return resized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set a clinet floating.
|
||||||
|
* \param c The client.
|
||||||
|
* \param floating Set floating, or not.
|
||||||
|
* \param layer Layer to put the floating window onto.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
client_setfloating(client_t *c, bool floating, layer_t layer)
|
client_setfloating(client_t *c, bool floating, layer_t layer)
|
||||||
{
|
{
|
||||||
|
@ -576,16 +577,14 @@ client_setfloating(client_t *c, bool floating, layer_t layer)
|
||||||
c->layer = layer;
|
c->layer = layer;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
c->layer = c->oldlayer;
|
c->layer = c->oldlayer;
|
||||||
}
|
|
||||||
client_raise(c);
|
client_raise(c);
|
||||||
client_saveprops(c);
|
client_saveprops(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Save client properties as an X property
|
/** Save client properties as an X property.
|
||||||
* \param c client
|
* \param c The client.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
client_saveprops(client_t *c)
|
client_saveprops(client_t *c)
|
||||||
|
@ -593,6 +592,9 @@ client_saveprops(client_t *c)
|
||||||
int i = 0, ntags = 0;
|
int i = 0, ntags = 0;
|
||||||
char *prop;
|
char *prop;
|
||||||
tag_t *tag;
|
tag_t *tag;
|
||||||
|
xutil_intern_atom_request_t atom_q;
|
||||||
|
|
||||||
|
atom_q = xutil_intern_atom(globalconf.connection, &globalconf.atoms, "_AWESOME_PROPERTIES");
|
||||||
|
|
||||||
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
|
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
|
||||||
ntags++;
|
ntags++;
|
||||||
|
@ -609,10 +611,7 @@ client_saveprops(client_t *c)
|
||||||
prop[++i] = '\0';
|
prop[++i] = '\0';
|
||||||
|
|
||||||
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, c->win,
|
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, c->win,
|
||||||
xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms,
|
xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms, atom_q),
|
||||||
xutil_intern_atom(globalconf.connection,
|
|
||||||
&globalconf.atoms,
|
|
||||||
"_AWESOME_PROPERTIES")),
|
|
||||||
STRING, 8, i, (unsigned char *) prop);
|
STRING, 8, i, (unsigned char *) prop);
|
||||||
|
|
||||||
p_delete(&prop);
|
p_delete(&prop);
|
||||||
|
@ -664,42 +663,51 @@ client_unmanage(client_t *c)
|
||||||
p_delete(&c);
|
p_delete(&c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Update the WM hints of a client.
|
||||||
|
* \param c The client.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
client_updatewmhints(client_t *c)
|
client_updatewmhints(client_t *c)
|
||||||
{
|
{
|
||||||
xcb_wm_hints_t *wmh = NULL;
|
xcb_wm_hints_t *wmh = NULL;
|
||||||
|
uint32_t wm_hints_flags;
|
||||||
|
|
||||||
if((wmh = xcb_get_wm_hints(globalconf.connection, c->win)))
|
if((wmh = xcb_get_wm_hints(globalconf.connection, c->win)))
|
||||||
{
|
{
|
||||||
const uint32_t wm_hints_flags = xcb_wm_hints_get_flags(wmh);
|
wm_hints_flags = xcb_wm_hints_get_flags(wmh);
|
||||||
if((c->isurgent = (wm_hints_flags & XCB_WM_X_URGENCY_HINT)))
|
if((c->isurgent = (wm_hints_flags & XCB_WM_X_URGENCY_HINT)))
|
||||||
{
|
{
|
||||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
|
||||||
titlebar_draw(c);
|
|
||||||
/* execute hook */
|
/* execute hook */
|
||||||
luaA_client_userdata_new(c);
|
luaA_client_userdata_new(c);
|
||||||
luaA_dofunction(globalconf.L, globalconf.hooks.urgent, 1);
|
luaA_dofunction(globalconf.L, globalconf.hooks.urgent, 1);
|
||||||
|
|
||||||
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||||
}
|
}
|
||||||
if((wm_hints_flags & XCB_WM_STATE_HINT) &&
|
if((wm_hints_flags & XCB_WM_STATE_HINT) &&
|
||||||
(xcb_wm_hints_get_initial_state(wmh) == XCB_WM_WITHDRAWN_STATE))
|
(xcb_wm_hints_get_initial_state(wmh) == XCB_WM_WITHDRAWN_STATE))
|
||||||
{
|
{
|
||||||
c->border = 0;
|
client_setborder(c, 0);
|
||||||
c->skip = true;
|
c->skip = true;
|
||||||
}
|
}
|
||||||
xcb_free_wm_hints(wmh);
|
xcb_free_wm_hints(wmh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Update the size hintz of a client.
|
||||||
|
* \param c The client
|
||||||
|
* \return A pointer to a xcb_size_hints_t.
|
||||||
|
*/
|
||||||
xcb_size_hints_t *
|
xcb_size_hints_t *
|
||||||
client_updatesizehints(client_t *c)
|
client_updatesizehints(client_t *c)
|
||||||
{
|
{
|
||||||
long msize;
|
long msize;
|
||||||
xcb_size_hints_t *size = NULL;
|
xcb_size_hints_t *size;
|
||||||
|
uint32_t size_flags;
|
||||||
|
|
||||||
if(!(size = xcb_get_wm_normal_hints(globalconf.connection, c->win, &msize)))
|
if(!(size = xcb_get_wm_normal_hints(globalconf.connection, c->win, &msize)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
const uint32_t size_flags = xcb_size_hints_get_flags(size);
|
size_flags = xcb_size_hints_get_flags(size);
|
||||||
|
|
||||||
if((size_flags & XCB_SIZE_P_SIZE_HINT))
|
if((size_flags & XCB_SIZE_P_SIZE_HINT))
|
||||||
xcb_size_hints_get_base_size(size, &c->basew, &c->baseh);
|
xcb_size_hints_get_base_size(size, &c->basew, &c->baseh);
|
||||||
|
@ -739,6 +747,12 @@ client_updatesizehints(client_t *c)
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 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.
|
||||||
|
*/
|
||||||
char *
|
char *
|
||||||
client_markup_parse(client_t *c, const char *str, ssize_t len)
|
client_markup_parse(client_t *c, const char *str, ssize_t len)
|
||||||
{
|
{
|
||||||
|
@ -766,17 +780,17 @@ client_markup_parse(client_t *c, const char *str, ssize_t len)
|
||||||
|
|
||||||
/** Kill a client via a WM_DELETE_WINDOW request or XKillClient if not
|
/** Kill a client via a WM_DELETE_WINDOW request or XKillClient if not
|
||||||
* supported.
|
* supported.
|
||||||
* \param c The client to kill,
|
* \param c The client to kill.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
client_kill(client_t *c)
|
client_kill(client_t *c)
|
||||||
{
|
{
|
||||||
xcb_client_message_event_t ev;
|
xcb_client_message_event_t ev;
|
||||||
|
|
||||||
if(client_isprotodel(c->win))
|
if(window_isprotodel(c->win))
|
||||||
{
|
{
|
||||||
/* Initialize all of event's fields first */
|
/* Initialize all of event's fields first */
|
||||||
memset(&ev, 0, sizeof(ev));
|
p_clear(&ev, 1);
|
||||||
|
|
||||||
ev.response_type = XCB_CLIENT_MESSAGE;
|
ev.response_type = XCB_CLIENT_MESSAGE;
|
||||||
ev.window = c->win;
|
ev.window = c->win;
|
||||||
|
@ -799,6 +813,9 @@ client_kill(client_t *c)
|
||||||
xcb_kill_client(globalconf.connection, c->win);
|
xcb_kill_client(globalconf.connection, c->win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get all clients into a table.
|
||||||
|
* \return A table with all clients.
|
||||||
|
*/
|
||||||
static int
|
static int
|
||||||
luaA_client_get(lua_State *L)
|
luaA_client_get(lua_State *L)
|
||||||
{
|
{
|
||||||
|
@ -816,6 +833,11 @@ luaA_client_get(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Add mouse bindings over clients's window.
|
||||||
|
* \param A table with modifier keys.
|
||||||
|
* \param A mouse button number
|
||||||
|
* \param A function to execute.
|
||||||
|
*/
|
||||||
static int
|
static int
|
||||||
luaA_client_mouse(lua_State *L)
|
luaA_client_mouse(lua_State *L)
|
||||||
{
|
{
|
||||||
|
@ -823,11 +845,11 @@ luaA_client_mouse(lua_State *L)
|
||||||
int b;
|
int b;
|
||||||
button_t *button;
|
button_t *button;
|
||||||
|
|
||||||
/* arg 2 is modkey table */
|
/* arg 1 is modkey table */
|
||||||
luaA_checktable(L, 1);
|
luaA_checktable(L, 1);
|
||||||
/* arg 3 is mouse button */
|
/* arg 2 is mouse button */
|
||||||
b = luaL_checknumber(L, 2);
|
b = luaL_checknumber(L, 2);
|
||||||
/* arg 4 is cmd to run */
|
/* arg 3 is cmd to run */
|
||||||
luaA_checkfunction(L, 3);
|
luaA_checkfunction(L, 3);
|
||||||
|
|
||||||
button = p_new(button_t, 1);
|
button = p_new(button_t, 1);
|
||||||
|
@ -846,6 +868,10 @@ luaA_client_mouse(lua_State *L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get only visible clients for a screen.
|
||||||
|
* \param A screen number.
|
||||||
|
* \return A table with all visible clients for this screen.
|
||||||
|
*/
|
||||||
static int
|
static int
|
||||||
luaA_client_visible_get(lua_State *L)
|
luaA_client_visible_get(lua_State *L)
|
||||||
{
|
{
|
||||||
|
@ -867,19 +893,20 @@ luaA_client_visible_get(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get the currently focused client.
|
||||||
|
* \return The currently focused client.
|
||||||
|
*/
|
||||||
static int
|
static int
|
||||||
luaA_client_focus_get(lua_State *L __attribute__ ((unused)))
|
luaA_client_focus_get(lua_State *L __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
if(!globalconf.focus->client)
|
if(globalconf.focus->client)
|
||||||
return 0;
|
return luaA_client_userdata_new(globalconf.focus->client);
|
||||||
|
return 0;
|
||||||
luaA_client_userdata_new(globalconf.focus->client);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set client border width.
|
/** Set client border width.
|
||||||
* \c The client.
|
* \param c The client.
|
||||||
* \ width The border width.
|
* \param width The border width.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
client_setborder(client_t *c, uint32_t width)
|
client_setborder(client_t *c, uint32_t width)
|
||||||
|
@ -915,6 +942,9 @@ luaA_client_border_set(lua_State *L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Move the client to another screen.
|
||||||
|
* \param A screen number.
|
||||||
|
*/
|
||||||
static int
|
static int
|
||||||
luaA_client_screen_set(lua_State *L)
|
luaA_client_screen_set(lua_State *L)
|
||||||
{
|
{
|
||||||
|
@ -925,6 +955,9 @@ luaA_client_screen_set(lua_State *L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get the screen number the client is onto.
|
||||||
|
* \return A screen number.
|
||||||
|
*/
|
||||||
static int
|
static int
|
||||||
luaA_client_screen_get(lua_State *L)
|
luaA_client_screen_get(lua_State *L)
|
||||||
{
|
{
|
||||||
|
@ -933,7 +966,10 @@ luaA_client_screen_get(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Tag a client with a specified tag.
|
||||||
|
* \param A tag object.
|
||||||
|
* \param A boolean value: true to add this tag to clients, false to remove.
|
||||||
|
*/
|
||||||
static int
|
static int
|
||||||
luaA_client_tag(lua_State *L)
|
luaA_client_tag(lua_State *L)
|
||||||
{
|
{
|
||||||
|
@ -952,6 +988,11 @@ luaA_client_tag(lua_State *L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Check if a client is tagged with the specified tag.
|
||||||
|
* \param A tag object.
|
||||||
|
* \return A boolean value, true if the client is tagged with this tag, false
|
||||||
|
* otherwise.
|
||||||
|
*/
|
||||||
static int
|
static int
|
||||||
luaA_client_istagged(lua_State *L)
|
luaA_client_istagged(lua_State *L)
|
||||||
{
|
{
|
||||||
|
@ -961,6 +1002,9 @@ luaA_client_istagged(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get the client coordinates on the display.
|
||||||
|
* \return A table with keys `width', `height', `x' and `y'.
|
||||||
|
*/
|
||||||
static int
|
static int
|
||||||
luaA_client_coords_get(lua_State *L)
|
luaA_client_coords_get(lua_State *L)
|
||||||
{
|
{
|
||||||
|
|
2
client.h
2
client.h
|
@ -27,7 +27,7 @@
|
||||||
#include "structs.h"
|
#include "structs.h"
|
||||||
|
|
||||||
bool client_isvisible(client_t *, int);
|
bool client_isvisible(client_t *, int);
|
||||||
client_t * client_get_bywin(client_t *, xcb_window_t);
|
client_t * client_getbywin(xcb_window_t);
|
||||||
bool client_focus(client_t *, int);
|
bool client_focus(client_t *, int);
|
||||||
void client_raise(client_t *);
|
void client_raise(client_t *);
|
||||||
void client_ban(client_t *);
|
void client_ban(client_t *);
|
||||||
|
|
18
event.c
18
event.c
|
@ -154,7 +154,7 @@ event_handle_buttonpress(void *data __attribute__ ((unused)),
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((c = client_get_bywin(globalconf.clients, ev->event)))
|
if((c = client_getbywin(ev->event)))
|
||||||
{
|
{
|
||||||
event_handle_mouse_button_press(c, ev->detail, ev->state, globalconf.buttons.client);
|
event_handle_mouse_button_press(c, ev->detail, ev->state, globalconf.buttons.client);
|
||||||
xcb_allow_events(globalconf.connection, XCB_ALLOW_REPLAY_POINTER, XCB_CURRENT_TIME);
|
xcb_allow_events(globalconf.connection, XCB_ALLOW_REPLAY_POINTER, XCB_CURRENT_TIME);
|
||||||
|
@ -182,7 +182,7 @@ event_handle_configurerequest(void *data __attribute__ ((unused)),
|
||||||
client_t *c;
|
client_t *c;
|
||||||
area_t geometry;
|
area_t geometry;
|
||||||
|
|
||||||
if((c = client_get_bywin(globalconf.clients, ev->window)))
|
if((c = client_getbywin(ev->window)))
|
||||||
{
|
{
|
||||||
geometry = c->geometry;
|
geometry = c->geometry;
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ event_handle_destroynotify(void *data __attribute__ ((unused)),
|
||||||
{
|
{
|
||||||
client_t *c;
|
client_t *c;
|
||||||
|
|
||||||
if((c = client_get_bywin(globalconf.clients, ev->window)))
|
if((c = client_getbywin(ev->window)))
|
||||||
client_unmanage(c);
|
client_unmanage(c);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -319,7 +319,7 @@ event_handle_enternotify(void *data __attribute__ ((unused)),
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if((c = client_getbytitlebarwin(ev->event))
|
if((c = client_getbytitlebarwin(ev->event))
|
||||||
|| (c = client_get_bywin(globalconf.clients, ev->event)))
|
|| (c = client_getbywin(ev->event)))
|
||||||
{
|
{
|
||||||
window_grabbuttons(c->win, c->phys_screen);
|
window_grabbuttons(c->win, c->phys_screen);
|
||||||
/* the idea behind saving pointer_x and pointer_y is Bob Marley powered
|
/* the idea behind saving pointer_x and pointer_y is Bob Marley powered
|
||||||
|
@ -418,7 +418,7 @@ event_handle_maprequest(void *data __attribute__ ((unused)),
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(c = client_get_bywin(globalconf.clients, ev->window)))
|
if(!(c = client_getbywin(ev->window)))
|
||||||
{
|
{
|
||||||
geom_c = xcb_get_geometry(connection, ev->window);
|
geom_c = xcb_get_geometry(connection, ev->window);
|
||||||
|
|
||||||
|
@ -473,13 +473,13 @@ event_handle_propertynotify(void *data __attribute__ ((unused)),
|
||||||
|
|
||||||
if(ev->state == XCB_PROPERTY_DELETE)
|
if(ev->state == XCB_PROPERTY_DELETE)
|
||||||
return 0; /* ignore */
|
return 0; /* ignore */
|
||||||
if((c = client_get_bywin(globalconf.clients, ev->window)))
|
if((c = client_getbywin(ev->window)))
|
||||||
{
|
{
|
||||||
if(ev->atom == WM_TRANSIENT_FOR)
|
if(ev->atom == WM_TRANSIENT_FOR)
|
||||||
{
|
{
|
||||||
xutil_get_transient_for_hint(connection, c->win, &trans);
|
xutil_get_transient_for_hint(connection, c->win, &trans);
|
||||||
if(!c->isfloating
|
if(!c->isfloating
|
||||||
&& (c->isfloating = (client_get_bywin(globalconf.clients, trans) != NULL)))
|
&& (c->isfloating = (client_getbywin(trans) != NULL)))
|
||||||
globalconf.screens[c->screen].need_arrange = true;
|
globalconf.screens[c->screen].need_arrange = true;
|
||||||
}
|
}
|
||||||
else if (ev->atom == WM_NORMAL_HINTS)
|
else if (ev->atom == WM_NORMAL_HINTS)
|
||||||
|
@ -515,7 +515,7 @@ event_handle_unmapnotify(void *data __attribute__ ((unused)),
|
||||||
*/
|
*/
|
||||||
bool send_event = ((ev->response_type & 0x80) >> 7);
|
bool send_event = ((ev->response_type & 0x80) >> 7);
|
||||||
|
|
||||||
if((c = client_get_bywin(globalconf.clients, ev->window))
|
if((c = client_getbywin(ev->window))
|
||||||
&& ev->event == xcb_aux_get_screen(connection, c->phys_screen)->root
|
&& ev->event == xcb_aux_get_screen(connection, c->phys_screen)->root
|
||||||
&& send_event && window_getstate(c->win) == XCB_WM_NORMAL_STATE)
|
&& send_event && window_getstate(c->win) == XCB_WM_NORMAL_STATE)
|
||||||
client_unmanage(c);
|
client_unmanage(c);
|
||||||
|
@ -531,7 +531,7 @@ event_handle_shape(void *data __attribute__ ((unused)),
|
||||||
xcb_connection_t *connection __attribute__ ((unused)),
|
xcb_connection_t *connection __attribute__ ((unused)),
|
||||||
xcb_shape_notify_event_t *ev)
|
xcb_shape_notify_event_t *ev)
|
||||||
{
|
{
|
||||||
client_t *c = client_get_bywin(globalconf.clients, ev->affected_window);
|
client_t *c = client_getbywin(ev->affected_window);
|
||||||
|
|
||||||
if(c)
|
if(c)
|
||||||
window_setshape(c->win, c->phys_screen);
|
window_setshape(c->win, c->phys_screen);
|
||||||
|
|
4
ewmh.c
4
ewmh.c
|
@ -379,12 +379,12 @@ ewmh_process_client_message(xcb_client_message_event_t *ev)
|
||||||
|
|
||||||
if(ev->type == net_close_window)
|
if(ev->type == net_close_window)
|
||||||
{
|
{
|
||||||
if((c = client_get_bywin(globalconf.clients, ev->window)))
|
if((c = client_getbywin(ev->window)))
|
||||||
client_kill(c);
|
client_kill(c);
|
||||||
}
|
}
|
||||||
else if(ev->type == net_wm_state)
|
else if(ev->type == net_wm_state)
|
||||||
{
|
{
|
||||||
if((c = client_get_bywin(globalconf.clients, ev->window)))
|
if((c = client_getbywin(ev->window)))
|
||||||
{
|
{
|
||||||
ewmh_process_state_atom(c, (xcb_atom_t) ev->data.data32[1], ev->data.data32[0]);
|
ewmh_process_state_atom(c, (xcb_atom_t) ev->data.data32[1], ev->data.data32[0]);
|
||||||
if(ev->data.data32[2])
|
if(ev->data.data32[2])
|
||||||
|
|
2
mouse.c
2
mouse.c
|
@ -362,7 +362,7 @@ mouse_client_move(client_t *c, int snap)
|
||||||
globalconf.screens[newscreen].need_arrange = true;
|
globalconf.screens[newscreen].need_arrange = true;
|
||||||
layout_refresh();
|
layout_refresh();
|
||||||
}
|
}
|
||||||
if((target = client_get_bywin(globalconf.clients, mquery_pointer_r->child))
|
if((target = client_getbywin(mquery_pointer_r->child))
|
||||||
&& target != c && !target->isfloating)
|
&& target != c && !target->isfloating)
|
||||||
{
|
{
|
||||||
client_list_swap(&globalconf.clients, c, target);
|
client_list_swap(&globalconf.clients, c, target);
|
||||||
|
|
Loading…
Reference in New Issue