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-12 14:31:19 +02:00
|
|
|
#include <X11/Xutil.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-10-15 20:23:54 +02:00
|
|
|
#include "tab.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-09-15 15:16:53 +02:00
|
|
|
#include "util.h"
|
|
|
|
#include "statusbar.h"
|
2007-09-05 20:15:00 +02:00
|
|
|
#include "layouts/floating.h"
|
|
|
|
|
2007-10-16 22:40:02 +02:00
|
|
|
Client *
|
|
|
|
get_client_bywin(Client **list, Window w)
|
|
|
|
{
|
|
|
|
Client *c;
|
|
|
|
|
|
|
|
for(c = *list; c && c->win != w; c = c->next);
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2007-09-05 20:15:00 +02:00
|
|
|
/** Grab or ungrab buttons when a client is focused
|
|
|
|
* \param c client
|
|
|
|
* \param focused True if client is focused
|
2007-10-11 06:46:28 +02:00
|
|
|
* \param raised True if the client is above other clients
|
2007-09-05 20:15:00 +02:00
|
|
|
* \param modkey Mod key mask
|
|
|
|
* \param numlockmask Numlock mask
|
|
|
|
*/
|
2007-10-11 06:46:28 +02:00
|
|
|
void
|
|
|
|
grabbuttons(Client * c, Bool focused, Bool raised, KeySym modkey, unsigned int numlockmask)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
XUngrabButton(c->display, AnyButton, AnyModifier, c->win);
|
|
|
|
|
|
|
|
if(focused)
|
|
|
|
{
|
2007-10-11 15:23:33 +02:00
|
|
|
if(!raised)
|
2007-10-11 11:33:40 +02:00
|
|
|
{
|
2007-10-11 15:23:33 +02:00
|
|
|
XGrabButton(c->display, Button1, NoSymbol, c->win, False,
|
2007-10-16 01:24:04 +02:00
|
|
|
BUTTONMASK, GrabModeSync, GrabModeAsync, None, None);
|
2007-10-11 06:46:28 +02:00
|
|
|
}
|
|
|
|
|
2007-09-05 20:15:00 +02:00
|
|
|
XGrabButton(c->display, Button1, modkey, c->win, False, BUTTONMASK,
|
|
|
|
GrabModeAsync, GrabModeSync, None, None);
|
|
|
|
XGrabButton(c->display, Button1, modkey | LockMask, c->win, False,
|
|
|
|
BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
|
|
|
XGrabButton(c->display, Button1, modkey | numlockmask, c->win, False,
|
|
|
|
BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
|
|
|
XGrabButton(c->display, Button1, modkey | numlockmask | LockMask,
|
|
|
|
c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
|
|
|
|
|
|
|
XGrabButton(c->display, Button2, modkey, c->win, False, BUTTONMASK,
|
|
|
|
GrabModeAsync, GrabModeSync, None, None);
|
|
|
|
XGrabButton(c->display, Button2, modkey | LockMask, c->win, False,
|
|
|
|
BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
|
|
|
XGrabButton(c->display, Button2, modkey | numlockmask, c->win, False,
|
|
|
|
BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
|
|
|
XGrabButton(c->display, Button2, modkey | numlockmask | LockMask,
|
|
|
|
c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
|
|
|
|
|
|
|
XGrabButton(c->display, Button3, modkey, c->win, False, BUTTONMASK,
|
|
|
|
GrabModeAsync, GrabModeSync, None, None);
|
|
|
|
XGrabButton(c->display, Button3, modkey | LockMask, c->win, False,
|
|
|
|
BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
|
|
|
XGrabButton(c->display, Button3, modkey | numlockmask, c->win, False,
|
|
|
|
BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
|
|
|
XGrabButton(c->display, Button3, modkey | numlockmask | LockMask,
|
|
|
|
c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
|
|
|
|
2007-10-09 23:47:45 +02:00
|
|
|
XGrabButton(c->display, Button4, modkey, c->win, False, BUTTONMASK,
|
|
|
|
GrabModeAsync, GrabModeSync, None, None);
|
|
|
|
XGrabButton(c->display, Button4, modkey | LockMask, c->win, False,
|
|
|
|
BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
|
|
|
XGrabButton(c->display, Button4, modkey | numlockmask, c->win, False,
|
|
|
|
BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
|
|
|
XGrabButton(c->display, Button4, modkey | numlockmask | LockMask,
|
|
|
|
c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
|
|
|
|
|
|
|
XGrabButton(c->display, Button5, modkey, c->win, False, BUTTONMASK,
|
|
|
|
GrabModeAsync, GrabModeSync, None, None);
|
|
|
|
XGrabButton(c->display, Button5, modkey | LockMask, c->win, False,
|
|
|
|
BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
|
|
|
XGrabButton(c->display, Button5, modkey | numlockmask, c->win, False,
|
|
|
|
BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
|
|
|
XGrabButton(c->display, Button5, modkey | numlockmask | LockMask,
|
|
|
|
c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
|
|
|
|
2007-10-01 15:23:05 +02:00
|
|
|
XUngrabButton(c->display, AnyButton, AnyModifier, RootWindow(c->display, c->phys_screen));
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
XGrabButton(c->display, AnyButton, AnyModifier, c->win, False, BUTTONMASK,
|
|
|
|
GrabModeAsync, GrabModeSync, None, None);
|
2007-10-11 15:23:33 +02:00
|
|
|
|
2007-10-01 15:23:05 +02:00
|
|
|
XGrabButton(c->display, Button4, NoSymbol, RootWindow(c->display, c->phys_screen), False, BUTTONMASK,
|
2007-09-05 20:15:00 +02:00
|
|
|
GrabModeAsync, GrabModeSync, None, None);
|
2007-10-01 15:23:05 +02:00
|
|
|
XGrabButton(c->display, Button4, LockMask, RootWindow(c->display, c->phys_screen), False, BUTTONMASK,
|
2007-09-05 20:15:00 +02:00
|
|
|
GrabModeAsync, GrabModeSync, None, None);
|
2007-10-01 15:23:05 +02:00
|
|
|
XGrabButton(c->display, Button4, numlockmask, RootWindow(c->display, c->phys_screen), False, BUTTONMASK,
|
2007-09-05 20:15:00 +02:00
|
|
|
GrabModeAsync, GrabModeSync, None, None);
|
2007-10-01 15:23:05 +02:00
|
|
|
XGrabButton(c->display, Button4, numlockmask | LockMask, RootWindow(c->display, c->phys_screen), False, BUTTONMASK,
|
2007-09-05 20:15:00 +02:00
|
|
|
GrabModeAsync, GrabModeSync, None, None);
|
|
|
|
|
2007-10-01 15:23:05 +02:00
|
|
|
XGrabButton(c->display, Button5, NoSymbol, RootWindow(c->display, c->phys_screen), False, BUTTONMASK,
|
2007-09-05 20:15:00 +02:00
|
|
|
GrabModeAsync, GrabModeSync, None, None);
|
2007-10-01 15:23:05 +02:00
|
|
|
XGrabButton(c->display, Button5, LockMask, RootWindow(c->display, c->phys_screen), False, BUTTONMASK,
|
2007-09-05 20:15:00 +02:00
|
|
|
GrabModeAsync, GrabModeSync, None, None);
|
2007-10-01 15:23:05 +02:00
|
|
|
XGrabButton(c->display, Button5, numlockmask, RootWindow(c->display, c->phys_screen), False, BUTTONMASK,
|
2007-09-05 20:15:00 +02:00
|
|
|
GrabModeAsync, GrabModeSync, None, None);
|
2007-10-01 15:23:05 +02:00
|
|
|
XGrabButton(c->display, Button5, numlockmask | LockMask, RootWindow(c->display, c->phys_screen), False, BUTTONMASK,
|
2007-09-05 20:15:00 +02:00
|
|
|
GrabModeAsync, GrabModeSync, None, None);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-11 13:14:43 +02:00
|
|
|
/** Check if client supports protocol WM_DELETE_WINDOW
|
2007-09-05 20:15:00 +02:00
|
|
|
* \param c the client
|
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
|
|
|
|
isprotodel(Client * c)
|
|
|
|
{
|
|
|
|
int i, n;
|
|
|
|
Atom *protocols;
|
|
|
|
Bool ret = False;
|
|
|
|
|
|
|
|
if(XGetWMProtocols(c->display, c->win, &protocols, &n))
|
|
|
|
{
|
|
|
|
for(i = 0; !ret && i < n; i++)
|
2007-09-10 16:43:20 +02:00
|
|
|
if(protocols[i] == XInternAtom(c->display, "WM_DELETE_WINDOW", False))
|
2007-09-05 20:15:00 +02:00
|
|
|
ret = True;
|
|
|
|
XFree(protocols);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-09-11 13:14:43 +02:00
|
|
|
/** Set client WM_STATE property
|
2007-09-05 20:15:00 +02:00
|
|
|
* \param c the client
|
|
|
|
* \param state no idea
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
setclientstate(Client * c, long state)
|
|
|
|
{
|
|
|
|
long data[] = { state, None };
|
|
|
|
|
2007-09-10 16:47:20 +02:00
|
|
|
XChangeProperty(c->display, c->win, XInternAtom(c->display, "WM_STATE", False),
|
|
|
|
XInternAtom(c->display, "WM_STATE", False), 32,
|
2007-09-05 20:15:00 +02:00
|
|
|
PropModeReplace, (unsigned char *) data, 2);
|
|
|
|
}
|
|
|
|
|
2007-09-06 22:45:05 +02:00
|
|
|
/** Set client transparency using composite
|
|
|
|
* \param c client
|
|
|
|
* \param opacity opacity percentage
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
setclienttrans(Client *c, double opacity)
|
|
|
|
{
|
|
|
|
unsigned int real_opacity = 0xffffffff;
|
|
|
|
|
|
|
|
if(opacity >= 0 && opacity <= 100)
|
|
|
|
{
|
|
|
|
real_opacity = ((opacity / 100.0) * 0xffffffff);
|
|
|
|
XChangeProperty(c->display, c->win,
|
|
|
|
XInternAtom(c->display, "_NET_WM_WINDOW_OPACITY", False),
|
|
|
|
XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &real_opacity, 1L);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
XDeleteProperty(c->display, c->win, XInternAtom(c->display, "_NET_WM_WINDOW_OPACITY", False));
|
|
|
|
|
|
|
|
XSync(c->display, False);
|
|
|
|
}
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2007-09-25 12:41:36 +02:00
|
|
|
/** Swap two client in the linked list clients
|
|
|
|
* \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-09-05 20:15:00 +02:00
|
|
|
/** Attach client to the beginning of the clients stack
|
|
|
|
* \param c the client
|
|
|
|
*/
|
2007-10-01 20:44:02 +02:00
|
|
|
void
|
2007-10-11 21:50:32 +02:00
|
|
|
attach(Client **head, Client *c)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-10-11 21:50:32 +02:00
|
|
|
if(*head)
|
|
|
|
(*head)->prev = c;
|
|
|
|
c->next = *head;
|
|
|
|
*head = c;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2007-10-01 20:44:02 +02:00
|
|
|
void
|
2007-10-11 21:50:32 +02:00
|
|
|
updatetitle(Client *c)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-10-15 17:33:28 +02:00
|
|
|
if(!xgettextprop(c->display, c->win, XInternAtom(c->display, "_NET_WM_NAME", False), c->name, sizeof(c->name)))
|
|
|
|
xgettextprop(c->display, c->win, XInternAtom(c->display, "WM_NAME", False), c->name, sizeof(c->name));
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2007-09-20 21:27:43 +02:00
|
|
|
/** Ban client and unmapped it
|
2007-09-05 20:15:00 +02:00
|
|
|
* \param c the client
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ban(Client * c)
|
|
|
|
{
|
|
|
|
XUnmapWindow(c->display, c->win);
|
|
|
|
setclientstate(c, IconicState);
|
|
|
|
c->isbanned = True;
|
2007-09-19 00:03:54 +02:00
|
|
|
c->unmapped = True;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Configure client
|
|
|
|
* \param c the client
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
configure(Client * c)
|
|
|
|
{
|
|
|
|
XConfigureEvent ce;
|
|
|
|
|
|
|
|
ce.type = ConfigureNotify;
|
|
|
|
ce.display = c->display;
|
|
|
|
ce.event = c->win;
|
|
|
|
ce.window = c->win;
|
|
|
|
ce.x = c->x;
|
|
|
|
ce.y = c->y;
|
|
|
|
ce.width = c->w;
|
|
|
|
ce.height = c->h;
|
|
|
|
ce.border_width = c->border;
|
|
|
|
ce.above = None;
|
|
|
|
ce.override_redirect = False;
|
|
|
|
XSendEvent(c->display, c->win, False, StructureNotifyMask, (XEvent *) & ce);
|
|
|
|
}
|
|
|
|
|
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-10-11 21:50:32 +02:00
|
|
|
detach(Client **head, 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-10-11 21:50:32 +02:00
|
|
|
if(c == *head)
|
|
|
|
*head = 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 disp Display ref
|
|
|
|
* \param c client
|
2007-09-07 12:53:30 +02:00
|
|
|
* \param selscreen True if current screen is selected
|
2007-09-10 12:06:54 +02:00
|
|
|
* \param awesomeconf awesome config
|
2007-09-05 20:15:00 +02:00
|
|
|
*/
|
|
|
|
void
|
2007-10-15 18:25:29 +02:00
|
|
|
focus(Client * c, Bool selscreen, awesome_config *awesomeconf)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
/* if c is NULL or invisible, take next client in the stack */
|
2007-09-24 15:37:52 +02:00
|
|
|
if((!c && selscreen) || (c && !isvisible(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags)))
|
2007-10-12 11:43:07 +02:00
|
|
|
for(c = *awesomeconf->clients; c && !isvisible(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags); c = c->next);
|
2007-10-03 17:26:14 +02:00
|
|
|
|
2007-09-05 20:15:00 +02:00
|
|
|
/* if a client was selected but it's not the current client, unfocus it */
|
2007-10-11 23:12:05 +02:00
|
|
|
if(*awesomeconf->client_sel && *awesomeconf->client_sel != c)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-10-11 23:12:05 +02:00
|
|
|
grabbuttons(*awesomeconf->client_sel, False, True, awesomeconf->modkey, awesomeconf->numlockmask);
|
|
|
|
XSetWindowBorder(awesomeconf->display, (*awesomeconf->client_sel)->win, awesomeconf->colors_normal[ColBorder].pixel);
|
|
|
|
setclienttrans(*awesomeconf->client_sel, awesomeconf->opacity_unfocused);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
2007-10-15 16:57:54 +02:00
|
|
|
if(c)
|
|
|
|
{
|
|
|
|
if(c->tab.next || c->tab.prev)
|
|
|
|
XSetWindowBorder(awesomeconf->display, c->win, awesomeconf->colors_tab[ColBorder].pixel);
|
|
|
|
else
|
|
|
|
XSetWindowBorder(awesomeconf->display, c->win, awesomeconf->colors_selected[ColBorder].pixel);
|
|
|
|
}
|
2007-10-11 23:12:05 +02:00
|
|
|
if(*awesomeconf->client_sel == c)
|
2007-10-09 23:47:45 +02:00
|
|
|
return;
|
2007-09-05 20:15:00 +02:00
|
|
|
if(c)
|
2007-10-11 06:46:28 +02:00
|
|
|
grabbuttons(c, True, True, awesomeconf->modkey, awesomeconf->numlockmask);
|
2007-09-05 20:15:00 +02:00
|
|
|
if(!selscreen)
|
|
|
|
return;
|
2007-10-11 23:12:05 +02:00
|
|
|
*awesomeconf->client_sel = c;
|
2007-10-15 18:19:33 +02:00
|
|
|
drawstatusbar(awesomeconf);
|
2007-10-11 23:12:05 +02:00
|
|
|
if(*awesomeconf->client_sel)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-10-11 23:12:05 +02:00
|
|
|
XSetInputFocus(awesomeconf->display, (*awesomeconf->client_sel)->win, RevertToPointerRoot, CurrentTime);
|
2007-10-12 11:43:07 +02:00
|
|
|
for(c = *awesomeconf->clients; c; c = c->next)
|
2007-10-11 23:12:05 +02:00
|
|
|
if(c != *awesomeconf->client_sel)
|
2007-09-10 12:06:54 +02:00
|
|
|
setclienttrans(c, awesomeconf->opacity_unfocused);
|
2007-10-11 23:12:05 +02:00
|
|
|
setclienttrans(*awesomeconf->client_sel, -1);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
else
|
2007-10-15 18:25:29 +02:00
|
|
|
XSetInputFocus(awesomeconf->display, RootWindow(awesomeconf->display, awesomeconf->phys_screen), RevertToPointerRoot, CurrentTime);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2007-09-20 21:27:43 +02: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
|
|
|
|
* \param ntags tags number
|
|
|
|
*/
|
2007-09-05 20:15:00 +02:00
|
|
|
static Bool
|
|
|
|
loadprops(Client * c, int ntags)
|
|
|
|
{
|
|
|
|
int i;
|
2007-09-06 23:48:18 +02:00
|
|
|
char *prop;
|
2007-09-05 20:15:00 +02:00
|
|
|
Bool result = False;
|
|
|
|
|
2007-09-06 23:48:18 +02:00
|
|
|
prop = p_new(char, ntags + 2);
|
|
|
|
|
2007-09-12 15:01:35 +02:00
|
|
|
if(xgettextprop(c->display, c->win, AWESOMEPROPS_ATOM(c->display), prop, ntags + 2))
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-09-06 23:48:18 +02:00
|
|
|
for(i = 0; i < ntags && prop[i]; i++)
|
2007-09-05 20:15:00 +02:00
|
|
|
if((c->tags[i] = prop[i] == '1'))
|
|
|
|
result = True;
|
2007-09-06 23:48:18 +02:00
|
|
|
if(i <= ntags && prop[i])
|
2007-09-05 20:15:00 +02:00
|
|
|
c->isfloating = prop[i] == '1';
|
|
|
|
}
|
2007-09-06 23:48:18 +02:00
|
|
|
|
|
|
|
p_delete(&prop);
|
|
|
|
|
2007-09-05 20:15:00 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2007-09-20 21:27:43 +02:00
|
|
|
/** Manage a new client
|
|
|
|
* \param disp Display ref
|
|
|
|
* \param w The window
|
|
|
|
* \param wa Window attributes
|
|
|
|
* \param awesomeconf awesome config
|
|
|
|
*/
|
2007-09-05 20:15:00 +02:00
|
|
|
void
|
2007-10-10 14:09:36 +02:00
|
|
|
manage(Display *disp, Window w, XWindowAttributes *wa, awesome_config *awesomeconf)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
Client *c, *t = NULL;
|
|
|
|
Window trans;
|
|
|
|
Status rettrans;
|
|
|
|
XWindowChanges wc;
|
2007-10-03 20:46:03 +02:00
|
|
|
ScreenInfo *si = get_display_info(disp, awesomeconf->phys_screen, &awesomeconf->statusbar);
|
2007-10-01 16:43:01 +02:00
|
|
|
ScreenInfo *screen_info;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
|
|
|
c = p_new(Client, 1);
|
|
|
|
c->win = w;
|
|
|
|
c->ftview = True;
|
|
|
|
c->x = c->rw = wa->x;
|
|
|
|
c->y = c->ry = wa->y;
|
|
|
|
c->w = c->rw = wa->width;
|
|
|
|
c->h = c->rh = wa->height;
|
|
|
|
c->oldborder = wa->border_width;
|
|
|
|
c->display = disp;
|
2007-10-01 16:43:01 +02:00
|
|
|
c->phys_screen = get_phys_screen(c->display, c->screen);
|
2007-10-15 16:27:48 +02:00
|
|
|
c->tab.isvisible = True;
|
2007-10-01 20:58:29 +02:00
|
|
|
screen_info = get_screen_info(c->display, c->screen, NULL);
|
2007-10-01 16:43:01 +02:00
|
|
|
if(c->w == screen_info[c->screen].width && c->h == screen_info[c->screen].height)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-09-07 17:36:21 +02:00
|
|
|
c->x = 0;
|
|
|
|
c->y = 0;
|
2007-09-05 20:15:00 +02:00
|
|
|
c->border = wa->border_width;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-14 11:55:36 +02:00
|
|
|
if(c->x + c->w + 2 * c->border > si->x_org + si->width)
|
|
|
|
c->x = c->rx = si->x_org + si->width - c->w - 2 * c->border;
|
|
|
|
if(c->y + c->h + 2 * c->border > si->y_org + si->height)
|
|
|
|
c->y = c->ry = si->y_org + si->height - c->h - 2 * c->border;
|
|
|
|
if(c->x < si->x_org)
|
|
|
|
c->x = c->rx = si->x_org;
|
|
|
|
if(c->y < si->y_org)
|
|
|
|
c->y = c->ry = si->y_org;
|
2007-09-10 12:06:54 +02:00
|
|
|
c->border = awesomeconf->borderpx;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
2007-10-11 23:44:35 +02:00
|
|
|
p_delete(&si);
|
2007-09-05 20:15:00 +02:00
|
|
|
wc.border_width = c->border;
|
|
|
|
XConfigureWindow(disp, w, CWBorderWidth, &wc);
|
2007-10-10 13:07:12 +02:00
|
|
|
XSetWindowBorder(disp, w, awesomeconf->colors_normal[ColBorder].pixel);
|
2007-09-05 20:15:00 +02:00
|
|
|
configure(c); /* propagates border_width, if size doesn't change */
|
|
|
|
updatesizehints(c);
|
|
|
|
XSelectInput(disp, w, StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
2007-09-13 15:57:35 +02:00
|
|
|
if(awesomeconf->have_shape)
|
|
|
|
{
|
|
|
|
XShapeSelectInput(disp, w, ShapeNotifyMask);
|
|
|
|
set_shape(c);
|
|
|
|
}
|
2007-10-11 06:46:28 +02:00
|
|
|
grabbuttons(c, False, True, awesomeconf->modkey, awesomeconf->numlockmask);
|
2007-09-05 20:15:00 +02:00
|
|
|
updatetitle(c);
|
2007-09-28 16:40:20 +02:00
|
|
|
move_client_to_screen(c, awesomeconf, False);
|
2007-10-16 22:43:03 +02:00
|
|
|
if((rettrans = XGetTransientForHint(disp, w, &trans) == Success)
|
|
|
|
&& (t = get_client_bywin(awesomeconf->clients, trans)))
|
2007-09-10 12:06:54 +02:00
|
|
|
for(i = 0; i < awesomeconf->ntags; i++)
|
2007-09-05 20:15:00 +02:00
|
|
|
c->tags[i] = t->tags[i];
|
2007-09-10 12:06:54 +02:00
|
|
|
if(!loadprops(c, awesomeconf->ntags))
|
|
|
|
applyrules(c, awesomeconf);
|
2007-09-05 20:15:00 +02:00
|
|
|
if(!c->isfloating)
|
|
|
|
c->isfloating = (rettrans == Success) || c->isfixed;
|
2007-09-10 12:06:54 +02:00
|
|
|
saveprops(c, awesomeconf->ntags);
|
2007-10-11 21:50:32 +02:00
|
|
|
attach(awesomeconf->clients, c);
|
2007-09-05 20:15:00 +02:00
|
|
|
XMoveResizeWindow(disp, c->win, c->x, c->y, c->w, c->h); /* some windows require this */
|
2007-09-15 20:24:40 +02:00
|
|
|
c->isbanned = True;
|
2007-10-15 18:23:05 +02:00
|
|
|
arrange(awesomeconf);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-09-28 11:30:51 +02:00
|
|
|
resize(Client *c, int x, int y, int w, int h, awesome_config *awesomeconf, Bool sizehints)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
double dx, dy, max, min, ratio;
|
|
|
|
XWindowChanges wc;
|
2007-09-27 20:19:36 +02:00
|
|
|
ScreenInfo *si;
|
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-10-01 16:43:01 +02:00
|
|
|
si = get_display_info(c->display, c->phys_screen, NULL);
|
2007-09-27 20:19:36 +02:00
|
|
|
if(x > si->width)
|
|
|
|
x = si->width - w - 2 * c->border;
|
|
|
|
if(y > si->height)
|
|
|
|
y = si->height - h - 2 * c->border;
|
2007-10-11 23:44:35 +02:00
|
|
|
p_delete(&si);
|
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;
|
|
|
|
wc.border_width = c->border;
|
|
|
|
XConfigureWindow(c->display, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc);
|
|
|
|
configure(c);
|
|
|
|
XSync(c->display, False);
|
2007-09-27 20:19:36 +02:00
|
|
|
if(XineramaIsActive(c->display))
|
2007-09-28 11:30:51 +02:00
|
|
|
{
|
2007-09-28 16:40:20 +02:00
|
|
|
int new_screen = get_screen_bycoord(c->display, c->x, c->y);
|
|
|
|
if(c->screen != new_screen)
|
|
|
|
move_client_to_screen(c, &awesomeconf[new_screen - awesomeconf->screen], False);
|
2007-09-28 11:30:51 +02:00
|
|
|
}
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
saveprops(Client * c, int ntags)
|
|
|
|
{
|
|
|
|
int i;
|
2007-09-07 11:18:27 +02:00
|
|
|
char *prop;
|
|
|
|
|
|
|
|
prop = p_new(char, ntags + 2);
|
2007-09-06 22:02:50 +02:00
|
|
|
|
2007-09-07 11:18:27 +02:00
|
|
|
for(i = 0; i < ntags; i++)
|
2007-09-05 20:15:00 +02:00
|
|
|
prop[i] = c->tags[i] ? '1' : '0';
|
|
|
|
|
2007-09-07 11:18:27 +02:00
|
|
|
if(i <= ntags)
|
|
|
|
prop[i] = c->isfloating ? '1' : '0';
|
|
|
|
|
|
|
|
prop[++i] = '\0';
|
|
|
|
|
2007-09-10 16:11:57 +02:00
|
|
|
XChangeProperty(c->display, c->win, AWESOMEPROPS_ATOM(c->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
|
|
|
|
unban(Client * c)
|
|
|
|
{
|
|
|
|
XMapWindow(c->display, c->win);
|
|
|
|
setclientstate(c, NormalState);
|
|
|
|
c->isbanned = False;
|
2007-09-19 00:03:54 +02:00
|
|
|
c->unmapped = False;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-10-10 14:09:36 +02:00
|
|
|
unmanage(Client * c, long state, awesome_config *awesomeconf)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
XWindowChanges wc;
|
|
|
|
|
2007-10-15 20:23:54 +02:00
|
|
|
client_untab(c);
|
2007-09-19 00:03:54 +02:00
|
|
|
c->unmapped = True;
|
2007-09-05 20:15:00 +02:00
|
|
|
wc.border_width = c->oldborder;
|
|
|
|
/* The server grab construct avoids race conditions. */
|
|
|
|
XGrabServer(c->display);
|
|
|
|
XConfigureWindow(c->display, c->win, CWBorderWidth, &wc); /* restore border */
|
2007-10-11 21:50:32 +02:00
|
|
|
detach(awesomeconf->clients, c);
|
2007-10-11 23:12:05 +02:00
|
|
|
if(*awesomeconf->client_sel == c)
|
2007-10-15 18:25:29 +02:00
|
|
|
focus(NULL, True, awesomeconf);
|
2007-09-05 20:15:00 +02:00
|
|
|
XUngrabButton(c->display, AnyButton, AnyModifier, c->win);
|
|
|
|
setclientstate(c, state);
|
|
|
|
XSync(c->display, False);
|
|
|
|
XSetErrorHandler(xerror);
|
|
|
|
XUngrabServer(c->display);
|
|
|
|
if(state != NormalState)
|
2007-10-15 18:23:05 +02:00
|
|
|
arrange(awesomeconf);
|
2007-09-05 20:15:00 +02:00
|
|
|
p_delete(&c->tags);
|
|
|
|
p_delete(&c);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
updatesizehints(Client * c)
|
|
|
|
{
|
|
|
|
long msize;
|
|
|
|
XSizeHints size;
|
|
|
|
|
|
|
|
if(!XGetWMNormalHints(c->display, c->win, &size, &msize) || !size.flags)
|
|
|
|
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-09-13 15:57:35 +02:00
|
|
|
void
|
|
|
|
set_shape(Client *c)
|
|
|
|
{
|
|
|
|
int bounding_shaped;
|
|
|
|
int i, b; unsigned int u; /* dummies */
|
|
|
|
/* Logic to decide if we have a shaped window cribbed from fvwm-2.5.10. */
|
|
|
|
if (XShapeQueryExtents(c->display, c->win, &bounding_shaped, &i, &i,
|
|
|
|
&u, &u, &b, &i, &i, &u, &u) && bounding_shaped)
|
2007-10-03 20:46:03 +02:00
|
|
|
XShapeCombineShape(c->display, RootWindow(c->display, c->phys_screen), ShapeBounding, 0, 0, c->win, ShapeBounding, ShapeSet);
|
2007-09-13 15:57:35 +02:00
|
|
|
}
|
|
|
|
|
2007-09-20 21:27:43 +02:00
|
|
|
/** Set selected client transparency
|
|
|
|
* \param awesomeconf awesome config
|
|
|
|
* \param arg unused arg
|
|
|
|
* \ingroup ui_callback
|
|
|
|
*/
|
2007-09-05 20:15:00 +02:00
|
|
|
void
|
2007-10-11 23:32:29 +02:00
|
|
|
uicb_settrans(awesome_config *awesomeconf __attribute__ ((unused)),
|
2007-09-05 20:15:00 +02:00
|
|
|
const char *arg)
|
|
|
|
{
|
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-10-11 23:12:05 +02:00
|
|
|
if(!*awesomeconf->client_sel)
|
2007-09-05 20:15:00 +02:00
|
|
|
return;
|
|
|
|
|
2007-10-11 23:12:05 +02:00
|
|
|
XGetWindowProperty(awesomeconf->display, (*awesomeconf->client_sel)->win,
|
|
|
|
XInternAtom((*awesomeconf->client_sel)->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-10-11 23:12:05 +02:00
|
|
|
setclienttrans(*awesomeconf->client_sel, -1);
|
2007-09-05 20:15:00 +02:00
|
|
|
else
|
2007-10-11 23:12:05 +02:00
|
|
|
setclienttrans(*awesomeconf->client_sel, delta);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
2007-09-18 23:36:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
/** Set borrder size
|
|
|
|
* \param awesomeconf awesome config
|
|
|
|
* \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-10-11 23:32:29 +02:00
|
|
|
uicb_setborder(awesome_config *awesomeconf,
|
2007-09-18 23:36:52 +02:00
|
|
|
const char *arg)
|
|
|
|
{
|
|
|
|
if(!arg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if((awesomeconf->borderpx = (int) compute_new_value_from_arg(arg, (double) awesomeconf->borderpx)) < 0)
|
|
|
|
awesomeconf->borderpx = 0;
|
|
|
|
}
|
|
|
|
|
2007-09-25 12:41:36 +02:00
|
|
|
void
|
2007-10-11 23:32:29 +02:00
|
|
|
uicb_swapnext(awesome_config *awesomeconf,
|
2007-09-25 12:41:36 +02:00
|
|
|
const char *arg __attribute__ ((unused)))
|
|
|
|
{
|
2007-10-15 21:17:32 +02:00
|
|
|
Client *next, *sel = *awesomeconf->client_sel;
|
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-10-15 21:17:32 +02:00
|
|
|
for(next = sel->next; next && !isvisible(next, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags); next = next->next);
|
2007-09-25 12:41:36 +02:00
|
|
|
if(next)
|
|
|
|
{
|
2007-10-11 23:12:05 +02:00
|
|
|
client_swap(awesomeconf->clients, *awesomeconf->client_sel, next);
|
2007-10-15 18:23:05 +02:00
|
|
|
arrange(awesomeconf);
|
2007-10-15 21:17:32 +02:00
|
|
|
/* restore focus */
|
|
|
|
focus(sel, True, awesomeconf);
|
2007-09-25 12:41:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-10-11 23:32:29 +02:00
|
|
|
uicb_swapprev(awesome_config *awesomeconf,
|
2007-09-25 12:41:36 +02:00
|
|
|
const char *arg __attribute__ ((unused)))
|
|
|
|
{
|
2007-10-15 21:17:32 +02:00
|
|
|
Client *prev, *sel = *awesomeconf->client_sel;
|
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-10-15 21:17:32 +02:00
|
|
|
for(prev = sel->prev; prev && !isvisible(prev, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags); prev = prev->prev);
|
2007-09-25 12:41:36 +02:00
|
|
|
if(prev)
|
|
|
|
{
|
2007-10-11 23:12:05 +02:00
|
|
|
client_swap(awesomeconf->clients, prev, *awesomeconf->client_sel);
|
2007-10-15 18:23:05 +02:00
|
|
|
arrange(awesomeconf);
|
2007-10-15 21:17:32 +02:00
|
|
|
/* restore focus */
|
|
|
|
focus(sel, True, awesomeconf);
|
2007-09-25 12:41:36 +02:00
|
|
|
}
|
|
|
|
}
|
2007-10-01 20:42:59 +02:00
|
|
|
|
|
|
|
void
|
2007-10-11 23:32:29 +02:00
|
|
|
uicb_moveresize(awesome_config *awesomeconf,
|
2007-10-01 20:42:59 +02:00
|
|
|
const char *arg)
|
|
|
|
{
|
|
|
|
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-10-16 22:33:10 +02:00
|
|
|
if(get_current_layout(awesomeconf->tags, awesomeconf->ntags)->arrange == layout_floating)
|
2007-10-11 23:12:05 +02:00
|
|
|
if(!*awesomeconf->client_sel || !(*awesomeconf->client_sel)->isfloating || (*awesomeconf->client_sel)->isfixed || !arg)
|
2007-10-01 20:42:59 +02:00
|
|
|
return;
|
|
|
|
if(sscanf(arg, "%s %s %s %s", x, y, w, h) != 4)
|
|
|
|
return;
|
2007-10-11 23:12:05 +02:00
|
|
|
nx = (int) compute_new_value_from_arg(x, (*awesomeconf->client_sel)->x);
|
|
|
|
ny = (int) compute_new_value_from_arg(y, (*awesomeconf->client_sel)->y);
|
|
|
|
nw = (int) compute_new_value_from_arg(w, (*awesomeconf->client_sel)->w);
|
|
|
|
nh = (int) compute_new_value_from_arg(h, (*awesomeconf->client_sel)->h);
|
|
|
|
|
|
|
|
ox = (*awesomeconf->client_sel)->x;
|
|
|
|
oy = (*awesomeconf->client_sel)->y;
|
|
|
|
ow = (*awesomeconf->client_sel)->w;
|
|
|
|
oh = (*awesomeconf->client_sel)->h;
|
|
|
|
|
|
|
|
Bool xqp = XQueryPointer(awesomeconf->display, RootWindow(awesomeconf->display, awesomeconf->phys_screen), &dummy, &dummy, &mx, &my, &dx, &dy, &dui);
|
|
|
|
resize(*awesomeconf->client_sel, nx, ny, nw, nh, awesomeconf, True);
|
2007-10-01 20:42:59 +02:00
|
|
|
if (xqp && ox <= mx && (ox + ow) >= mx && oy <= my && (oy + oh) >= my)
|
|
|
|
{
|
2007-10-11 23:12:05 +02:00
|
|
|
nmx = mx - ox + (*awesomeconf->client_sel)->w - ow - 1 < 0 ? 0 : mx - ox + (*awesomeconf->client_sel)->w - ow - 1;
|
|
|
|
nmy = my - oy + (*awesomeconf->client_sel)->h - oh - 1 < 0 ? 0 : my - oy + (*awesomeconf->client_sel)->h - oh - 1;
|
|
|
|
XWarpPointer(awesomeconf->display, None, (*awesomeconf->client_sel)->win, 0, 0, 0, 0, nmx, nmy);
|
2007-10-01 20:42:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Kill selected client
|
|
|
|
* \param awesomeconf awesome config
|
|
|
|
* \param arg unused
|
|
|
|
* \ingroup ui_callback
|
|
|
|
*/
|
|
|
|
void
|
2007-10-11 23:32:29 +02:00
|
|
|
uicb_killclient(awesome_config *awesomeconf,
|
2007-10-01 20:42:59 +02:00
|
|
|
const char *arg __attribute__ ((unused)))
|
|
|
|
{
|
|
|
|
XEvent ev;
|
|
|
|
|
2007-10-11 23:12:05 +02:00
|
|
|
if(!*awesomeconf->client_sel)
|
2007-10-01 20:42:59 +02:00
|
|
|
return;
|
2007-10-11 23:12:05 +02:00
|
|
|
if(isprotodel(*awesomeconf->client_sel))
|
2007-10-01 20:42:59 +02:00
|
|
|
{
|
|
|
|
ev.type = ClientMessage;
|
2007-10-11 23:12:05 +02:00
|
|
|
ev.xclient.window = (*awesomeconf->client_sel)->win;
|
2007-10-11 23:32:29 +02:00
|
|
|
ev.xclient.message_type = XInternAtom(awesomeconf->display, "WM_PROTOCOLS", False);
|
2007-10-01 20:42:59 +02:00
|
|
|
ev.xclient.format = 32;
|
2007-10-11 23:32:29 +02:00
|
|
|
ev.xclient.data.l[0] = XInternAtom(awesomeconf->display, "WM_DELETE_WINDOW", False);
|
2007-10-01 20:42:59 +02:00
|
|
|
ev.xclient.data.l[1] = CurrentTime;
|
2007-10-11 23:12:05 +02:00
|
|
|
XSendEvent(awesomeconf->display, (*awesomeconf->client_sel)->win, False, NoEventMask, &ev);
|
2007-10-01 20:42:59 +02:00
|
|
|
}
|
|
|
|
else
|
2007-10-11 23:12:05 +02:00
|
|
|
XKillClient(awesomeconf->display, (*awesomeconf->client_sel)->win);
|
2007-10-01 20:42:59 +02:00
|
|
|
}
|
2007-10-15 13:56:24 +02:00
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99
|