2007-10-03 17:26:14 +02:00
|
|
|
/*
|
|
|
|
* client.c - client management
|
|
|
|
*
|
|
|
|
* Copyright © 2007 Julien Danjou <julien@danjou.info>
|
|
|
|
*
|
|
|
|
* 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>
|
|
|
|
#include <X11/Xatom.h>
|
2007-09-13 15:57:35 +02:00
|
|
|
#include <X11/extensions/shape.h>
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2007-09-14 11:55:36 +02:00
|
|
|
#include "screen.h"
|
2007-09-10 12:06:54 +02:00
|
|
|
#include "awesome.h"
|
2007-09-05 20:15:00 +02:00
|
|
|
#include "layout.h"
|
|
|
|
#include "tag.h"
|
2007-11-13 21:40:33 +01:00
|
|
|
#include "rules.h"
|
2007-12-14 16:15:40 +01:00
|
|
|
#include "util.h"
|
2007-11-17 20:53:31 +01:00
|
|
|
#include "xutil.h"
|
2007-09-15 15:16:53 +02:00
|
|
|
#include "statusbar.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"
|
2007-09-05 20:15:00 +02:00
|
|
|
#include "layouts/floating.h"
|
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
|
2007-12-19 04:46:44 +01:00
|
|
|
extern AwesomeConf globalconf;
|
2007-12-16 02:45:38 +01:00
|
|
|
|
2007-12-14 14:29:32 +01:00
|
|
|
/** Load windows properties, restoring client's tag
|
|
|
|
* and floating state before awesome was restarted if any
|
|
|
|
* \todo this may bug if number of tags is != than before
|
|
|
|
* \param c Client ref
|
2007-12-19 04:26:20 +01:00
|
|
|
* \param screen Screen ID
|
2007-10-17 11:49:54 +02:00
|
|
|
*/
|
2007-12-14 14:29:32 +01:00
|
|
|
static Bool
|
2007-12-16 02:45:38 +01:00
|
|
|
client_loadprops(Client * c, int screen)
|
2007-10-16 22:40:02 +02:00
|
|
|
{
|
2007-12-14 19:02:38 +01:00
|
|
|
int i, ntags = 0;
|
|
|
|
Tag *tag;
|
2007-12-14 14:29:32 +01:00
|
|
|
char *prop;
|
|
|
|
Bool result = False;
|
2007-10-16 22:40:02 +02:00
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
|
2007-12-14 19:02:38 +01:00
|
|
|
ntags++;
|
2007-12-14 14:29:32 +01:00
|
|
|
|
2007-12-14 19:02:38 +01:00
|
|
|
prop = p_new(char, ntags + 2);
|
|
|
|
|
2007-12-27 23:10:43 +01:00
|
|
|
if(xgettextprop(globalconf.display, c->win, AWESOMEPROPS_ATOM(globalconf.display), prop, ntags + 2))
|
2007-12-14 14:29:32 +01:00
|
|
|
{
|
2007-12-16 02:45:38 +01:00
|
|
|
for(i = 0, tag = globalconf.screens[screen].tags; tag && i < ntags && prop[i]; i++, tag = tag->next)
|
2007-12-14 14:29:32 +01:00
|
|
|
if(prop[i] == '1')
|
|
|
|
{
|
2007-12-27 22:43:59 +01:00
|
|
|
tag_client(c, tag);
|
2007-12-14 14:29:32 +01:00
|
|
|
result = True;
|
|
|
|
}
|
|
|
|
else
|
2007-12-27 22:43:59 +01:00
|
|
|
untag_client(c, tag);
|
2007-12-14 14:29:32 +01:00
|
|
|
|
2007-12-14 19:02:38 +01:00
|
|
|
if(i <= ntags && prop[i])
|
2007-12-14 14:29:32 +01:00
|
|
|
c->isfloating = prop[i] == '1';
|
|
|
|
}
|
|
|
|
|
|
|
|
p_delete(&prop);
|
|
|
|
|
|
|
|
return result;
|
2007-10-16 22:40:02 +02:00
|
|
|
}
|
|
|
|
|
2007-09-11 13:14:43 +02:00
|
|
|
/** Check if client supports protocol WM_DELETE_WINDOW
|
2007-12-16 03:14:47 +01:00
|
|
|
* \param disp the display
|
2007-12-19 04:26:20 +01:00
|
|
|
* \param win the Window
|
2007-09-11 13:14:43 +02:00
|
|
|
* \return True if client has WM_DELETE_WINDOW
|
2007-09-05 20:15:00 +02:00
|
|
|
*/
|
|
|
|
static Bool
|
2007-10-19 15:36:41 +02:00
|
|
|
isprotodel(Display *disp, Window win)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
int i, n;
|
|
|
|
Atom *protocols;
|
|
|
|
Bool ret = False;
|
|
|
|
|
2007-10-19 15:36:41 +02:00
|
|
|
if(XGetWMProtocols(disp, win, &protocols, &n))
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
for(i = 0; !ret && i < n; i++)
|
2007-10-19 15:36:41 +02:00
|
|
|
if(protocols[i] == XInternAtom(disp, "WM_DELETE_WINDOW", False))
|
2007-09-05 20:15:00 +02:00
|
|
|
ret = True;
|
|
|
|
XFree(protocols);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-09-25 12:41:36 +02:00
|
|
|
/** Swap two client in the linked list clients
|
2007-12-16 03:14:47 +01:00
|
|
|
* \param head pointer ito the client list head
|
2007-09-25 12:41:36 +02:00
|
|
|
* \param c1 first client
|
|
|
|
* \param c2 second client
|
|
|
|
*/
|
|
|
|
static void
|
2007-10-11 21:50:32 +02:00
|
|
|
client_swap(Client **head, Client *c1, Client *c2)
|
2007-09-25 12:41:36 +02:00
|
|
|
{
|
|
|
|
Client *tmp;
|
|
|
|
|
|
|
|
tmp = c1->next;
|
2007-10-03 17:26:14 +02:00
|
|
|
c1->next = c2->next;
|
2007-09-25 12:41:36 +02:00
|
|
|
c2->next = (tmp == c2 ? c1 : tmp);
|
|
|
|
|
|
|
|
tmp = c2->prev;
|
|
|
|
c2->prev = c1->prev;
|
|
|
|
c1->prev = (tmp == c1 ? c2 : tmp );
|
|
|
|
|
|
|
|
if(c1->next)
|
|
|
|
c1->next->prev = c1;
|
|
|
|
|
|
|
|
if(c1->prev)
|
|
|
|
c1->prev->next = c1;
|
|
|
|
|
|
|
|
if(c2->next)
|
|
|
|
c2->next->prev = c2;
|
|
|
|
|
|
|
|
if(c2->prev)
|
|
|
|
c2->prev->next = c2;
|
|
|
|
|
2007-10-11 21:50:32 +02:00
|
|
|
if(*head == c1)
|
|
|
|
*head = c2;
|
2007-09-25 12:41:36 +02:00
|
|
|
}
|
|
|
|
|
2007-12-14 14:29:32 +01:00
|
|
|
/** Get a Client by its window
|
|
|
|
* \param list Client list to look info
|
|
|
|
* \param w Client window to find
|
|
|
|
* \return client
|
|
|
|
*/
|
|
|
|
Client *
|
|
|
|
get_client_bywin(Client *list, Window w)
|
|
|
|
{
|
|
|
|
Client *c;
|
|
|
|
|
|
|
|
for(c = list; c && c->win != w; c = c->next);
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2007-12-23 16:16:02 +01:00
|
|
|
Client *
|
|
|
|
get_client_byname(Client *list, char *name)
|
|
|
|
{
|
|
|
|
Client *c;
|
|
|
|
|
|
|
|
for(c = list; c; c = c->next)
|
|
|
|
if(strstr(c->name, name))
|
|
|
|
return c;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-10-01 20:44:02 +02:00
|
|
|
void
|
2007-12-14 16:05:10 +01:00
|
|
|
client_updatetitle(Client *c)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-12-27 23:10:43 +01:00
|
|
|
if(!xgettextprop(globalconf.display, c->win, XInternAtom(globalconf.display, "_NET_WM_NAME", False), c->name, sizeof(c->name)))
|
|
|
|
xgettextprop(globalconf.display, c->win, XInternAtom(globalconf.display, "WM_NAME", False), c->name, sizeof(c->name));
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2007-12-14 08:47:21 +01:00
|
|
|
/** Ban client and unmap it
|
2007-09-05 20:15:00 +02:00
|
|
|
* \param c the client
|
|
|
|
*/
|
|
|
|
void
|
2007-10-26 19:50:39 +02:00
|
|
|
client_ban(Client * c)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-12-27 23:10:43 +01:00
|
|
|
XUnmapWindow(globalconf.display, c->win);
|
|
|
|
window_setstate(globalconf.display, c->win, IconicState);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2007-10-17 12:12:40 +02:00
|
|
|
/** Attach client to the beginning of the clients stack
|
|
|
|
* \param c the client
|
|
|
|
*/
|
|
|
|
void
|
2007-12-16 02:45:38 +01:00
|
|
|
client_attach(Client *c)
|
2007-10-17 12:12:40 +02:00
|
|
|
{
|
2007-12-16 02:45:38 +01:00
|
|
|
if(globalconf.clients)
|
|
|
|
(globalconf.clients)->prev = c;
|
|
|
|
c->next = globalconf.clients;
|
|
|
|
globalconf.clients = c;
|
2007-10-17 12:12:40 +02:00
|
|
|
}
|
|
|
|
|
2007-10-03 00:13:09 +02:00
|
|
|
/** Detach client from clients list
|
|
|
|
* \param c client to detach
|
|
|
|
*/
|
2007-09-05 20:15:00 +02:00
|
|
|
void
|
2007-12-16 02:45:38 +01:00
|
|
|
client_detach(Client *c)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
if(c->prev)
|
|
|
|
c->prev->next = c->next;
|
|
|
|
if(c->next)
|
|
|
|
c->next->prev = c->prev;
|
2007-12-16 02:45:38 +01:00
|
|
|
if(c == globalconf.clients)
|
|
|
|
globalconf.clients = c->next;
|
2007-09-05 20:15:00 +02:00
|
|
|
c->next = c->prev = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Give focus to client, or to first client if c is NULL
|
|
|
|
* \param c client
|
2007-09-07 12:53:30 +02:00
|
|
|
* \param selscreen True if current screen is selected
|
2007-12-19 04:26:20 +01:00
|
|
|
* \param screen Screen ID
|
2007-09-05 20:15:00 +02:00
|
|
|
*/
|
|
|
|
void
|
2007-12-16 02:45:38 +01:00
|
|
|
focus(Client *c, Bool selscreen, int screen)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-12-14 21:51:54 +01:00
|
|
|
/* unfocus current selected client */
|
2007-12-16 02:45:38 +01:00
|
|
|
if(globalconf.focus->client)
|
2007-12-14 21:51:54 +01:00
|
|
|
{
|
2007-12-27 23:10:43 +01:00
|
|
|
window_grabbuttons(globalconf.display, globalconf.focus->client->phys_screen,
|
2007-12-16 02:45:38 +01:00
|
|
|
globalconf.focus->client->win, False, True);
|
2007-12-27 23:10:43 +01:00
|
|
|
XSetWindowBorder(globalconf.display, globalconf.focus->client->win,
|
2007-12-16 02:45:38 +01:00
|
|
|
globalconf.screens[screen].colors_normal[ColBorder].pixel);
|
2007-12-27 23:10:43 +01:00
|
|
|
window_settrans(globalconf.display, globalconf.focus->client->win,
|
2007-12-16 02:45:38 +01:00
|
|
|
globalconf.screens[screen].opacity_unfocused);
|
2007-12-14 21:51:54 +01:00
|
|
|
}
|
2007-10-26 22:11:02 +02:00
|
|
|
|
2007-09-05 20:15:00 +02:00
|
|
|
/* if c is NULL or invisible, take next client in the stack */
|
2007-12-16 02:45:38 +01:00
|
|
|
if((!c && selscreen) || (c && !client_isvisible(c, screen)))
|
|
|
|
for(c = globalconf.clients; c && !client_isvisible(c, screen); c = c->next);
|
2007-10-03 17:26:14 +02:00
|
|
|
|
2007-10-15 16:57:54 +02:00
|
|
|
if(c)
|
|
|
|
{
|
2007-12-16 02:45:38 +01:00
|
|
|
XSetWindowBorder(globalconf.display, c->win, globalconf.screens[screen].colors_selected[ColBorder].pixel);
|
2007-12-27 23:10:43 +01:00
|
|
|
window_grabbuttons(globalconf.display, c->phys_screen, c->win,
|
2007-12-16 02:45:38 +01:00
|
|
|
True, True);
|
2007-11-10 10:45:32 +01:00
|
|
|
}
|
2007-12-14 21:51:54 +01:00
|
|
|
|
2007-09-05 20:15:00 +02:00
|
|
|
if(!selscreen)
|
|
|
|
return;
|
2007-12-14 21:51:54 +01:00
|
|
|
|
|
|
|
/* save old sel in focus history */
|
2007-12-17 03:56:29 +01:00
|
|
|
focus_add_client(c);
|
2007-12-14 21:51:54 +01:00
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
statusbar_draw(screen);
|
2007-12-14 21:51:54 +01:00
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
if(globalconf.focus->client)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-12-27 23:10:43 +01:00
|
|
|
XSetInputFocus(globalconf.display,
|
2007-12-16 02:45:38 +01:00
|
|
|
globalconf.focus->client->win, RevertToPointerRoot, CurrentTime);
|
|
|
|
for(c = globalconf.clients; c; c = c->next)
|
|
|
|
if(c != globalconf.focus->client)
|
|
|
|
window_settrans(globalconf.display, globalconf.focus->client->win,
|
|
|
|
globalconf.screens[screen].opacity_unfocused);
|
|
|
|
window_settrans(globalconf.display, globalconf.focus->client->win, -1);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
else
|
2007-12-16 02:45:38 +01:00
|
|
|
XSetInputFocus(globalconf.display,
|
2007-12-18 09:02:08 +01:00
|
|
|
RootWindow(globalconf.display, get_phys_screen(screen)),
|
2007-12-14 21:51:54 +01:00
|
|
|
RevertToPointerRoot, CurrentTime);
|
2007-12-27 19:33:01 +01:00
|
|
|
ewmh_update_net_active_window(get_phys_screen(screen));
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2007-09-20 21:27:43 +02:00
|
|
|
/** Manage a new client
|
|
|
|
* \param w The window
|
|
|
|
* \param wa Window attributes
|
2007-12-19 04:26:20 +01:00
|
|
|
* \param screen Screen ID
|
2007-09-20 21:27:43 +02:00
|
|
|
*/
|
2007-09-05 20:15:00 +02:00
|
|
|
void
|
2007-12-16 02:45:38 +01:00
|
|
|
client_manage(Window w, XWindowAttributes *wa, int screen)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
Client *c, *t = NULL;
|
|
|
|
Window trans;
|
|
|
|
Status rettrans;
|
|
|
|
XWindowChanges wc;
|
2007-12-23 00:54:59 +01:00
|
|
|
Area area, darea;
|
2007-12-14 19:02:38 +01:00
|
|
|
Tag *tag;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
|
|
|
c = p_new(Client, 1);
|
2007-10-22 16:25:27 +02:00
|
|
|
|
2007-09-05 20:15:00 +02:00
|
|
|
c->win = w;
|
2007-10-22 17:01:25 +02:00
|
|
|
c->x = c->rx = wa->x;
|
2007-09-05 20:15:00 +02:00
|
|
|
c->y = c->ry = wa->y;
|
|
|
|
c->w = c->rw = wa->width;
|
|
|
|
c->h = c->rh = wa->height;
|
|
|
|
c->oldborder = wa->border_width;
|
2007-10-22 16:25:27 +02:00
|
|
|
|
2007-12-27 23:10:43 +01:00
|
|
|
globalconf.display = globalconf.display;
|
2007-12-18 09:02:08 +01:00
|
|
|
c->screen = get_screen_bycoord(c->x, c->y);
|
|
|
|
c->phys_screen = get_phys_screen(c->screen);
|
2007-11-15 14:44:43 +01:00
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
move_client_to_screen(c, screen, True);
|
2007-11-13 22:41:56 +01:00
|
|
|
|
|
|
|
/* update window title */
|
2007-12-14 16:05:10 +01:00
|
|
|
client_updatetitle(c);
|
2007-11-13 22:41:56 +01:00
|
|
|
|
|
|
|
/* loadprops or apply rules if no props */
|
2007-12-16 02:45:38 +01:00
|
|
|
if(!client_loadprops(c, screen))
|
|
|
|
tag_client_with_rules(c);
|
2007-10-22 16:25:27 +02:00
|
|
|
|
2007-12-23 00:54:59 +01:00
|
|
|
area = get_screen_area(screen, NULL, NULL);
|
2007-11-15 14:44:43 +01:00
|
|
|
|
2007-10-22 16:25:27 +02:00
|
|
|
/* if window request fullscreen mode */
|
2007-12-23 00:54:59 +01:00
|
|
|
if(c->w == area.width && c->h == area.height)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-12-23 00:54:59 +01:00
|
|
|
c->x = area.x;
|
|
|
|
c->y = area.y;
|
2007-09-05 20:15:00 +02:00
|
|
|
c->border = wa->border_width;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-12-23 00:54:59 +01:00
|
|
|
darea = get_display_area(c->phys_screen,
|
|
|
|
globalconf.screens[screen].statusbar,
|
|
|
|
&globalconf.screens[screen].padding);
|
|
|
|
|
|
|
|
if(c->x + c->w + 2 * c->border > darea.x + darea.width)
|
|
|
|
c->x = c->rx = darea.x + darea.width - c->w - 2 * c->border;
|
|
|
|
if(c->y + c->h + 2 * c->border > darea.y + darea.height)
|
|
|
|
c->y = c->ry = darea.y + darea.height - c->h - 2 * c->border;
|
|
|
|
if(c->x < darea.x)
|
|
|
|
c->x = c->rx = darea.x;
|
|
|
|
if(c->y < darea.y)
|
|
|
|
c->y = c->ry = darea.y;
|
2007-10-22 16:25:27 +02:00
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
c->border = globalconf.screens[screen].borderpx;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
2007-10-22 16:25:27 +02:00
|
|
|
|
|
|
|
/* set borders */
|
2007-09-05 20:15:00 +02:00
|
|
|
wc.border_width = c->border;
|
2007-12-27 23:10:43 +01:00
|
|
|
XConfigureWindow(globalconf.display, w, CWBorderWidth, &wc);
|
|
|
|
XSetWindowBorder(globalconf.display, w, globalconf.screens[screen].colors_normal[ColBorder].pixel);
|
2007-10-22 16:25:27 +02:00
|
|
|
|
2007-10-17 17:29:21 +02:00
|
|
|
/* propagates border_width, if size doesn't change */
|
2007-12-27 23:10:43 +01:00
|
|
|
window_configure(globalconf.display, c->win, c->x, c->y, c->w, c->h, c->border);
|
2007-10-22 16:25:27 +02:00
|
|
|
|
|
|
|
/* update sizehint */
|
2007-12-14 16:05:10 +01:00
|
|
|
client_updatesizehints(c);
|
2007-10-22 16:25:27 +02:00
|
|
|
|
2007-12-27 23:10:43 +01:00
|
|
|
XSelectInput(globalconf.display, w, StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
2007-10-22 16:25:27 +02:00
|
|
|
|
|
|
|
/* handle xshape */
|
2007-12-16 02:45:38 +01:00
|
|
|
if(globalconf.have_shape)
|
2007-09-13 15:57:35 +02:00
|
|
|
{
|
2007-12-27 23:10:43 +01:00
|
|
|
XShapeSelectInput(globalconf.display, w, ShapeNotifyMask);
|
|
|
|
window_setshape(globalconf.display, c->phys_screen, c->win);
|
2007-09-13 15:57:35 +02:00
|
|
|
}
|
2007-10-22 16:25:27 +02:00
|
|
|
|
|
|
|
/* grab buttons */
|
2007-12-27 23:10:43 +01:00
|
|
|
window_grabbuttons(globalconf.display, c->phys_screen, c->win, False, True);
|
2007-10-22 16:25:27 +02:00
|
|
|
|
|
|
|
/* check for transient and set tags like its parent */
|
2007-12-27 23:10:43 +01:00
|
|
|
if((rettrans = XGetTransientForHint(globalconf.display, w, &trans) == Success)
|
2007-12-16 02:45:38 +01:00
|
|
|
&& (t = get_client_bywin(globalconf.clients, trans)))
|
|
|
|
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
|
2007-12-27 23:05:34 +01:00
|
|
|
if(is_client_tagged(t, tag))
|
2007-12-27 22:43:59 +01:00
|
|
|
tag_client(c, tag);
|
2007-10-22 16:25:27 +02:00
|
|
|
|
|
|
|
/* should be floating if transsient or fixed) */
|
2007-09-05 20:15:00 +02:00
|
|
|
if(!c->isfloating)
|
|
|
|
c->isfloating = (rettrans == Success) || c->isfixed;
|
2007-10-22 16:25:27 +02:00
|
|
|
|
|
|
|
/* save new props */
|
2007-12-16 02:45:38 +01:00
|
|
|
client_saveprops(c, c->screen);
|
2007-10-22 16:25:27 +02:00
|
|
|
|
|
|
|
/* attach to the stack */
|
2007-12-16 02:45:38 +01:00
|
|
|
client_attach(c);
|
2007-10-22 16:25:27 +02:00
|
|
|
|
|
|
|
/* some windows require this */
|
2007-12-27 23:10:43 +01:00
|
|
|
XMoveResizeWindow(globalconf.display, c->win, c->x, c->y, c->w, c->h);
|
2007-10-22 16:25:27 +02:00
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
focus(c, True, screen);
|
2007-10-25 19:47:37 +02:00
|
|
|
|
2007-12-27 22:39:29 +01:00
|
|
|
ewmh_check_client_hints(c);
|
2007-12-27 16:19:05 +01:00
|
|
|
ewmh_update_net_client_list(c->phys_screen);
|
|
|
|
|
2007-10-22 16:25:27 +02:00
|
|
|
/* rearrange to display new window */
|
2007-12-16 02:45:38 +01:00
|
|
|
arrange(screen);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-12-16 02:45:38 +01:00
|
|
|
client_resize(Client *c, int x, int y, int w, int h,
|
2007-10-29 15:24:10 +01:00
|
|
|
Bool sizehints, Bool volatile_coords)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
double dx, dy, max, min, ratio;
|
|
|
|
XWindowChanges wc;
|
2007-12-23 00:54:59 +01:00
|
|
|
Area area;
|
2007-12-27 13:22:40 +01:00
|
|
|
Tag **curtags;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
|
|
|
if(sizehints)
|
|
|
|
{
|
|
|
|
if(c->minay > 0 && c->maxay > 0 && (h - c->baseh) > 0 && (w - c->basew) > 0)
|
|
|
|
{
|
|
|
|
dx = (double) (w - c->basew);
|
|
|
|
dy = (double) (h - 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;
|
|
|
|
w = (int) dx + c->basew;
|
|
|
|
h = (int) dy + c->baseh;
|
|
|
|
}
|
|
|
|
else if(ratio > max)
|
|
|
|
{
|
|
|
|
dy = (dx * min + dy) / (max * max + 1);
|
|
|
|
dx = dy * min;
|
|
|
|
w = (int) dx + c->basew;
|
|
|
|
h = (int) dy + c->baseh;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(c->minw && w < c->minw)
|
|
|
|
w = c->minw;
|
|
|
|
if(c->minh && h < c->minh)
|
|
|
|
h = c->minh;
|
|
|
|
if(c->maxw && w > c->maxw)
|
|
|
|
w = c->maxw;
|
|
|
|
if(c->maxh && h > c->maxh)
|
|
|
|
h = c->maxh;
|
|
|
|
if(c->incw)
|
|
|
|
w -= (w - c->basew) % c->incw;
|
|
|
|
if(c->inch)
|
|
|
|
h -= (h - c->baseh) % c->inch;
|
|
|
|
}
|
|
|
|
if(w <= 0 || h <= 0)
|
|
|
|
return;
|
|
|
|
/* offscreen appearance fixes */
|
2007-12-23 00:54:59 +01:00
|
|
|
area = get_display_area(c->phys_screen,
|
|
|
|
NULL,
|
|
|
|
&globalconf.screens[c->screen].padding);
|
|
|
|
if(x > area.width)
|
|
|
|
x = area.width - w - 2 * c->border;
|
|
|
|
if(y > area.height)
|
|
|
|
y = area.height - h - 2 * c->border;
|
2007-09-07 17:36:21 +02:00
|
|
|
if(x + w + 2 * c->border < 0)
|
|
|
|
x = 0;
|
|
|
|
if(y + h + 2 * c->border < 0)
|
|
|
|
y = 0;
|
2007-09-05 20:15:00 +02:00
|
|
|
if(c->x != x || c->y != y || c->w != w || c->h != h)
|
|
|
|
{
|
|
|
|
c->x = wc.x = x;
|
|
|
|
c->y = wc.y = y;
|
|
|
|
c->w = wc.width = w;
|
|
|
|
c->h = wc.height = h;
|
2007-12-27 13:22:40 +01:00
|
|
|
curtags = get_current_tags(c->screen);
|
2007-10-29 15:24:10 +01:00
|
|
|
if(!volatile_coords
|
|
|
|
&& (c->isfloating
|
2007-12-27 13:22:40 +01:00
|
|
|
|| curtags[0]->layout->arrange == layout_floating))
|
2007-10-25 13:57:02 +02:00
|
|
|
{
|
|
|
|
c->rx = c->x;
|
|
|
|
c->ry = c->y;
|
2007-11-10 10:12:50 +01:00
|
|
|
c->rw = c->w;
|
|
|
|
c->rh = c->h;
|
2007-10-25 13:57:02 +02:00
|
|
|
}
|
2007-12-27 13:22:40 +01:00
|
|
|
p_delete(&curtags);
|
2007-09-05 20:15:00 +02:00
|
|
|
wc.border_width = c->border;
|
2007-12-27 23:10:43 +01:00
|
|
|
XConfigureWindow(globalconf.display, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc);
|
|
|
|
window_configure(globalconf.display, c->win, c->x, c->y, c->w, c->h, c->border);
|
|
|
|
XSync(globalconf.display, False);
|
|
|
|
if((c->x >= 0 || c->y >= 0) && XineramaIsActive(globalconf.display))
|
2007-09-28 11:30:51 +02:00
|
|
|
{
|
2007-12-18 09:02:08 +01:00
|
|
|
int new_screen = get_screen_bycoord(c->x, c->y);
|
2007-11-10 17:59:33 +01:00
|
|
|
if(c->screen != new_screen)
|
2007-12-16 02:45:38 +01:00
|
|
|
move_client_to_screen(c, new_screen, False);
|
2007-09-28 11:30:51 +02:00
|
|
|
}
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-12-16 02:45:38 +01:00
|
|
|
client_saveprops(Client * c, int screen)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-12-14 19:02:38 +01:00
|
|
|
int i = 0, ntags = 0;
|
2007-09-07 11:18:27 +02:00
|
|
|
char *prop;
|
2007-12-14 19:02:38 +01:00
|
|
|
Tag *tag;
|
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
|
2007-12-14 19:02:38 +01:00
|
|
|
ntags++;
|
2007-09-07 11:18:27 +02:00
|
|
|
|
2007-12-14 19:02:38 +01:00
|
|
|
prop = p_new(char, ntags + 2);
|
2007-09-06 22:02:50 +02:00
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next, i++)
|
2007-12-27 23:05:34 +01:00
|
|
|
prop[i] = is_client_tagged(c, tag) ? '1' : '0';
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2007-12-14 19:02:38 +01:00
|
|
|
if(i <= ntags)
|
2007-09-07 11:18:27 +02:00
|
|
|
prop[i] = c->isfloating ? '1' : '0';
|
|
|
|
|
|
|
|
prop[++i] = '\0';
|
|
|
|
|
2007-12-27 23:10:43 +01:00
|
|
|
XChangeProperty(globalconf.display, c->win, AWESOMEPROPS_ATOM(globalconf.display), XA_STRING, 8,
|
2007-09-05 20:15:00 +02:00
|
|
|
PropModeReplace, (unsigned char *) prop, i);
|
2007-09-07 11:18:27 +02:00
|
|
|
|
|
|
|
p_delete(&prop);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-10-26 19:50:39 +02:00
|
|
|
client_unban(Client *c)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-12-27 23:10:43 +01:00
|
|
|
XMapWindow(globalconf.display, c->win);
|
|
|
|
window_setstate(globalconf.display, c->win, NormalState);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-12-16 02:45:38 +01:00
|
|
|
client_unmanage(Client *c, long state)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
XWindowChanges wc;
|
2007-12-14 19:02:38 +01:00
|
|
|
Tag *tag;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
|
|
|
wc.border_width = c->oldborder;
|
|
|
|
/* The server grab construct avoids race conditions. */
|
2007-12-27 23:10:43 +01:00
|
|
|
XGrabServer(globalconf.display);
|
|
|
|
XConfigureWindow(globalconf.display, c->win, CWBorderWidth, &wc); /* restore border */
|
2007-12-16 02:45:38 +01:00
|
|
|
client_detach(c);
|
|
|
|
if(globalconf.focus->client == c)
|
|
|
|
focus(NULL, True, c->screen);
|
2007-12-17 03:56:29 +01:00
|
|
|
focus_delete_client(c);
|
2007-12-16 02:45:38 +01:00
|
|
|
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
|
2007-12-27 22:43:59 +01:00
|
|
|
untag_client(c, tag);
|
2007-12-27 23:10:43 +01:00
|
|
|
XUngrabButton(globalconf.display, AnyButton, AnyModifier, c->win);
|
|
|
|
window_setstate(globalconf.display, c->win, state);
|
|
|
|
XSync(globalconf.display, False);
|
2007-09-05 20:15:00 +02:00
|
|
|
XSetErrorHandler(xerror);
|
2007-12-27 23:10:43 +01:00
|
|
|
XUngrabServer(globalconf.display);
|
2007-09-05 20:15:00 +02:00
|
|
|
if(state != NormalState)
|
2007-12-16 02:45:38 +01:00
|
|
|
arrange(c->screen);
|
2007-09-05 20:15:00 +02:00
|
|
|
p_delete(&c);
|
|
|
|
}
|
|
|
|
|
2007-12-23 15:16:10 +01:00
|
|
|
void
|
|
|
|
client_updatewmhints(Client *c)
|
|
|
|
{
|
|
|
|
XWMHints *wmh;
|
|
|
|
|
|
|
|
if((wmh = XGetWMHints(globalconf.display, c->win)))
|
|
|
|
{
|
|
|
|
c->isurgent = (wmh->flags & XUrgencyHint);
|
|
|
|
XFree(wmh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-05 20:15:00 +02:00
|
|
|
void
|
2007-12-14 16:05:10 +01:00
|
|
|
client_updatesizehints(Client *c)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
long msize;
|
|
|
|
XSizeHints size;
|
|
|
|
|
2007-12-27 23:10:43 +01:00
|
|
|
if(!XGetWMNormalHints(globalconf.display, c->win, &size, &msize) || !size.flags)
|
2007-09-05 20:15:00 +02:00
|
|
|
size.flags = PSize;
|
|
|
|
c->flags = size.flags;
|
|
|
|
if(c->flags & PBaseSize)
|
|
|
|
{
|
|
|
|
c->basew = size.base_width;
|
|
|
|
c->baseh = size.base_height;
|
|
|
|
}
|
|
|
|
else if(c->flags & PMinSize)
|
|
|
|
{
|
|
|
|
c->basew = size.min_width;
|
|
|
|
c->baseh = size.min_height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
c->basew = c->baseh = 0;
|
|
|
|
if(c->flags & PResizeInc)
|
|
|
|
{
|
|
|
|
c->incw = size.width_inc;
|
|
|
|
c->inch = size.height_inc;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
c->incw = c->inch = 0;
|
|
|
|
|
|
|
|
if(c->flags & PMaxSize)
|
|
|
|
{
|
|
|
|
c->maxw = size.max_width;
|
|
|
|
c->maxh = size.max_height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
c->maxw = c->maxh = 0;
|
|
|
|
|
|
|
|
if(c->flags & PMinSize)
|
|
|
|
{
|
|
|
|
c->minw = size.min_width;
|
|
|
|
c->minh = size.min_height;
|
|
|
|
}
|
|
|
|
else if(c->flags & PBaseSize)
|
|
|
|
{
|
|
|
|
c->minw = size.base_width;
|
|
|
|
c->minh = size.base_height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
c->minw = c->minh = 0;
|
|
|
|
|
|
|
|
if(c->flags & PAspect)
|
|
|
|
{
|
|
|
|
c->minax = size.min_aspect.x;
|
|
|
|
c->maxax = size.max_aspect.x;
|
|
|
|
c->minay = size.min_aspect.y;
|
|
|
|
c->maxay = size.max_aspect.y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
c->minax = c->maxax = c->minay = c->maxay = 0;
|
|
|
|
|
|
|
|
c->isfixed = (c->maxw && c->minw && c->maxh && c->minh
|
|
|
|
&& c->maxw == c->minw && c->maxh == c->minh);
|
|
|
|
}
|
|
|
|
|
2007-12-14 16:38:12 +01:00
|
|
|
/** Returns True if a client is tagged
|
|
|
|
* with one of the tags
|
|
|
|
* \return True or False
|
|
|
|
*/
|
|
|
|
Bool
|
2007-12-16 02:45:38 +01:00
|
|
|
client_isvisible(Client *c, int screen)
|
2007-12-14 16:38:12 +01:00
|
|
|
{
|
2007-12-14 19:02:38 +01:00
|
|
|
Tag *tag;
|
2007-12-14 16:38:12 +01:00
|
|
|
|
|
|
|
if(c->screen != screen)
|
|
|
|
return False;
|
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
|
2007-12-27 23:05:34 +01:00
|
|
|
if(tag->selected && is_client_tagged(c, tag))
|
2007-12-14 16:38:12 +01:00
|
|
|
return True;
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
2007-09-20 21:27:43 +02:00
|
|
|
/** Set selected client transparency
|
2007-12-19 04:26:20 +01:00
|
|
|
* \param screen Screen ID
|
2007-09-20 21:27:43 +02:00
|
|
|
* \param arg unused arg
|
|
|
|
* \ingroup ui_callback
|
|
|
|
*/
|
2007-09-05 20:15:00 +02:00
|
|
|
void
|
2007-12-17 01:17:54 +01:00
|
|
|
uicb_client_settrans(int screen __attribute__ ((unused)), char *arg)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-10-09 23:47:45 +02:00
|
|
|
double delta = 100.0, current_opacity = 100.0;
|
2007-09-05 20:15:00 +02:00
|
|
|
unsigned char *data;
|
|
|
|
Atom actual;
|
|
|
|
int format;
|
|
|
|
unsigned long n, left;
|
2007-09-14 13:50:46 +02:00
|
|
|
unsigned int current_opacity_raw = 0;
|
2007-09-05 20:15:00 +02:00
|
|
|
int set_prop = 0;
|
2007-12-16 02:45:38 +01:00
|
|
|
Client *sel = globalconf.focus->client;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2007-10-26 23:19:13 +02:00
|
|
|
if(!sel)
|
2007-09-05 20:15:00 +02:00
|
|
|
return;
|
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
XGetWindowProperty(globalconf.display, sel->win,
|
2007-12-27 23:10:43 +01:00
|
|
|
XInternAtom(globalconf.display, "_NET_WM_WINDOW_OPACITY", False),
|
2007-09-14 13:50:46 +02:00
|
|
|
0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left,
|
|
|
|
(unsigned char **) &data);
|
|
|
|
if(data)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-09-14 13:50:46 +02:00
|
|
|
memcpy(¤t_opacity_raw, data, sizeof(unsigned int));
|
|
|
|
XFree(data);
|
|
|
|
current_opacity = (current_opacity_raw * 100.0) / 0xffffffff;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
2007-09-14 13:50:46 +02:00
|
|
|
else
|
|
|
|
set_prop = 1;
|
|
|
|
|
|
|
|
delta = compute_new_value_from_arg(arg, current_opacity);
|
2007-09-05 20:15:00 +02:00
|
|
|
|
|
|
|
if(delta <= 0.0)
|
|
|
|
delta = 0.0;
|
|
|
|
else if(delta > 100.0)
|
|
|
|
{
|
|
|
|
delta = 100.0;
|
|
|
|
set_prop = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(delta == 100.0 && !set_prop)
|
2007-12-27 23:10:43 +01:00
|
|
|
window_settrans(globalconf.display, sel->win, -1);
|
2007-09-05 20:15:00 +02:00
|
|
|
else
|
2007-12-27 23:10:43 +01:00
|
|
|
window_settrans(globalconf.display, sel->win, delta);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
2007-09-18 23:36:52 +02:00
|
|
|
|
|
|
|
|
2007-12-14 08:47:21 +01:00
|
|
|
/** Set border size
|
2007-12-19 04:26:20 +01:00
|
|
|
* \param screen Screen ID
|
2007-09-18 23:36:52 +02:00
|
|
|
* \param arg X, +X or -X
|
2007-09-20 21:27:43 +02:00
|
|
|
* \ingroup ui_callback
|
2007-09-18 23:36:52 +02:00
|
|
|
*/
|
|
|
|
void
|
2007-12-17 01:17:54 +01:00
|
|
|
uicb_setborder(int screen, char *arg)
|
2007-09-18 23:36:52 +02:00
|
|
|
{
|
|
|
|
if(!arg)
|
|
|
|
return;
|
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
if((globalconf.screens[screen].borderpx = (int) compute_new_value_from_arg(arg, (double) globalconf.screens[screen].borderpx)) < 0)
|
|
|
|
globalconf.screens[screen].borderpx = 0;
|
2007-09-18 23:36:52 +02:00
|
|
|
}
|
|
|
|
|
2007-12-19 04:26:20 +01:00
|
|
|
/** Swap current with next client
|
2007-12-19 04:39:59 +01:00
|
|
|
* \param screen Screen ID
|
|
|
|
* \param arg nothing
|
2007-12-19 04:26:20 +01:00
|
|
|
* \ingroup ui_callback
|
|
|
|
*/
|
2007-09-25 12:41:36 +02:00
|
|
|
void
|
2007-12-17 01:17:54 +01:00
|
|
|
uicb_client_swapnext(int screen, char *arg __attribute__ ((unused)))
|
2007-09-25 12:41:36 +02:00
|
|
|
{
|
2007-12-16 02:45:38 +01:00
|
|
|
Client *next, *sel = globalconf.focus->client;
|
2007-09-25 12:41:36 +02:00
|
|
|
|
2007-10-15 21:17:32 +02:00
|
|
|
if(!sel)
|
2007-09-25 12:41:36 +02:00
|
|
|
return;
|
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
for(next = sel->next; next && !client_isvisible(next, screen); next = next->next);
|
2007-09-25 12:41:36 +02:00
|
|
|
if(next)
|
|
|
|
{
|
2007-12-16 02:45:38 +01:00
|
|
|
client_swap(&globalconf.clients, sel, next);
|
|
|
|
arrange(screen);
|
2007-10-15 21:17:32 +02:00
|
|
|
/* restore focus */
|
2007-12-16 02:45:38 +01:00
|
|
|
focus(sel, True, screen);
|
2007-09-25 12:41:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-19 04:26:20 +01:00
|
|
|
/** Swap current with previous client
|
2007-12-19 04:39:59 +01:00
|
|
|
* \param screen Screen ID
|
|
|
|
* \param arg nothing
|
2007-12-19 04:26:20 +01:00
|
|
|
* \ingroup ui_callback
|
|
|
|
*/
|
2007-09-25 12:41:36 +02:00
|
|
|
void
|
2007-12-17 01:17:54 +01:00
|
|
|
uicb_client_swapprev(int screen, char *arg __attribute__ ((unused)))
|
2007-09-25 12:41:36 +02:00
|
|
|
{
|
2007-12-16 02:45:38 +01:00
|
|
|
Client *prev, *sel = globalconf.focus->client;
|
2007-09-25 12:41:36 +02:00
|
|
|
|
2007-10-15 21:17:32 +02:00
|
|
|
if(!sel)
|
2007-09-25 12:41:36 +02:00
|
|
|
return;
|
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
for(prev = sel->prev; prev && !client_isvisible(prev, screen); prev = prev->prev);
|
2007-09-25 12:41:36 +02:00
|
|
|
if(prev)
|
|
|
|
{
|
2007-12-16 02:45:38 +01:00
|
|
|
client_swap(&globalconf.clients, prev, sel);
|
|
|
|
arrange(screen);
|
2007-10-15 21:17:32 +02:00
|
|
|
/* restore focus */
|
2007-12-16 02:45:38 +01:00
|
|
|
focus(sel, True, screen);
|
2007-09-25 12:41:36 +02:00
|
|
|
}
|
|
|
|
}
|
2007-10-01 20:42:59 +02:00
|
|
|
|
2007-12-19 04:26:20 +01:00
|
|
|
/** Move and resize client
|
|
|
|
* \param screen Screen ID
|
|
|
|
* \param arg x y w h
|
|
|
|
* \ingroup ui_callback
|
|
|
|
*/
|
2007-10-01 20:42:59 +02:00
|
|
|
void
|
2007-12-17 01:17:54 +01:00
|
|
|
uicb_client_moveresize(int screen, char *arg)
|
2007-10-01 20:42:59 +02:00
|
|
|
{
|
|
|
|
int nx, ny, nw, nh, ox, oy, ow, oh;
|
|
|
|
char x[8], y[8], w[8], h[8];
|
|
|
|
int mx, my, dx, dy, nmx, nmy;
|
|
|
|
unsigned int dui;
|
|
|
|
Window dummy;
|
2007-12-16 02:45:38 +01:00
|
|
|
Client *sel = globalconf.focus->client;
|
2007-12-27 13:22:40 +01:00
|
|
|
Tag **curtags = get_current_tags(screen);
|
2007-10-01 20:42:59 +02:00
|
|
|
|
2007-12-27 13:22:40 +01:00
|
|
|
if(curtags[0]->layout->arrange != layout_floating)
|
2007-10-26 23:19:13 +02:00
|
|
|
if(!sel || !sel->isfloating || sel->isfixed || !arg)
|
2007-12-27 13:22:40 +01:00
|
|
|
{
|
|
|
|
p_delete(&curtags);
|
2007-10-01 20:42:59 +02:00
|
|
|
return;
|
2007-12-27 13:22:40 +01:00
|
|
|
}
|
|
|
|
p_delete(&curtags);
|
2007-10-01 20:42:59 +02:00
|
|
|
if(sscanf(arg, "%s %s %s %s", x, y, w, h) != 4)
|
|
|
|
return;
|
2007-10-26 23:19:13 +02:00
|
|
|
nx = (int) compute_new_value_from_arg(x, sel->x);
|
|
|
|
ny = (int) compute_new_value_from_arg(y, sel->y);
|
|
|
|
nw = (int) compute_new_value_from_arg(w, sel->w);
|
|
|
|
nh = (int) compute_new_value_from_arg(h, sel->h);
|
2007-10-11 23:12:05 +02:00
|
|
|
|
2007-10-26 23:19:13 +02:00
|
|
|
ox = sel->x;
|
|
|
|
oy = sel->y;
|
|
|
|
ow = sel->w;
|
|
|
|
oh = sel->h;
|
2007-10-11 23:12:05 +02:00
|
|
|
|
2007-12-19 04:26:20 +01:00
|
|
|
Bool xqp = XQueryPointer(globalconf.display,
|
|
|
|
RootWindow(globalconf.display,
|
|
|
|
get_phys_screen(screen)),
|
|
|
|
&dummy, &dummy, &mx, &my, &dx, &dy, &dui);
|
2007-12-16 02:45:38 +01:00
|
|
|
client_resize(sel, nx, ny, nw, nh, True, False);
|
2007-10-01 20:42:59 +02:00
|
|
|
if (xqp && ox <= mx && (ox + ow) >= mx && oy <= my && (oy + oh) >= my)
|
|
|
|
{
|
2007-10-26 23:19:13 +02:00
|
|
|
nmx = mx - ox + sel->w - ow - 1 < 0 ? 0 : mx - ox + sel->w - ow - 1;
|
|
|
|
nmy = my - oy + sel->h - oh - 1 < 0 ? 0 : my - oy + sel->h - oh - 1;
|
2007-12-19 04:26:20 +01:00
|
|
|
XWarpPointer(globalconf.display,
|
|
|
|
None, sel->win,
|
|
|
|
0, 0, 0, 0, nmx, nmy);
|
2007-10-01 20:42:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-27 20:49:38 +01:00
|
|
|
|
2007-10-01 20:42:59 +02:00
|
|
|
void
|
2007-12-27 20:49:38 +01:00
|
|
|
client_kill(Client *c)
|
2007-10-01 20:42:59 +02:00
|
|
|
{
|
|
|
|
XEvent ev;
|
|
|
|
|
2007-12-27 23:10:43 +01:00
|
|
|
if(isprotodel(globalconf.display, c->win))
|
2007-10-01 20:42:59 +02:00
|
|
|
{
|
|
|
|
ev.type = ClientMessage;
|
2007-12-27 20:49:38 +01:00
|
|
|
ev.xclient.window = c->win;
|
2007-12-16 02:45:38 +01:00
|
|
|
ev.xclient.message_type = XInternAtom(globalconf.display, "WM_PROTOCOLS", False);
|
2007-10-01 20:42:59 +02:00
|
|
|
ev.xclient.format = 32;
|
2007-12-16 02:45:38 +01:00
|
|
|
ev.xclient.data.l[0] = XInternAtom(globalconf.display, "WM_DELETE_WINDOW", False);
|
2007-10-01 20:42:59 +02:00
|
|
|
ev.xclient.data.l[1] = CurrentTime;
|
2007-12-27 20:49:38 +01:00
|
|
|
XSendEvent(globalconf.display, c->win, False, NoEventMask, &ev);
|
2007-10-01 20:42:59 +02:00
|
|
|
}
|
|
|
|
else
|
2007-12-27 20:49:38 +01:00
|
|
|
XKillClient(globalconf.display, c->win);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Kill selected client
|
|
|
|
* \param screen Screen ID
|
|
|
|
* \param arg unused
|
|
|
|
* \ingroup ui_callback
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
uicb_client_kill(int screen __attribute__ ((unused)), char *arg __attribute__ ((unused)))
|
|
|
|
{
|
|
|
|
Client *sel = globalconf.focus->client;
|
|
|
|
|
|
|
|
if(sel)
|
|
|
|
client_kill(sel);
|
2007-10-01 20:42:59 +02:00
|
|
|
}
|
2007-12-18 09:24:15 +01:00
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|