2007-04-27 11:58:48 -06:00
|
|
|
/*
|
|
|
|
* calmwm - the calm window manager
|
|
|
|
*
|
|
|
|
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
|
|
|
*
|
2008-01-11 09:06:44 -07:00
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
2019-02-22 07:39:18 -07:00
|
|
|
* $OpenBSD: client.c,v 1.248 2019/02/22 14:39:18 okan Exp $
|
2007-04-27 11:58:48 -06:00
|
|
|
*/
|
|
|
|
|
2015-01-19 07:54:16 -07:00
|
|
|
#include <sys/types.h>
|
2009-12-14 21:10:42 -07:00
|
|
|
#include <sys/queue.h>
|
|
|
|
|
|
|
|
#include <err.h>
|
|
|
|
#include <errno.h>
|
2015-01-19 07:54:16 -07:00
|
|
|
#include <limits.h>
|
2012-11-08 20:52:02 -07:00
|
|
|
#include <stdio.h>
|
2009-12-14 21:10:42 -07:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
2009-12-14 20:34:34 -07:00
|
|
|
|
2007-04-27 11:58:48 -06:00
|
|
|
#include "calmwm.h"
|
|
|
|
|
2014-09-08 14:32:40 -06:00
|
|
|
static struct client_ctx *client_next(struct client_ctx *);
|
|
|
|
static struct client_ctx *client_prev(struct client_ctx *);
|
2009-06-26 06:21:58 -06:00
|
|
|
static void client_placecalc(struct client_ctx *);
|
2013-05-19 11:02:04 -06:00
|
|
|
static void client_wm_protocols(struct client_ctx *);
|
2013-12-11 08:46:47 -07:00
|
|
|
static void client_mwm_hints(struct client_ctx *);
|
2007-04-27 11:58:48 -06:00
|
|
|
|
|
|
|
struct client_ctx *
|
2016-09-16 08:32:02 -06:00
|
|
|
client_init(Window win, struct screen_ctx *sc, int active)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2008-07-11 08:21:28 -06:00
|
|
|
struct client_ctx *cc;
|
|
|
|
XWindowAttributes wattr;
|
2014-02-03 13:20:39 -07:00
|
|
|
int mapped;
|
2015-09-23 08:09:40 -06:00
|
|
|
Window rwin, cwin;
|
2016-09-16 08:32:02 -06:00
|
|
|
int x, y, wx, wy;
|
2015-09-23 08:09:40 -06:00
|
|
|
unsigned int mask;
|
2007-04-27 11:58:48 -06:00
|
|
|
|
|
|
|
if (win == None)
|
2014-09-07 13:27:30 -06:00
|
|
|
return(NULL);
|
2014-02-02 14:34:05 -07:00
|
|
|
if (!XGetWindowAttributes(X_Dpy, win, &wattr))
|
2014-09-07 13:27:30 -06:00
|
|
|
return(NULL);
|
2014-02-03 13:20:39 -07:00
|
|
|
|
|
|
|
if (sc == NULL) {
|
2015-06-30 08:01:43 -06:00
|
|
|
if ((sc = screen_find(wattr.root)) == NULL)
|
|
|
|
return(NULL);
|
2014-02-03 13:20:39 -07:00
|
|
|
mapped = 1;
|
|
|
|
} else {
|
|
|
|
if (wattr.override_redirect || wattr.map_state != IsViewable)
|
2014-09-07 13:27:30 -06:00
|
|
|
return(NULL);
|
2014-02-03 13:20:39 -07:00
|
|
|
mapped = wattr.map_state != IsUnmapped;
|
|
|
|
}
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2007-05-28 12:34:27 -06:00
|
|
|
XGrabServer(X_Dpy);
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2018-11-13 10:37:13 -07:00
|
|
|
cc = xmalloc(sizeof(*cc));
|
2007-04-27 11:58:48 -06:00
|
|
|
cc->sc = sc;
|
|
|
|
cc->win = win;
|
2016-09-13 11:42:58 -06:00
|
|
|
cc->label = NULL;
|
2016-09-12 07:48:41 -06:00
|
|
|
cc->gc = NULL;
|
|
|
|
cc->flags = 0;
|
|
|
|
cc->stackingorder = 0;
|
|
|
|
memset(&cc->hint, 0, sizeof(cc->hint));
|
2016-09-14 15:00:24 -06:00
|
|
|
memset(&cc->ch, 0, sizeof(cc->ch));
|
2009-05-29 18:30:17 -06:00
|
|
|
TAILQ_INIT(&cc->nameq);
|
|
|
|
|
2018-11-13 10:37:13 -07:00
|
|
|
cc->geom.x = wattr.x;
|
|
|
|
cc->geom.y = wattr.y;
|
|
|
|
cc->geom.w = wattr.width;
|
|
|
|
cc->geom.h = wattr.height;
|
|
|
|
cc->colormap = wattr.colormap;
|
|
|
|
cc->obwidth = wattr.border_width;
|
|
|
|
cc->bwidth = Conf.bwidth;
|
|
|
|
|
|
|
|
client_setname(cc);
|
2009-05-29 18:30:17 -06:00
|
|
|
conf_client(cc);
|
|
|
|
|
2013-12-11 07:09:21 -07:00
|
|
|
XGetClassHint(X_Dpy, cc->win, &cc->ch);
|
2013-12-11 08:41:11 -07:00
|
|
|
client_wm_hints(cc);
|
2013-12-11 07:09:21 -07:00
|
|
|
client_wm_protocols(cc);
|
|
|
|
client_getsizehints(cc);
|
2018-11-13 10:37:13 -07:00
|
|
|
client_transient(cc);
|
2013-12-11 08:46:47 -07:00
|
|
|
client_mwm_hints(cc);
|
2013-04-03 14:22:55 -06:00
|
|
|
|
2018-11-13 10:37:13 -07:00
|
|
|
if ((cc->flags & CLIENT_IGNORE))
|
|
|
|
cc->bwidth = 0;
|
2016-12-06 14:00:13 -07:00
|
|
|
cc->dim.w = (cc->geom.w - cc->hint.basew) / cc->hint.incw;
|
|
|
|
cc->dim.h = (cc->geom.h - cc->hint.baseh) / cc->hint.inch;
|
2016-09-30 14:55:54 -06:00
|
|
|
cc->ptr.x = cc->geom.w / 2;
|
|
|
|
cc->ptr.y = cc->geom.h / 2;
|
|
|
|
|
2007-04-27 11:58:48 -06:00
|
|
|
if (wattr.map_state != IsViewable) {
|
|
|
|
client_placecalc(cc);
|
2017-02-06 11:10:28 -07:00
|
|
|
client_resize(cc, 0);
|
2013-12-11 07:16:09 -07:00
|
|
|
if ((cc->wmh) && (cc->wmh->flags & StateHint))
|
|
|
|
client_set_wm_state(cc, cc->wmh->initial_state);
|
2015-09-23 08:09:40 -06:00
|
|
|
} else {
|
2017-12-22 14:21:44 -07:00
|
|
|
if ((active == 0) && (XQueryPointer(X_Dpy, cc->win, &rwin,
|
|
|
|
&cwin, &x, &y, &wx, &wy, &mask)) && (cwin != None))
|
2016-09-16 08:32:02 -06:00
|
|
|
active = 1;
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2008-05-15 15:56:21 -06:00
|
|
|
XSelectInput(X_Dpy, cc->win, ColormapChangeMask | EnterWindowMask |
|
|
|
|
PropertyChangeMask | KeyReleaseMask);
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2013-12-13 08:56:44 -07:00
|
|
|
XAddToSaveSet(X_Dpy, cc->win);
|
|
|
|
|
2007-04-27 11:58:48 -06:00
|
|
|
/* Notify client of its configuration. */
|
2013-06-10 15:37:30 -06:00
|
|
|
client_config(cc);
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2014-09-08 14:11:22 -06:00
|
|
|
TAILQ_INSERT_TAIL(&sc->clientq, cc, entry);
|
2012-07-03 07:49:03 -06:00
|
|
|
|
|
|
|
xu_ewmh_net_client_list(sc);
|
2015-08-24 09:42:57 -06:00
|
|
|
xu_ewmh_net_client_list_stacking(sc);
|
2013-05-20 15:13:58 -06:00
|
|
|
xu_ewmh_restore_net_wm_state(cc);
|
2008-04-15 14:24:41 -06:00
|
|
|
|
2015-01-23 12:35:11 -07:00
|
|
|
if (client_get_wm_state(cc) == IconicState)
|
|
|
|
client_hide(cc);
|
|
|
|
else
|
|
|
|
client_unhide(cc);
|
|
|
|
|
2015-08-25 12:29:10 -06:00
|
|
|
if (mapped) {
|
2018-11-13 10:37:13 -07:00
|
|
|
if (cc->gc) {
|
|
|
|
group_movetogroup(cc, cc->gc->num);
|
|
|
|
goto out;
|
|
|
|
}
|
2015-08-25 12:29:10 -06:00
|
|
|
if (group_restore(cc))
|
|
|
|
goto out;
|
|
|
|
if (group_autogroup(cc))
|
|
|
|
goto out;
|
2016-10-03 08:42:34 -06:00
|
|
|
if (Conf.stickygroups)
|
2015-08-25 12:29:10 -06:00
|
|
|
group_assign(sc->group_active, cc);
|
|
|
|
else
|
|
|
|
group_assign(NULL, cc);
|
|
|
|
}
|
|
|
|
out:
|
2013-04-03 13:20:50 -06:00
|
|
|
XSync(X_Dpy, False);
|
|
|
|
XUngrabServer(X_Dpy);
|
|
|
|
|
2016-09-16 08:32:02 -06:00
|
|
|
if (active)
|
2015-09-23 08:09:40 -06:00
|
|
|
client_setactive(cc);
|
|
|
|
|
2014-09-07 13:27:30 -06:00
|
|
|
return(cc);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2015-06-28 13:54:37 -06:00
|
|
|
struct client_ctx *
|
|
|
|
client_find(Window win)
|
|
|
|
{
|
|
|
|
struct screen_ctx *sc;
|
|
|
|
struct client_ctx *cc;
|
|
|
|
|
|
|
|
TAILQ_FOREACH(sc, &Screenq, entry) {
|
|
|
|
TAILQ_FOREACH(cc, &sc->clientq, entry) {
|
|
|
|
if (cc->win == win)
|
|
|
|
return(cc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
|
2011-06-23 23:40:09 -06:00
|
|
|
void
|
2013-11-12 14:25:00 -07:00
|
|
|
client_delete(struct client_ctx *cc)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2009-08-26 19:38:08 -06:00
|
|
|
struct screen_ctx *sc = cc->sc;
|
2008-07-11 08:21:28 -06:00
|
|
|
struct winname *wn;
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2014-09-08 14:11:22 -06:00
|
|
|
TAILQ_REMOVE(&sc->clientq, cc, entry);
|
2012-07-03 07:49:03 -06:00
|
|
|
|
|
|
|
xu_ewmh_net_client_list(sc);
|
2015-08-24 09:42:57 -06:00
|
|
|
xu_ewmh_net_client_list_stacking(sc);
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2016-09-14 13:45:33 -06:00
|
|
|
if (cc->flags & CLIENT_ACTIVE)
|
2016-09-20 12:21:32 -06:00
|
|
|
xu_ewmh_net_active_window(sc, None);
|
2016-09-14 13:45:33 -06:00
|
|
|
|
2015-08-27 12:53:14 -06:00
|
|
|
if (cc->gc != NULL)
|
|
|
|
TAILQ_REMOVE(&cc->gc->clientq, cc, group_entry);
|
2013-05-06 10:03:11 -06:00
|
|
|
|
2007-04-27 11:58:48 -06:00
|
|
|
while ((wn = TAILQ_FIRST(&cc->nameq)) != NULL) {
|
|
|
|
TAILQ_REMOVE(&cc->nameq, wn, entry);
|
2013-01-01 07:26:29 -07:00
|
|
|
free(wn->name);
|
2012-11-07 13:34:39 -07:00
|
|
|
free(wn);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2013-12-11 07:09:21 -07:00
|
|
|
if (cc->ch.res_class)
|
|
|
|
XFree(cc->ch.res_class);
|
|
|
|
if (cc->ch.res_name)
|
|
|
|
XFree(cc->ch.res_name);
|
|
|
|
if (cc->wmh)
|
|
|
|
XFree(cc->wmh);
|
|
|
|
|
2012-11-07 13:34:39 -07:00
|
|
|
free(cc);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-11-26 17:01:23 -07:00
|
|
|
client_setactive(struct client_ctx *cc)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2013-11-26 17:01:23 -07:00
|
|
|
struct screen_ctx *sc = cc->sc;
|
|
|
|
struct client_ctx *oldcc;
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2013-12-12 13:15:07 -07:00
|
|
|
if (cc->flags & CLIENT_HIDDEN)
|
|
|
|
return;
|
|
|
|
|
2013-11-26 17:01:23 -07:00
|
|
|
XInstallColormap(X_Dpy, cc->colormap);
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2013-11-26 17:01:23 -07:00
|
|
|
if ((cc->flags & CLIENT_INPUT) ||
|
2014-09-15 07:00:49 -06:00
|
|
|
(!(cc->flags & CLIENT_WM_TAKE_FOCUS))) {
|
2013-11-26 17:01:23 -07:00
|
|
|
XSetInputFocus(X_Dpy, cc->win,
|
|
|
|
RevertToPointerRoot, CurrentTime);
|
|
|
|
}
|
|
|
|
if (cc->flags & CLIENT_WM_TAKE_FOCUS)
|
2013-12-12 13:15:07 -07:00
|
|
|
client_msg(cc, cwmh[WM_TAKE_FOCUS], Last_Event_Time);
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2015-08-27 12:42:56 -06:00
|
|
|
if ((oldcc = client_current()) != NULL) {
|
2014-09-10 14:30:38 -06:00
|
|
|
oldcc->flags &= ~CLIENT_ACTIVE;
|
2013-11-26 17:01:23 -07:00
|
|
|
client_draw_border(oldcc);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2017-12-22 14:21:44 -07:00
|
|
|
/* If we're in the middle of cycling, don't change the order. */
|
2013-11-26 17:01:23 -07:00
|
|
|
if (!sc->cycling)
|
|
|
|
client_mtf(cc);
|
|
|
|
|
2014-09-10 14:30:38 -06:00
|
|
|
cc->flags |= CLIENT_ACTIVE;
|
2013-12-13 07:40:52 -07:00
|
|
|
cc->flags &= ~CLIENT_URGENCY;
|
2007-04-27 11:58:48 -06:00
|
|
|
client_draw_border(cc);
|
2013-11-26 17:01:23 -07:00
|
|
|
conf_grab_mouse(cc->win);
|
|
|
|
xu_ewmh_net_active_window(sc, cc->win);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
struct client_ctx *
|
|
|
|
client_current(void)
|
|
|
|
{
|
2016-09-20 12:21:32 -06:00
|
|
|
struct screen_ctx *sc;
|
|
|
|
struct client_ctx *cc;
|
|
|
|
|
|
|
|
TAILQ_FOREACH(sc, &Screenq, entry) {
|
|
|
|
TAILQ_FOREACH(cc, &sc->clientq, entry) {
|
|
|
|
if (cc->flags & CLIENT_ACTIVE)
|
|
|
|
return(cc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(NULL);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2011-05-07 11:15:37 -06:00
|
|
|
void
|
2014-09-17 12:41:44 -06:00
|
|
|
client_toggle_freeze(struct client_ctx *cc)
|
2011-05-07 11:15:37 -06:00
|
|
|
{
|
2015-08-24 08:57:19 -06:00
|
|
|
if (cc->flags & CLIENT_FULLSCREEN)
|
|
|
|
return;
|
|
|
|
|
2016-09-02 09:08:44 -06:00
|
|
|
cc->flags ^= CLIENT_FREEZE;
|
2015-08-21 10:30:02 -06:00
|
|
|
xu_ewmh_set_net_wm_state(cc);
|
2011-05-07 11:15:37 -06:00
|
|
|
}
|
|
|
|
|
2014-09-17 10:00:44 -06:00
|
|
|
void
|
2014-09-17 12:41:44 -06:00
|
|
|
client_toggle_hidden(struct client_ctx *cc)
|
2014-09-17 10:00:44 -06:00
|
|
|
{
|
2016-09-02 09:08:44 -06:00
|
|
|
cc->flags ^= CLIENT_HIDDEN;
|
2014-09-17 10:00:44 -06:00
|
|
|
xu_ewmh_set_net_wm_state(cc);
|
|
|
|
}
|
|
|
|
|
2017-12-19 07:30:53 -07:00
|
|
|
void
|
|
|
|
client_toggle_skip_pager(struct client_ctx *cc)
|
|
|
|
{
|
|
|
|
cc->flags ^= CLIENT_SKIP_PAGER;
|
|
|
|
xu_ewmh_set_net_wm_state(cc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
client_toggle_skip_taskbar(struct client_ctx *cc)
|
|
|
|
{
|
|
|
|
cc->flags ^= CLIENT_SKIP_TASKBAR;
|
|
|
|
xu_ewmh_set_net_wm_state(cc);
|
|
|
|
}
|
|
|
|
|
2014-08-25 06:49:19 -06:00
|
|
|
void
|
2014-09-17 12:41:44 -06:00
|
|
|
client_toggle_sticky(struct client_ctx *cc)
|
2014-08-25 06:49:19 -06:00
|
|
|
{
|
2016-09-02 09:08:44 -06:00
|
|
|
cc->flags ^= CLIENT_STICKY;
|
2014-08-25 06:49:19 -06:00
|
|
|
xu_ewmh_set_net_wm_state(cc);
|
|
|
|
}
|
|
|
|
|
2013-12-16 12:02:17 -07:00
|
|
|
void
|
2014-09-17 12:41:44 -06:00
|
|
|
client_toggle_fullscreen(struct client_ctx *cc)
|
2013-12-16 12:02:17 -07:00
|
|
|
{
|
|
|
|
struct screen_ctx *sc = cc->sc;
|
2015-11-11 07:22:01 -07:00
|
|
|
struct geom area;
|
2013-12-16 12:02:17 -07:00
|
|
|
|
|
|
|
if ((cc->flags & CLIENT_FREEZE) &&
|
|
|
|
!(cc->flags & CLIENT_FULLSCREEN))
|
|
|
|
return;
|
|
|
|
|
2014-09-15 07:00:49 -06:00
|
|
|
if (cc->flags & CLIENT_FULLSCREEN) {
|
2016-09-01 12:38:52 -06:00
|
|
|
if (!(cc->flags & CLIENT_IGNORE))
|
|
|
|
cc->bwidth = Conf.bwidth;
|
2013-12-16 12:02:17 -07:00
|
|
|
cc->geom = cc->fullgeom;
|
|
|
|
cc->flags &= ~(CLIENT_FULLSCREEN | CLIENT_FREEZE);
|
|
|
|
goto resize;
|
|
|
|
}
|
|
|
|
|
|
|
|
cc->fullgeom = cc->geom;
|
|
|
|
|
2015-11-11 07:22:01 -07:00
|
|
|
area = screen_area(sc,
|
2013-12-16 12:02:17 -07:00
|
|
|
cc->geom.x + cc->geom.w / 2,
|
2015-11-11 07:22:01 -07:00
|
|
|
cc->geom.y + cc->geom.h / 2, CWM_NOGAP);
|
2013-12-16 12:02:17 -07:00
|
|
|
|
|
|
|
cc->bwidth = 0;
|
2015-11-11 07:22:01 -07:00
|
|
|
cc->geom = area;
|
2013-12-16 12:02:17 -07:00
|
|
|
cc->flags |= (CLIENT_FULLSCREEN | CLIENT_FREEZE);
|
|
|
|
|
|
|
|
resize:
|
|
|
|
client_resize(cc, 0);
|
|
|
|
xu_ewmh_set_net_wm_state(cc);
|
|
|
|
}
|
|
|
|
|
2007-04-27 11:58:48 -06:00
|
|
|
void
|
2014-09-17 12:41:44 -06:00
|
|
|
client_toggle_maximize(struct client_ctx *cc)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2009-08-26 19:38:08 -06:00
|
|
|
struct screen_ctx *sc = cc->sc;
|
2015-11-11 07:22:01 -07:00
|
|
|
struct geom area;
|
2008-07-15 16:06:48 -06:00
|
|
|
|
2015-08-21 10:14:39 -06:00
|
|
|
if (cc->flags & CLIENT_FREEZE)
|
2011-05-07 11:15:37 -06:00
|
|
|
return;
|
|
|
|
|
2011-09-04 10:59:31 -06:00
|
|
|
if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_MAXIMIZED) {
|
2007-04-27 11:58:48 -06:00
|
|
|
cc->geom = cc->savegeom;
|
2013-12-16 12:02:17 -07:00
|
|
|
cc->flags &= ~CLIENT_MAXIMIZED;
|
2011-09-04 10:59:31 -06:00
|
|
|
goto resize;
|
|
|
|
}
|
|
|
|
|
2014-09-15 07:00:49 -06:00
|
|
|
if (!(cc->flags & CLIENT_VMAXIMIZED)) {
|
2012-07-13 11:01:04 -06:00
|
|
|
cc->savegeom.h = cc->geom.h;
|
2011-09-04 10:59:31 -06:00
|
|
|
cc->savegeom.y = cc->geom.y;
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2014-09-15 07:00:49 -06:00
|
|
|
if (!(cc->flags & CLIENT_HMAXIMIZED)) {
|
2012-07-13 11:01:04 -06:00
|
|
|
cc->savegeom.w = cc->geom.w;
|
2011-09-04 10:59:31 -06:00
|
|
|
cc->savegeom.x = cc->geom.x;
|
|
|
|
}
|
|
|
|
|
2015-11-11 07:22:01 -07:00
|
|
|
area = screen_area(sc,
|
2012-07-15 19:36:30 -06:00
|
|
|
cc->geom.x + cc->geom.w / 2,
|
2015-11-11 07:22:01 -07:00
|
|
|
cc->geom.y + cc->geom.h / 2, CWM_GAP);
|
2012-07-15 19:36:30 -06:00
|
|
|
|
2015-11-11 07:22:01 -07:00
|
|
|
cc->geom.x = area.x;
|
|
|
|
cc->geom.y = area.y;
|
|
|
|
cc->geom.w = area.w - (cc->bwidth * 2);
|
|
|
|
cc->geom.h = area.h - (cc->bwidth * 2);
|
2011-09-04 10:59:31 -06:00
|
|
|
cc->flags |= CLIENT_MAXIMIZED;
|
|
|
|
|
|
|
|
resize:
|
2012-09-09 13:47:47 -06:00
|
|
|
client_resize(cc, 0);
|
2013-05-20 15:13:58 -06:00
|
|
|
xu_ewmh_set_net_wm_state(cc);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2008-07-15 16:12:09 -06:00
|
|
|
void
|
2014-09-17 12:41:44 -06:00
|
|
|
client_toggle_vmaximize(struct client_ctx *cc)
|
2008-07-15 16:12:09 -06:00
|
|
|
{
|
2009-08-26 19:38:08 -06:00
|
|
|
struct screen_ctx *sc = cc->sc;
|
2015-11-11 07:22:01 -07:00
|
|
|
struct geom area;
|
2008-07-15 16:12:09 -06:00
|
|
|
|
2015-08-21 10:14:39 -06:00
|
|
|
if (cc->flags & CLIENT_FREEZE)
|
2011-05-07 11:15:37 -06:00
|
|
|
return;
|
|
|
|
|
2008-07-15 16:12:09 -06:00
|
|
|
if (cc->flags & CLIENT_VMAXIMIZED) {
|
2011-06-24 00:01:47 -06:00
|
|
|
cc->geom.y = cc->savegeom.y;
|
2012-07-13 11:01:04 -06:00
|
|
|
cc->geom.h = cc->savegeom.h;
|
2011-06-24 00:01:47 -06:00
|
|
|
cc->flags &= ~CLIENT_VMAXIMIZED;
|
2011-09-04 10:59:31 -06:00
|
|
|
goto resize;
|
2008-07-15 16:12:09 -06:00
|
|
|
}
|
|
|
|
|
2011-09-04 10:59:31 -06:00
|
|
|
cc->savegeom.y = cc->geom.y;
|
2012-07-13 11:01:04 -06:00
|
|
|
cc->savegeom.h = cc->geom.h;
|
2011-09-04 10:59:31 -06:00
|
|
|
|
2015-11-11 07:22:01 -07:00
|
|
|
area = screen_area(sc,
|
2012-07-15 19:36:30 -06:00
|
|
|
cc->geom.x + cc->geom.w / 2,
|
2015-11-11 07:22:01 -07:00
|
|
|
cc->geom.y + cc->geom.h / 2, CWM_GAP);
|
2012-07-15 19:36:30 -06:00
|
|
|
|
2015-11-11 07:22:01 -07:00
|
|
|
cc->geom.y = area.y;
|
|
|
|
cc->geom.h = area.h - (cc->bwidth * 2);
|
2011-09-04 10:59:31 -06:00
|
|
|
cc->flags |= CLIENT_VMAXIMIZED;
|
|
|
|
|
|
|
|
resize:
|
2012-09-09 13:47:47 -06:00
|
|
|
client_resize(cc, 0);
|
2013-05-20 15:13:58 -06:00
|
|
|
xu_ewmh_set_net_wm_state(cc);
|
2008-07-15 16:12:09 -06:00
|
|
|
}
|
|
|
|
|
2009-08-24 17:54:41 -06:00
|
|
|
void
|
2014-09-17 12:41:44 -06:00
|
|
|
client_toggle_hmaximize(struct client_ctx *cc)
|
2009-08-24 17:54:41 -06:00
|
|
|
{
|
2009-08-26 19:38:08 -06:00
|
|
|
struct screen_ctx *sc = cc->sc;
|
2015-11-11 07:22:01 -07:00
|
|
|
struct geom area;
|
2009-08-24 17:54:41 -06:00
|
|
|
|
2015-08-21 10:14:39 -06:00
|
|
|
if (cc->flags & CLIENT_FREEZE)
|
2011-05-07 11:15:37 -06:00
|
|
|
return;
|
|
|
|
|
2009-08-24 17:54:41 -06:00
|
|
|
if (cc->flags & CLIENT_HMAXIMIZED) {
|
2011-06-24 00:01:47 -06:00
|
|
|
cc->geom.x = cc->savegeom.x;
|
2012-07-13 11:01:04 -06:00
|
|
|
cc->geom.w = cc->savegeom.w;
|
2011-06-24 00:01:47 -06:00
|
|
|
cc->flags &= ~CLIENT_HMAXIMIZED;
|
2011-09-04 10:59:31 -06:00
|
|
|
goto resize;
|
2012-05-13 09:15:54 -06:00
|
|
|
}
|
2011-09-04 10:59:31 -06:00
|
|
|
|
|
|
|
cc->savegeom.x = cc->geom.x;
|
2012-07-13 11:01:04 -06:00
|
|
|
cc->savegeom.w = cc->geom.w;
|
2011-09-04 10:59:31 -06:00
|
|
|
|
2015-11-11 07:22:01 -07:00
|
|
|
area = screen_area(sc,
|
2012-07-15 19:36:30 -06:00
|
|
|
cc->geom.x + cc->geom.w / 2,
|
2015-11-11 07:22:01 -07:00
|
|
|
cc->geom.y + cc->geom.h / 2, CWM_GAP);
|
2012-07-15 19:36:30 -06:00
|
|
|
|
2015-11-11 07:22:01 -07:00
|
|
|
cc->geom.x = area.x;
|
|
|
|
cc->geom.w = area.w - (cc->bwidth * 2);
|
2011-09-04 10:59:31 -06:00
|
|
|
cc->flags |= CLIENT_HMAXIMIZED;
|
|
|
|
|
|
|
|
resize:
|
2012-09-09 13:47:47 -06:00
|
|
|
client_resize(cc, 0);
|
2013-05-20 15:13:58 -06:00
|
|
|
xu_ewmh_set_net_wm_state(cc);
|
2009-08-24 17:54:41 -06:00
|
|
|
}
|
|
|
|
|
2007-04-27 11:58:48 -06:00
|
|
|
void
|
2012-09-09 13:47:47 -06:00
|
|
|
client_resize(struct client_ctx *cc, int reset)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2012-09-09 13:47:47 -06:00
|
|
|
if (reset) {
|
|
|
|
cc->flags &= ~CLIENT_MAXIMIZED;
|
2013-05-20 15:13:58 -06:00
|
|
|
xu_ewmh_set_net_wm_state(cc);
|
2012-09-09 13:47:47 -06:00
|
|
|
}
|
|
|
|
|
2013-11-11 05:51:15 -07:00
|
|
|
client_draw_border(cc);
|
|
|
|
|
2009-01-22 12:01:56 -07:00
|
|
|
XMoveResizeWindow(X_Dpy, cc->win, cc->geom.x,
|
2012-07-13 11:01:04 -06:00
|
|
|
cc->geom.y, cc->geom.w, cc->geom.h);
|
2016-12-06 14:00:13 -07:00
|
|
|
cc->dim.w = (cc->geom.w - cc->hint.basew) / cc->hint.incw;
|
|
|
|
cc->dim.h = (cc->geom.h - cc->hint.baseh) / cc->hint.inch;
|
2013-06-10 15:37:30 -06:00
|
|
|
client_config(cc);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
client_move(struct client_ctx *cc)
|
|
|
|
{
|
2009-01-22 12:01:56 -07:00
|
|
|
XMoveWindow(X_Dpy, cc->win, cc->geom.x, cc->geom.y);
|
2013-06-10 15:37:30 -06:00
|
|
|
client_config(cc);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
client_lower(struct client_ctx *cc)
|
|
|
|
{
|
2009-01-16 08:24:14 -07:00
|
|
|
XLowerWindow(X_Dpy, cc->win);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
client_raise(struct client_ctx *cc)
|
|
|
|
{
|
2009-01-16 08:24:14 -07:00
|
|
|
XRaiseWindow(X_Dpy, cc->win);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2013-06-10 15:37:30 -06:00
|
|
|
void
|
|
|
|
client_config(struct client_ctx *cc)
|
|
|
|
{
|
|
|
|
XConfigureEvent cn;
|
|
|
|
|
2013-12-17 09:10:43 -07:00
|
|
|
(void)memset(&cn, 0, sizeof(cn));
|
2013-06-10 15:37:30 -06:00
|
|
|
cn.type = ConfigureNotify;
|
|
|
|
cn.event = cc->win;
|
|
|
|
cn.window = cc->win;
|
|
|
|
cn.x = cc->geom.x;
|
|
|
|
cn.y = cc->geom.y;
|
|
|
|
cn.width = cc->geom.w;
|
|
|
|
cn.height = cc->geom.h;
|
|
|
|
cn.border_width = cc->bwidth;
|
|
|
|
cn.above = None;
|
|
|
|
cn.override_redirect = 0;
|
|
|
|
|
|
|
|
XSendEvent(X_Dpy, cc->win, False, StructureNotifyMask, (XEvent *)&cn);
|
|
|
|
}
|
|
|
|
|
2017-05-01 06:54:55 -06:00
|
|
|
void
|
|
|
|
client_ptr_inbound(struct client_ctx *cc, int getpos)
|
|
|
|
{
|
|
|
|
if (getpos)
|
|
|
|
xu_ptr_getpos(cc->win, &cc->ptr.x, &cc->ptr.y);
|
|
|
|
|
|
|
|
if (cc->ptr.x < 0)
|
|
|
|
cc->ptr.x = 0;
|
|
|
|
else if (cc->ptr.x > cc->geom.w - 1)
|
|
|
|
cc->ptr.x = cc->geom.w - 1;
|
|
|
|
if (cc->ptr.y < 0)
|
|
|
|
cc->ptr.y = 0;
|
|
|
|
else if (cc->ptr.y > cc->geom.h - 1)
|
|
|
|
cc->ptr.y = cc->geom.h - 1;
|
|
|
|
|
|
|
|
client_ptrwarp(cc);
|
|
|
|
}
|
|
|
|
|
2007-04-27 11:58:48 -06:00
|
|
|
void
|
|
|
|
client_ptrwarp(struct client_ctx *cc)
|
|
|
|
{
|
2016-09-30 14:55:54 -06:00
|
|
|
xu_ptr_setpos(cc->win, cc->ptr.x, cc->ptr.y);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
client_ptrsave(struct client_ctx *cc)
|
|
|
|
{
|
2008-07-11 08:21:28 -06:00
|
|
|
int x, y;
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2009-01-16 08:24:14 -07:00
|
|
|
xu_ptr_getpos(cc->win, &x, &y);
|
2009-05-17 18:23:35 -06:00
|
|
|
if (client_inbound(cc, x, y)) {
|
2007-04-27 11:58:48 -06:00
|
|
|
cc->ptr.x = x;
|
|
|
|
cc->ptr.y = y;
|
2011-02-13 13:09:57 -07:00
|
|
|
} else {
|
2016-09-30 14:55:54 -06:00
|
|
|
cc->ptr.x = cc->geom.w / 2;
|
|
|
|
cc->ptr.y = cc->geom.h / 2;
|
2008-04-15 14:24:41 -06:00
|
|
|
}
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
client_hide(struct client_ctx *cc)
|
|
|
|
{
|
2009-01-16 08:24:14 -07:00
|
|
|
XUnmapWindow(X_Dpy, cc->win);
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2016-09-14 13:45:33 -06:00
|
|
|
if (cc->flags & CLIENT_ACTIVE)
|
2016-09-20 12:21:32 -06:00
|
|
|
xu_ewmh_net_active_window(cc->sc, None);
|
2016-09-14 13:45:33 -06:00
|
|
|
|
2014-09-10 14:30:38 -06:00
|
|
|
cc->flags &= ~CLIENT_ACTIVE;
|
2014-09-17 10:30:21 -06:00
|
|
|
cc->flags |= CLIENT_HIDDEN;
|
2013-12-11 07:16:09 -07:00
|
|
|
client_set_wm_state(cc, IconicState);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2017-12-29 05:54:54 -07:00
|
|
|
void
|
|
|
|
client_show(struct client_ctx *cc)
|
|
|
|
{
|
|
|
|
if (cc->flags & CLIENT_HIDDEN)
|
|
|
|
client_unhide(cc);
|
|
|
|
else
|
|
|
|
client_raise(cc);
|
|
|
|
}
|
|
|
|
|
2007-04-27 11:58:48 -06:00
|
|
|
void
|
|
|
|
client_unhide(struct client_ctx *cc)
|
|
|
|
{
|
2009-01-16 08:24:14 -07:00
|
|
|
XMapRaised(X_Dpy, cc->win);
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2014-09-17 10:30:21 -06:00
|
|
|
cc->flags &= ~CLIENT_HIDDEN;
|
2013-12-11 07:16:09 -07:00
|
|
|
client_set_wm_state(cc, NormalState);
|
2013-12-10 14:27:37 -07:00
|
|
|
client_draw_border(cc);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2013-12-13 07:40:52 -07:00
|
|
|
void
|
|
|
|
client_urgency(struct client_ctx *cc)
|
|
|
|
{
|
2014-09-10 14:30:38 -06:00
|
|
|
if (!(cc->flags & CLIENT_ACTIVE))
|
2014-02-06 13:58:46 -07:00
|
|
|
cc->flags |= CLIENT_URGENCY;
|
2013-12-13 07:40:52 -07:00
|
|
|
}
|
|
|
|
|
2007-04-27 11:58:48 -06:00
|
|
|
void
|
|
|
|
client_draw_border(struct client_ctx *cc)
|
|
|
|
{
|
2009-08-26 19:38:08 -06:00
|
|
|
struct screen_ctx *sc = cc->sc;
|
2009-05-17 17:40:57 -06:00
|
|
|
unsigned long pixel;
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2014-09-10 14:30:38 -06:00
|
|
|
if (cc->flags & CLIENT_ACTIVE)
|
2012-12-17 10:48:57 -07:00
|
|
|
switch (cc->flags & CLIENT_HIGHLIGHT) {
|
|
|
|
case CLIENT_GROUP:
|
2013-05-19 17:09:59 -06:00
|
|
|
pixel = sc->xftcolor[CWM_COLOR_BORDER_GROUP].pixel;
|
2009-01-16 08:24:14 -07:00
|
|
|
break;
|
2012-12-17 10:48:57 -07:00
|
|
|
case CLIENT_UNGROUP:
|
2013-05-19 17:09:59 -06:00
|
|
|
pixel = sc->xftcolor[CWM_COLOR_BORDER_UNGROUP].pixel;
|
2009-01-16 08:24:14 -07:00
|
|
|
break;
|
|
|
|
default:
|
2013-05-19 17:09:59 -06:00
|
|
|
pixel = sc->xftcolor[CWM_COLOR_BORDER_ACTIVE].pixel;
|
2009-01-16 08:24:14 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
2013-05-19 17:09:59 -06:00
|
|
|
pixel = sc->xftcolor[CWM_COLOR_BORDER_INACTIVE].pixel;
|
2009-01-22 12:01:56 -07:00
|
|
|
|
2013-12-13 07:40:52 -07:00
|
|
|
if (cc->flags & CLIENT_URGENCY)
|
|
|
|
pixel = sc->xftcolor[CWM_COLOR_BORDER_URGENCY].pixel;
|
|
|
|
|
2017-04-26 15:10:54 -06:00
|
|
|
XSetWindowBorderWidth(X_Dpy, cc->win, (unsigned int)cc->bwidth);
|
2009-05-17 17:40:57 -06:00
|
|
|
XSetWindowBorder(X_Dpy, cc->win, pixel);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2009-06-26 06:21:58 -06:00
|
|
|
static void
|
2013-05-19 11:02:04 -06:00
|
|
|
client_wm_protocols(struct client_ctx *cc)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2009-11-28 10:52:12 -07:00
|
|
|
Atom *p;
|
2013-05-19 11:02:04 -06:00
|
|
|
int i, j;
|
|
|
|
|
|
|
|
if (XGetWMProtocols(X_Dpy, cc->win, &p, &j)) {
|
|
|
|
for (i = 0; i < j; i++) {
|
2013-07-15 08:50:44 -06:00
|
|
|
if (p[i] == cwmh[WM_DELETE_WINDOW])
|
2013-11-08 10:35:12 -07:00
|
|
|
cc->flags |= CLIENT_WM_DELETE_WINDOW;
|
2013-07-15 08:50:44 -06:00
|
|
|
else if (p[i] == cwmh[WM_TAKE_FOCUS])
|
2013-11-08 10:35:12 -07:00
|
|
|
cc->flags |= CLIENT_WM_TAKE_FOCUS;
|
2013-05-19 11:02:04 -06:00
|
|
|
}
|
|
|
|
XFree(p);
|
|
|
|
}
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2013-12-11 08:41:11 -07:00
|
|
|
void
|
|
|
|
client_wm_hints(struct client_ctx *cc)
|
|
|
|
{
|
|
|
|
if ((cc->wmh = XGetWMHints(X_Dpy, cc->win)) == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((cc->wmh->flags & InputHint) && (cc->wmh->input))
|
|
|
|
cc->flags |= CLIENT_INPUT;
|
2013-12-13 07:40:52 -07:00
|
|
|
|
|
|
|
if ((cc->wmh->flags & XUrgencyHint))
|
|
|
|
client_urgency(cc);
|
2013-12-11 08:41:11 -07:00
|
|
|
}
|
|
|
|
|
2013-06-10 15:37:30 -06:00
|
|
|
void
|
2013-12-12 13:15:07 -07:00
|
|
|
client_msg(struct client_ctx *cc, Atom proto, Time ts)
|
2013-06-10 15:37:30 -06:00
|
|
|
{
|
|
|
|
XClientMessageEvent cm;
|
|
|
|
|
2013-12-17 09:10:43 -07:00
|
|
|
(void)memset(&cm, 0, sizeof(cm));
|
2013-06-10 15:37:30 -06:00
|
|
|
cm.type = ClientMessage;
|
|
|
|
cm.window = cc->win;
|
2013-07-15 08:50:44 -06:00
|
|
|
cm.message_type = cwmh[WM_PROTOCOLS];
|
2013-06-10 15:37:30 -06:00
|
|
|
cm.format = 32;
|
|
|
|
cm.data.l[0] = proto;
|
2013-12-12 13:15:07 -07:00
|
|
|
cm.data.l[1] = ts;
|
2013-06-10 15:37:30 -06:00
|
|
|
|
|
|
|
XSendEvent(X_Dpy, cc->win, False, NoEventMask, (XEvent *)&cm);
|
|
|
|
}
|
|
|
|
|
2007-04-27 11:58:48 -06:00
|
|
|
void
|
|
|
|
client_send_delete(struct client_ctx *cc)
|
|
|
|
{
|
2013-11-08 10:35:12 -07:00
|
|
|
if (cc->flags & CLIENT_WM_DELETE_WINDOW)
|
2013-12-12 13:15:07 -07:00
|
|
|
client_msg(cc, cwmh[WM_DELETE_WINDOW], CurrentTime);
|
2007-04-27 11:58:48 -06:00
|
|
|
else
|
2007-05-28 12:34:27 -06:00
|
|
|
XKillClient(X_Dpy, cc->win);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
client_setname(struct client_ctx *cc)
|
|
|
|
{
|
2008-07-11 08:21:28 -06:00
|
|
|
struct winname *wn;
|
|
|
|
char *newname;
|
2016-10-04 09:52:32 -06:00
|
|
|
int i = 0;
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2013-07-15 08:50:44 -06:00
|
|
|
if (!xu_getstrprop(cc->win, ewmh[_NET_WM_NAME], &newname))
|
2011-06-23 23:40:09 -06:00
|
|
|
if (!xu_getstrprop(cc->win, XA_WM_NAME, &newname))
|
2013-01-01 07:26:29 -07:00
|
|
|
newname = xstrdup("");
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2014-09-08 14:37:02 -06:00
|
|
|
TAILQ_FOREACH(wn, &cc->nameq, entry) {
|
2007-04-27 11:58:48 -06:00
|
|
|
if (strcmp(wn->name, newname) == 0) {
|
|
|
|
/* Move to the last since we got a hit. */
|
|
|
|
TAILQ_REMOVE(&cc->nameq, wn, entry);
|
|
|
|
TAILQ_INSERT_TAIL(&cc->nameq, wn, entry);
|
|
|
|
goto match;
|
|
|
|
}
|
2014-09-08 14:37:02 -06:00
|
|
|
}
|
2009-06-19 18:22:39 -06:00
|
|
|
wn = xmalloc(sizeof(*wn));
|
2007-04-27 11:58:48 -06:00
|
|
|
wn->name = newname;
|
|
|
|
TAILQ_INSERT_TAIL(&cc->nameq, wn, entry);
|
|
|
|
match:
|
|
|
|
cc->name = wn->name;
|
|
|
|
|
2016-10-04 09:52:32 -06:00
|
|
|
/* Do some garbage collection. */
|
|
|
|
TAILQ_FOREACH(wn, &cc->nameq, entry)
|
|
|
|
i++;
|
|
|
|
if (i > Conf.nameqlen) {
|
|
|
|
wn = TAILQ_FIRST(&cc->nameq);
|
2007-04-27 11:58:48 -06:00
|
|
|
TAILQ_REMOVE(&cc->nameq, wn, entry);
|
2013-01-01 07:26:29 -07:00
|
|
|
free(wn->name);
|
2012-11-07 13:34:39 -07:00
|
|
|
free(wn);
|
2016-10-04 09:52:32 -06:00
|
|
|
i--;
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-23 23:40:09 -06:00
|
|
|
void
|
2011-09-03 03:20:58 -06:00
|
|
|
client_cycle(struct screen_ctx *sc, int flags)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2017-04-24 06:27:32 -06:00
|
|
|
struct client_ctx *newcc, *oldcc, *prevcc;
|
2008-05-01 12:01:13 -06:00
|
|
|
int again = 1;
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2014-09-08 14:11:22 -06:00
|
|
|
if (TAILQ_EMPTY(&sc->clientq))
|
2011-06-23 23:40:09 -06:00
|
|
|
return;
|
2007-06-05 13:03:20 -06:00
|
|
|
|
2017-04-24 06:27:32 -06:00
|
|
|
prevcc = TAILQ_FIRST(&sc->clientq);
|
2014-09-08 15:24:27 -06:00
|
|
|
oldcc = client_current();
|
2008-05-01 12:01:13 -06:00
|
|
|
if (oldcc == NULL)
|
2016-10-18 11:03:30 -06:00
|
|
|
oldcc = (flags & CWM_CYCLE_REVERSE) ?
|
|
|
|
TAILQ_LAST(&sc->clientq, client_q) :
|
2015-08-21 09:52:49 -06:00
|
|
|
TAILQ_FIRST(&sc->clientq);
|
2007-06-05 13:03:20 -06:00
|
|
|
|
2008-05-01 12:01:13 -06:00
|
|
|
newcc = oldcc;
|
|
|
|
while (again) {
|
|
|
|
again = 0;
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2016-10-18 11:03:30 -06:00
|
|
|
newcc = (flags & CWM_CYCLE_REVERSE) ? client_prev(newcc) :
|
2015-08-21 09:52:49 -06:00
|
|
|
client_next(newcc);
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2008-06-30 11:52:37 -06:00
|
|
|
/* Only cycle visible and non-ignored windows. */
|
2017-12-22 14:21:44 -07:00
|
|
|
if ((newcc->flags & (CLIENT_SKIP_CYCLE)) ||
|
|
|
|
((flags & CWM_CYCLE_INGROUP) &&
|
|
|
|
(newcc->gc != oldcc->gc)))
|
2008-05-01 12:01:13 -06:00
|
|
|
again = 1;
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2008-05-01 12:01:13 -06:00
|
|
|
/* Is oldcc the only non-hidden window? */
|
|
|
|
if (newcc == oldcc) {
|
|
|
|
if (again)
|
2011-06-23 23:40:09 -06:00
|
|
|
return; /* No windows visible. */
|
2008-05-19 09:17:50 -06:00
|
|
|
break;
|
2008-05-01 12:01:13 -06:00
|
|
|
}
|
|
|
|
}
|
2008-05-19 09:17:50 -06:00
|
|
|
|
2017-12-22 14:21:44 -07:00
|
|
|
/* Reset when cycling mod is released. XXX I hate this hack */
|
2012-05-13 09:17:13 -06:00
|
|
|
sc->cycling = 1;
|
2008-05-01 12:01:13 -06:00
|
|
|
client_ptrsave(oldcc);
|
2017-04-24 06:27:32 -06:00
|
|
|
client_raise(prevcc);
|
2016-10-03 07:41:30 -06:00
|
|
|
client_raise(newcc);
|
2016-10-06 08:30:05 -06:00
|
|
|
if (!client_inbound(newcc, newcc->ptr.x, newcc->ptr.y)) {
|
|
|
|
newcc->ptr.x = newcc->geom.w / 2;
|
|
|
|
newcc->ptr.y = newcc->geom.h / 2;
|
|
|
|
}
|
2008-05-01 12:01:13 -06:00
|
|
|
client_ptrwarp(newcc);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2009-06-26 06:21:58 -06:00
|
|
|
static struct client_ctx *
|
2014-09-08 14:32:40 -06:00
|
|
|
client_next(struct client_ctx *cc)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2009-08-26 19:38:08 -06:00
|
|
|
struct screen_ctx *sc = cc->sc;
|
2015-08-21 09:52:49 -06:00
|
|
|
struct client_ctx *newcc;
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2015-08-21 09:52:49 -06:00
|
|
|
return(((newcc = TAILQ_NEXT(cc, entry)) != NULL) ?
|
|
|
|
newcc : TAILQ_FIRST(&sc->clientq));
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2009-06-26 06:21:58 -06:00
|
|
|
static struct client_ctx *
|
2014-09-08 14:32:40 -06:00
|
|
|
client_prev(struct client_ctx *cc)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2009-08-26 19:38:08 -06:00
|
|
|
struct screen_ctx *sc = cc->sc;
|
2015-08-21 09:52:49 -06:00
|
|
|
struct client_ctx *newcc;
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2016-10-18 11:03:30 -06:00
|
|
|
return(((newcc = TAILQ_PREV(cc, client_q, entry)) != NULL) ?
|
|
|
|
newcc : TAILQ_LAST(&sc->clientq, client_q));
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2009-06-26 06:21:58 -06:00
|
|
|
static void
|
2007-04-27 11:58:48 -06:00
|
|
|
client_placecalc(struct client_ctx *cc)
|
|
|
|
{
|
2009-08-26 19:38:08 -06:00
|
|
|
struct screen_ctx *sc = cc->sc;
|
2009-01-22 12:01:56 -07:00
|
|
|
int xslack, yslack;
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2015-08-21 10:52:37 -06:00
|
|
|
if (cc->hint.flags & (USPosition | PPosition)) {
|
2018-02-06 08:05:20 -07:00
|
|
|
if (cc->geom.x >= sc->view.w)
|
|
|
|
cc->geom.x = sc->view.w - cc->bwidth - 1;
|
2017-05-05 08:14:19 -06:00
|
|
|
if (cc->geom.x + cc->geom.w + cc->bwidth <= 0)
|
|
|
|
cc->geom.x = -(cc->geom.w + cc->bwidth - 1);
|
2018-02-06 08:05:20 -07:00
|
|
|
if (cc->geom.y >= sc->view.h)
|
|
|
|
cc->geom.x = sc->view.h - cc->bwidth - 1;
|
2017-05-05 08:14:19 -06:00
|
|
|
if (cc->geom.y + cc->geom.h + cc->bwidth <= 0)
|
|
|
|
cc->geom.y = -(cc->geom.h + cc->bwidth - 1);
|
2018-11-08 08:49:42 -07:00
|
|
|
if (cc->flags & CLIENT_IGNORE) {
|
|
|
|
if (((cc->obwidth * 2) + cc->geom.x + cc->geom.w) == sc->view.w)
|
|
|
|
cc->geom.x += cc->obwidth * 2;
|
|
|
|
if (((cc->obwidth * 2) + cc->geom.y + cc->geom.h) == sc->view.h)
|
|
|
|
cc->geom.y += cc->obwidth * 2;
|
|
|
|
}
|
2007-04-27 11:58:48 -06:00
|
|
|
} else {
|
2015-06-26 11:17:46 -06:00
|
|
|
struct geom area;
|
2013-01-01 19:19:20 -07:00
|
|
|
int xmouse, ymouse;
|
2008-09-29 17:16:46 -06:00
|
|
|
|
|
|
|
xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse);
|
2015-11-11 07:22:01 -07:00
|
|
|
area = screen_area(sc, xmouse, ymouse, CWM_GAP);
|
2015-06-26 11:17:46 -06:00
|
|
|
area.w += area.x;
|
|
|
|
area.h += area.y;
|
|
|
|
xmouse = MAX(xmouse, area.x) - cc->geom.w / 2;
|
|
|
|
ymouse = MAX(ymouse, area.y) - cc->geom.h / 2;
|
2009-01-22 12:01:56 -07:00
|
|
|
|
2015-06-26 11:17:46 -06:00
|
|
|
xmouse = MAX(xmouse, area.x);
|
|
|
|
ymouse = MAX(ymouse, area.y);
|
2008-09-29 17:16:46 -06:00
|
|
|
|
2015-06-26 11:17:46 -06:00
|
|
|
xslack = area.w - cc->geom.w - cc->bwidth * 2;
|
|
|
|
yslack = area.h - cc->geom.h - cc->bwidth * 2;
|
2008-09-29 17:16:46 -06:00
|
|
|
|
2015-06-26 11:17:46 -06:00
|
|
|
if (xslack >= area.x) {
|
|
|
|
cc->geom.x = MAX(MIN(xmouse, xslack), area.x);
|
2007-04-27 11:58:48 -06:00
|
|
|
} else {
|
2015-06-26 11:17:46 -06:00
|
|
|
cc->geom.x = area.x;
|
|
|
|
cc->geom.w = area.w;
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
2015-06-26 11:17:46 -06:00
|
|
|
if (yslack >= area.y) {
|
|
|
|
cc->geom.y = MAX(MIN(ymouse, yslack), area.y);
|
2007-04-27 11:58:48 -06:00
|
|
|
} else {
|
2015-06-26 11:17:46 -06:00
|
|
|
cc->geom.y = area.y;
|
|
|
|
cc->geom.h = area.h;
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-29 11:50:43 -07:00
|
|
|
void
|
2007-04-27 11:58:48 -06:00
|
|
|
client_mtf(struct client_ctx *cc)
|
|
|
|
{
|
2013-11-26 17:01:23 -07:00
|
|
|
struct screen_ctx *sc = cc->sc;
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2014-09-08 14:11:22 -06:00
|
|
|
TAILQ_REMOVE(&sc->clientq, cc, entry);
|
|
|
|
TAILQ_INSERT_HEAD(&sc->clientq, cc, entry);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2009-08-24 17:49:04 -06:00
|
|
|
void
|
|
|
|
client_getsizehints(struct client_ctx *cc)
|
|
|
|
{
|
|
|
|
long tmp;
|
2013-11-27 10:04:35 -07:00
|
|
|
XSizeHints size;
|
2009-08-24 17:49:04 -06:00
|
|
|
|
2013-11-27 10:04:35 -07:00
|
|
|
if (!XGetWMNormalHints(X_Dpy, cc->win, &size, &tmp))
|
|
|
|
size.flags = 0;
|
2009-08-24 17:49:04 -06:00
|
|
|
|
2013-11-27 10:04:35 -07:00
|
|
|
cc->hint.flags = size.flags;
|
2013-11-02 13:13:56 -06:00
|
|
|
|
2013-11-27 10:04:35 -07:00
|
|
|
if (size.flags & PBaseSize) {
|
|
|
|
cc->hint.basew = size.base_width;
|
|
|
|
cc->hint.baseh = size.base_height;
|
|
|
|
} else if (size.flags & PMinSize) {
|
|
|
|
cc->hint.basew = size.min_width;
|
|
|
|
cc->hint.baseh = size.min_height;
|
2009-08-24 17:49:04 -06:00
|
|
|
}
|
2013-11-27 10:04:35 -07:00
|
|
|
if (size.flags & PMinSize) {
|
|
|
|
cc->hint.minw = size.min_width;
|
|
|
|
cc->hint.minh = size.min_height;
|
|
|
|
} else if (size.flags & PBaseSize) {
|
|
|
|
cc->hint.minw = size.base_width;
|
|
|
|
cc->hint.minh = size.base_height;
|
2009-08-24 17:49:04 -06:00
|
|
|
}
|
2013-11-27 10:04:35 -07:00
|
|
|
if (size.flags & PMaxSize) {
|
|
|
|
cc->hint.maxw = size.max_width;
|
|
|
|
cc->hint.maxh = size.max_height;
|
2009-08-24 17:49:04 -06:00
|
|
|
}
|
2013-11-27 10:04:35 -07:00
|
|
|
if (size.flags & PResizeInc) {
|
|
|
|
cc->hint.incw = size.width_inc;
|
|
|
|
cc->hint.inch = size.height_inc;
|
2009-08-24 17:49:04 -06:00
|
|
|
}
|
2011-09-03 03:42:33 -06:00
|
|
|
cc->hint.incw = MAX(1, cc->hint.incw);
|
|
|
|
cc->hint.inch = MAX(1, cc->hint.inch);
|
2015-11-12 11:33:30 -07:00
|
|
|
cc->hint.minw = MAX(1, cc->hint.minw);
|
|
|
|
cc->hint.minh = MAX(1, cc->hint.minh);
|
2009-08-24 19:32:40 -06:00
|
|
|
|
2013-11-27 10:04:35 -07:00
|
|
|
if (size.flags & PAspect) {
|
|
|
|
if (size.min_aspect.x > 0)
|
|
|
|
cc->hint.mina = (float)size.min_aspect.y /
|
|
|
|
size.min_aspect.x;
|
|
|
|
if (size.max_aspect.y > 0)
|
|
|
|
cc->hint.maxa = (float)size.max_aspect.x /
|
|
|
|
size.max_aspect.y;
|
2009-08-24 17:49:04 -06:00
|
|
|
}
|
|
|
|
}
|
2012-05-13 09:15:54 -06:00
|
|
|
|
2009-08-24 17:49:04 -06:00
|
|
|
void
|
|
|
|
client_applysizehints(struct client_ctx *cc)
|
|
|
|
{
|
|
|
|
Bool baseismin;
|
|
|
|
|
2011-09-03 03:42:33 -06:00
|
|
|
baseismin = (cc->hint.basew == cc->hint.minw) &&
|
|
|
|
(cc->hint.baseh == cc->hint.minh);
|
2009-08-24 17:49:04 -06:00
|
|
|
|
|
|
|
/* temporarily remove base dimensions, ICCCM 4.1.2.3 */
|
|
|
|
if (!baseismin) {
|
2012-07-13 11:01:04 -06:00
|
|
|
cc->geom.w -= cc->hint.basew;
|
|
|
|
cc->geom.h -= cc->hint.baseh;
|
2009-08-24 17:49:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* adjust for aspect limits */
|
2013-11-27 07:20:32 -07:00
|
|
|
if (cc->hint.mina && cc->hint.maxa) {
|
|
|
|
if (cc->hint.maxa < (float)cc->geom.w / cc->geom.h)
|
2012-07-13 11:01:04 -06:00
|
|
|
cc->geom.w = cc->geom.h * cc->hint.maxa;
|
2013-11-27 07:20:32 -07:00
|
|
|
else if (cc->hint.mina < (float)cc->geom.h / cc->geom.w)
|
2012-07-13 11:01:04 -06:00
|
|
|
cc->geom.h = cc->geom.w * cc->hint.mina;
|
2009-08-24 17:49:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* remove base dimensions for increment */
|
|
|
|
if (baseismin) {
|
2012-07-13 11:01:04 -06:00
|
|
|
cc->geom.w -= cc->hint.basew;
|
|
|
|
cc->geom.h -= cc->hint.baseh;
|
2009-08-24 17:49:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* adjust for increment value */
|
2012-07-13 11:01:04 -06:00
|
|
|
cc->geom.w -= cc->geom.w % cc->hint.incw;
|
|
|
|
cc->geom.h -= cc->geom.h % cc->hint.inch;
|
2009-08-24 17:49:04 -06:00
|
|
|
|
|
|
|
/* restore base dimensions */
|
2012-07-13 11:01:04 -06:00
|
|
|
cc->geom.w += cc->hint.basew;
|
|
|
|
cc->geom.h += cc->hint.baseh;
|
2009-08-24 17:49:04 -06:00
|
|
|
|
|
|
|
/* adjust for min width/height */
|
2012-07-13 11:01:04 -06:00
|
|
|
cc->geom.w = MAX(cc->geom.w, cc->hint.minw);
|
|
|
|
cc->geom.h = MAX(cc->geom.h, cc->hint.minh);
|
2009-08-24 17:49:04 -06:00
|
|
|
|
|
|
|
/* adjust for max width/height */
|
2011-09-03 03:42:33 -06:00
|
|
|
if (cc->hint.maxw)
|
2012-07-13 11:01:04 -06:00
|
|
|
cc->geom.w = MIN(cc->geom.w, cc->hint.maxw);
|
2011-09-03 03:42:33 -06:00
|
|
|
if (cc->hint.maxh)
|
2012-07-13 11:01:04 -06:00
|
|
|
cc->geom.h = MIN(cc->geom.h, cc->hint.maxh);
|
2009-08-24 17:49:04 -06:00
|
|
|
}
|
|
|
|
|
2009-06-26 06:21:58 -06:00
|
|
|
static void
|
2013-12-11 08:46:47 -07:00
|
|
|
client_mwm_hints(struct client_ctx *cc)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2008-07-11 08:21:28 -06:00
|
|
|
struct mwm_hints *mwmh;
|
2007-04-27 11:58:48 -06:00
|
|
|
|
2017-12-22 14:21:44 -07:00
|
|
|
if (xu_getprop(cc->win, cwmh[_MOTIF_WM_HINTS],
|
|
|
|
cwmh[_MOTIF_WM_HINTS], MWM_HINTS_ELEMENTS,
|
|
|
|
(unsigned char **)&mwmh) == MWM_HINTS_ELEMENTS) {
|
2015-05-20 17:54:39 -06:00
|
|
|
if (mwmh->flags & MWM_FLAGS_DECORATIONS &&
|
2007-04-27 11:58:48 -06:00
|
|
|
!(mwmh->decorations & MWM_DECOR_ALL) &&
|
|
|
|
!(mwmh->decorations & MWM_DECOR_BORDER))
|
|
|
|
cc->bwidth = 0;
|
2015-03-28 18:21:05 -06:00
|
|
|
XFree(mwmh);
|
2014-09-08 14:37:02 -06:00
|
|
|
}
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
|
|
|
|
2011-09-13 02:41:57 -06:00
|
|
|
void
|
|
|
|
client_transient(struct client_ctx *cc)
|
|
|
|
{
|
|
|
|
struct client_ctx *tc;
|
|
|
|
Window trans;
|
|
|
|
|
|
|
|
if (XGetTransientForHint(X_Dpy, cc->win, &trans)) {
|
2018-11-13 10:37:13 -07:00
|
|
|
if ((tc = client_find(trans)) != NULL) {
|
|
|
|
if (tc->flags & CLIENT_IGNORE) {
|
2011-09-13 02:41:57 -06:00
|
|
|
cc->flags |= CLIENT_IGNORE;
|
2018-11-13 10:37:13 -07:00
|
|
|
cc->bwidth = tc->bwidth;
|
|
|
|
}
|
2011-09-13 02:41:57 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-20 13:11:19 -06:00
|
|
|
int
|
2009-05-17 18:23:35 -06:00
|
|
|
client_inbound(struct client_ctx *cc, int x, int y)
|
2007-04-27 11:58:48 -06:00
|
|
|
{
|
2014-09-07 13:27:30 -06:00
|
|
|
return(x < cc->geom.w && x >= 0 &&
|
2012-07-13 11:01:04 -06:00
|
|
|
y < cc->geom.h && y >= 0);
|
2007-04-27 11:58:48 -06:00
|
|
|
}
|
2011-06-24 00:06:24 -06:00
|
|
|
|
|
|
|
int
|
2013-01-02 14:37:21 -07:00
|
|
|
client_snapcalc(int n0, int n1, int e0, int e1, int snapdist)
|
2011-06-24 00:06:24 -06:00
|
|
|
{
|
2013-01-02 14:37:21 -07:00
|
|
|
int s0, s1;
|
2011-06-24 00:06:24 -06:00
|
|
|
|
|
|
|
s0 = s1 = 0;
|
|
|
|
|
2013-01-02 14:37:21 -07:00
|
|
|
if (abs(e0 - n0) <= snapdist)
|
|
|
|
s0 = e0 - n0;
|
2011-06-24 00:06:24 -06:00
|
|
|
|
2013-01-02 14:37:21 -07:00
|
|
|
if (abs(e1 - n1) <= snapdist)
|
|
|
|
s1 = e1 - n1;
|
2011-06-24 00:06:24 -06:00
|
|
|
|
|
|
|
/* possible to snap in both directions */
|
|
|
|
if (s0 != 0 && s1 != 0)
|
|
|
|
if (abs(s0) < abs(s1))
|
2014-09-07 13:27:30 -06:00
|
|
|
return(s0);
|
2011-06-24 00:06:24 -06:00
|
|
|
else
|
2014-09-07 13:27:30 -06:00
|
|
|
return(s1);
|
2011-06-24 00:06:24 -06:00
|
|
|
else if (s0 != 0)
|
2014-09-07 13:27:30 -06:00
|
|
|
return(s0);
|
2011-06-24 00:06:24 -06:00
|
|
|
else if (s1 != 0)
|
2014-09-07 13:27:30 -06:00
|
|
|
return(s1);
|
2011-06-24 00:06:24 -06:00
|
|
|
else
|
2014-09-07 13:27:30 -06:00
|
|
|
return(0);
|
2011-06-24 00:06:24 -06:00
|
|
|
}
|
2013-01-08 08:16:04 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
client_htile(struct client_ctx *cc)
|
|
|
|
{
|
|
|
|
struct client_ctx *ci;
|
2015-08-27 12:53:14 -06:00
|
|
|
struct group_ctx *gc = cc->gc;
|
2013-01-08 08:16:04 -07:00
|
|
|
struct screen_ctx *sc = cc->sc;
|
2015-11-11 07:22:01 -07:00
|
|
|
struct geom area;
|
2017-04-24 07:31:19 -06:00
|
|
|
int i, n, mh, x, w, h;
|
2013-01-08 08:16:04 -07:00
|
|
|
|
|
|
|
if (!gc)
|
|
|
|
return;
|
|
|
|
i = n = 0;
|
|
|
|
|
2019-02-22 07:39:18 -07:00
|
|
|
area = screen_area(sc,
|
|
|
|
cc->geom.x + cc->geom.w / 2,
|
|
|
|
cc->geom.y + cc->geom.h / 2, CWM_GAP);
|
|
|
|
|
2014-09-08 15:15:14 -06:00
|
|
|
TAILQ_FOREACH(ci, &gc->clientq, group_entry) {
|
2013-01-08 08:16:04 -07:00
|
|
|
if (ci->flags & CLIENT_HIDDEN ||
|
2019-02-22 07:39:18 -07:00
|
|
|
ci->flags & CLIENT_IGNORE || (ci == cc) ||
|
|
|
|
ci->geom.x < area.x ||
|
|
|
|
ci->geom.x > (area.x + area.w) ||
|
|
|
|
ci->geom.y < area.y ||
|
|
|
|
ci->geom.y > (area.y + area.h))
|
2013-01-08 08:16:04 -07:00
|
|
|
continue;
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
if (n == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (cc->flags & CLIENT_VMAXIMIZED ||
|
2015-11-11 07:22:01 -07:00
|
|
|
cc->geom.h + (cc->bwidth * 2) >= area.h)
|
2013-01-08 08:16:04 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
cc->flags &= ~CLIENT_HMAXIMIZED;
|
2015-11-11 07:22:01 -07:00
|
|
|
cc->geom.x = area.x;
|
|
|
|
cc->geom.y = area.y;
|
|
|
|
cc->geom.w = area.w - (cc->bwidth * 2);
|
2017-04-24 07:31:19 -06:00
|
|
|
cc->geom.h = (area.h - (cc->bwidth * 2)) / 2;
|
2013-01-08 08:16:04 -07:00
|
|
|
client_resize(cc, 1);
|
|
|
|
client_ptrwarp(cc);
|
|
|
|
|
|
|
|
mh = cc->geom.h + (cc->bwidth * 2);
|
2015-11-11 07:22:01 -07:00
|
|
|
x = area.x;
|
|
|
|
w = area.w / n;
|
|
|
|
h = area.h - mh;
|
2014-09-08 15:15:14 -06:00
|
|
|
TAILQ_FOREACH(ci, &gc->clientq, group_entry) {
|
2013-01-08 08:16:04 -07:00
|
|
|
if (ci->flags & CLIENT_HIDDEN ||
|
2019-02-22 07:39:18 -07:00
|
|
|
ci->flags & CLIENT_IGNORE || (ci == cc) ||
|
|
|
|
ci->geom.x < area.x ||
|
|
|
|
ci->geom.x > (area.x + area.w) ||
|
|
|
|
ci->geom.y < area.y ||
|
|
|
|
ci->geom.y > (area.y + area.h))
|
2013-01-08 08:16:04 -07:00
|
|
|
continue;
|
|
|
|
ci->bwidth = Conf.bwidth;
|
|
|
|
ci->geom.x = x;
|
2017-04-24 07:31:19 -06:00
|
|
|
ci->geom.y = area.y + mh;
|
2013-01-08 08:16:04 -07:00
|
|
|
ci->geom.w = w - (ci->bwidth * 2);
|
2017-04-24 07:31:19 -06:00
|
|
|
ci->geom.h = h - (ci->bwidth * 2);
|
2013-01-08 08:16:04 -07:00
|
|
|
if (i + 1 == n)
|
2015-11-11 07:22:01 -07:00
|
|
|
ci->geom.w = area.x + area.w -
|
2013-01-08 08:16:04 -07:00
|
|
|
ci->geom.x - (ci->bwidth * 2);
|
|
|
|
x += w;
|
|
|
|
i++;
|
2017-04-24 07:31:19 -06:00
|
|
|
client_resize(ci, 1);
|
2013-01-08 08:16:04 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
client_vtile(struct client_ctx *cc)
|
|
|
|
{
|
|
|
|
struct client_ctx *ci;
|
2015-08-27 12:53:14 -06:00
|
|
|
struct group_ctx *gc = cc->gc;
|
2013-01-08 08:16:04 -07:00
|
|
|
struct screen_ctx *sc = cc->sc;
|
2015-11-11 07:22:01 -07:00
|
|
|
struct geom area;
|
2017-04-24 07:31:19 -06:00
|
|
|
int i, n, mw, y, w, h;
|
2013-01-08 08:16:04 -07:00
|
|
|
|
|
|
|
if (!gc)
|
|
|
|
return;
|
2019-02-22 07:39:18 -07:00
|
|
|
|
|
|
|
area = screen_area(sc,
|
|
|
|
cc->geom.x + cc->geom.w / 2,
|
|
|
|
cc->geom.y + cc->geom.h / 2, CWM_GAP);
|
|
|
|
|
2013-01-08 08:16:04 -07:00
|
|
|
i = n = 0;
|
|
|
|
|
2014-09-08 15:15:14 -06:00
|
|
|
TAILQ_FOREACH(ci, &gc->clientq, group_entry) {
|
2013-01-08 08:16:04 -07:00
|
|
|
if (ci->flags & CLIENT_HIDDEN ||
|
2019-02-22 07:39:18 -07:00
|
|
|
ci->flags & CLIENT_IGNORE || (ci == cc) ||
|
|
|
|
ci->geom.x < area.x ||
|
|
|
|
ci->geom.x > (area.x + area.w) ||
|
|
|
|
ci->geom.y < area.y ||
|
|
|
|
ci->geom.y > (area.y + area.h))
|
2013-01-08 08:16:04 -07:00
|
|
|
continue;
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
if (n == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (cc->flags & CLIENT_HMAXIMIZED ||
|
2015-11-11 07:22:01 -07:00
|
|
|
cc->geom.w + (cc->bwidth * 2) >= area.w)
|
2013-01-08 08:16:04 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
cc->flags &= ~CLIENT_VMAXIMIZED;
|
2015-11-11 07:22:01 -07:00
|
|
|
cc->geom.x = area.x;
|
|
|
|
cc->geom.y = area.y;
|
2017-04-24 06:18:04 -06:00
|
|
|
cc->geom.w = (area.w - (cc->bwidth * 2)) / 2;
|
2017-04-24 07:31:19 -06:00
|
|
|
cc->geom.h = area.h - (cc->bwidth * 2);
|
2013-01-08 08:16:04 -07:00
|
|
|
client_resize(cc, 1);
|
|
|
|
client_ptrwarp(cc);
|
|
|
|
|
|
|
|
mw = cc->geom.w + (cc->bwidth * 2);
|
2015-11-11 07:22:01 -07:00
|
|
|
y = area.y;
|
|
|
|
h = area.h / n;
|
|
|
|
w = area.w - mw;
|
2014-09-08 15:15:14 -06:00
|
|
|
TAILQ_FOREACH(ci, &gc->clientq, group_entry) {
|
2013-01-08 08:16:04 -07:00
|
|
|
if (ci->flags & CLIENT_HIDDEN ||
|
2019-02-22 07:39:18 -07:00
|
|
|
ci->flags & CLIENT_IGNORE || (ci == cc) ||
|
|
|
|
ci->geom.x < area.x ||
|
|
|
|
ci->geom.x > (area.x + area.w) ||
|
|
|
|
ci->geom.y < area.y ||
|
|
|
|
ci->geom.y > (area.y + area.h))
|
2013-01-08 08:16:04 -07:00
|
|
|
continue;
|
|
|
|
ci->bwidth = Conf.bwidth;
|
2015-11-11 07:22:01 -07:00
|
|
|
ci->geom.x = area.x + mw;
|
2017-04-24 07:31:19 -06:00
|
|
|
ci->geom.y = y;
|
2013-01-08 08:16:04 -07:00
|
|
|
ci->geom.w = w - (ci->bwidth * 2);
|
2017-04-24 07:31:19 -06:00
|
|
|
ci->geom.h = h - (ci->bwidth * 2);
|
2013-01-08 08:16:04 -07:00
|
|
|
if (i + 1 == n)
|
2015-11-11 07:22:01 -07:00
|
|
|
ci->geom.h = area.y + area.h -
|
2013-01-08 08:16:04 -07:00
|
|
|
ci->geom.y - (ci->bwidth * 2);
|
|
|
|
y += h;
|
|
|
|
i++;
|
2017-04-24 07:31:19 -06:00
|
|
|
client_resize(ci, 1);
|
2013-01-08 08:16:04 -07:00
|
|
|
}
|
|
|
|
}
|
2013-12-11 07:16:09 -07:00
|
|
|
|
|
|
|
long
|
|
|
|
client_get_wm_state(struct client_ctx *cc)
|
|
|
|
{
|
|
|
|
long *p, state = -1;
|
|
|
|
|
|
|
|
if (xu_getprop(cc->win, cwmh[WM_STATE], cwmh[WM_STATE], 2L,
|
|
|
|
(unsigned char **)&p) > 0) {
|
|
|
|
state = *p;
|
|
|
|
XFree(p);
|
|
|
|
}
|
|
|
|
return(state);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
client_set_wm_state(struct client_ctx *cc, long state)
|
|
|
|
{
|
|
|
|
long data[] = { state, None };
|
|
|
|
|
|
|
|
XChangeProperty(X_Dpy, cc->win, cwmh[WM_STATE], cwmh[WM_STATE], 32,
|
|
|
|
PropModeReplace, (unsigned char *)data, 2);
|
|
|
|
}
|