2007-04-27 21:58:48 +04:00
|
|
|
/*
|
|
|
|
* calmwm - the calm window manager
|
|
|
|
*
|
|
|
|
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
2008-01-11 19:06:44 +03: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.
|
2007-04-27 21:58:48 +04:00
|
|
|
*
|
2011-05-11 17:53:51 +04:00
|
|
|
* $OpenBSD$
|
2007-04-27 21:58:48 +04:00
|
|
|
*/
|
|
|
|
|
2015-01-19 17:54:16 +03:00
|
|
|
#include <sys/types.h>
|
2012-11-26 19:27:22 +04:00
|
|
|
#include "queue.h"
|
2009-12-15 07:10:42 +03:00
|
|
|
|
|
|
|
#include <err.h>
|
|
|
|
#include <errno.h>
|
2015-01-19 17:54:16 +03:00
|
|
|
#include <limits.h>
|
2012-11-09 07:52:02 +04:00
|
|
|
#include <stdio.h>
|
2009-12-15 07:10:42 +03:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
2009-12-15 06:34:34 +03:00
|
|
|
|
2007-04-27 21:58:48 +04:00
|
|
|
#include "calmwm.h"
|
|
|
|
|
2020-02-27 17:56:39 +03:00
|
|
|
static void client_class_hint(struct client_ctx *);
|
|
|
|
static void client_placement(struct client_ctx *);
|
2013-12-11 19:46:47 +04:00
|
|
|
static void client_mwm_hints(struct client_ctx *);
|
2020-02-27 17:56:39 +03:00
|
|
|
static void client_wm_protocols(struct client_ctx *);
|
2007-04-27 21:58:48 +04:00
|
|
|
|
|
|
|
struct client_ctx *
|
2020-03-24 17:47:29 +03:00
|
|
|
client_init(Window win, struct screen_ctx *sc)
|
2007-04-27 21:58:48 +04:00
|
|
|
{
|
2008-07-11 18:21:28 +04:00
|
|
|
struct client_ctx *cc;
|
|
|
|
XWindowAttributes wattr;
|
2014-02-04 00:20:39 +04:00
|
|
|
int mapped;
|
2020-02-27 17:56:39 +03:00
|
|
|
long state;
|
2007-04-27 21:58:48 +04:00
|
|
|
|
|
|
|
if (win == None)
|
2020-02-27 17:56:39 +03:00
|
|
|
return NULL;
|
2014-02-03 01:34:05 +04:00
|
|
|
if (!XGetWindowAttributes(X_Dpy, win, &wattr))
|
2020-02-27 17:56:39 +03:00
|
|
|
return NULL;
|
2014-02-04 00:20:39 +04:00
|
|
|
|
|
|
|
if (sc == NULL) {
|
2015-06-30 17:01:43 +03:00
|
|
|
if ((sc = screen_find(wattr.root)) == NULL)
|
2020-02-27 17:56:39 +03:00
|
|
|
return NULL;
|
2014-02-04 00:20:39 +04:00
|
|
|
mapped = 1;
|
|
|
|
} else {
|
|
|
|
if (wattr.override_redirect || wattr.map_state != IsViewable)
|
2020-02-27 17:56:39 +03:00
|
|
|
return NULL;
|
2014-02-04 00:20:39 +04:00
|
|
|
mapped = wattr.map_state != IsUnmapped;
|
|
|
|
}
|
2007-04-27 21:58:48 +04:00
|
|
|
|
2007-05-28 22:34:27 +04:00
|
|
|
XGrabServer(X_Dpy);
|
2007-04-27 21:58:48 +04:00
|
|
|
|
2018-11-13 20:37:13 +03:00
|
|
|
cc = xmalloc(sizeof(*cc));
|
2007-04-27 21:58:48 +04:00
|
|
|
cc->sc = sc;
|
|
|
|
cc->win = win;
|
2020-02-27 17:56:39 +03:00
|
|
|
cc->name = NULL;
|
2016-09-13 20:42:58 +03:00
|
|
|
cc->label = NULL;
|
2016-09-12 16:48:41 +03:00
|
|
|
cc->gc = NULL;
|
2020-02-27 17:56:39 +03:00
|
|
|
cc->res_class = NULL;
|
|
|
|
cc->res_name = NULL;
|
2016-09-12 16:48:41 +03:00
|
|
|
cc->flags = 0;
|
|
|
|
cc->stackingorder = 0;
|
2020-02-27 17:56:39 +03:00
|
|
|
cc->initial_state = 0;
|
2016-09-12 16:48:41 +03:00
|
|
|
memset(&cc->hint, 0, sizeof(cc->hint));
|
2009-05-30 04:30:17 +04:00
|
|
|
TAILQ_INIT(&cc->nameq);
|
|
|
|
|
2018-11-13 20:37:13 +03: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;
|
|
|
|
|
2020-02-27 17:56:39 +03:00
|
|
|
client_set_name(cc);
|
2009-05-30 04:30:17 +04:00
|
|
|
conf_client(cc);
|
|
|
|
|
2013-12-11 19:41:11 +04:00
|
|
|
client_wm_hints(cc);
|
2020-02-27 17:56:39 +03:00
|
|
|
client_class_hint(cc);
|
2013-12-11 18:09:21 +04:00
|
|
|
client_wm_protocols(cc);
|
2020-02-27 17:56:39 +03:00
|
|
|
client_get_sizehints(cc);
|
2018-11-13 20:37:13 +03:00
|
|
|
client_transient(cc);
|
2013-12-11 19:46:47 +04:00
|
|
|
client_mwm_hints(cc);
|
2013-04-04 00:22:55 +04:00
|
|
|
|
2018-11-13 20:37:13 +03:00
|
|
|
if ((cc->flags & CLIENT_IGNORE))
|
|
|
|
cc->bwidth = 0;
|
2016-12-07 00:00:13 +03: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 23:55:54 +03:00
|
|
|
cc->ptr.x = cc->geom.w / 2;
|
|
|
|
cc->ptr.y = cc->geom.h / 2;
|
|
|
|
|
2007-04-27 21:58:48 +04:00
|
|
|
if (wattr.map_state != IsViewable) {
|
2020-02-27 17:56:39 +03:00
|
|
|
client_placement(cc);
|
2017-02-06 21:10:28 +03:00
|
|
|
client_resize(cc, 0);
|
2020-02-27 17:56:39 +03:00
|
|
|
if (cc->initial_state)
|
|
|
|
xu_set_wm_state(cc->win, cc->initial_state);
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
|
2020-02-28 16:38:35 +03:00
|
|
|
XSelectInput(X_Dpy, cc->win,
|
|
|
|
EnterWindowMask | PropertyChangeMask | KeyReleaseMask);
|
2007-04-27 21:58:48 +04:00
|
|
|
|
2013-12-13 19:56:44 +04:00
|
|
|
XAddToSaveSet(X_Dpy, cc->win);
|
|
|
|
|
2007-04-27 21:58:48 +04:00
|
|
|
/* Notify client of its configuration. */
|
2013-06-11 01:37:30 +04:00
|
|
|
client_config(cc);
|
2007-04-27 21:58:48 +04:00
|
|
|
|
2014-09-09 00:11:22 +04:00
|
|
|
TAILQ_INSERT_TAIL(&sc->clientq, cc, entry);
|
2012-07-03 17:49:03 +04:00
|
|
|
|
|
|
|
xu_ewmh_net_client_list(sc);
|
2015-08-24 18:42:57 +03:00
|
|
|
xu_ewmh_net_client_list_stacking(sc);
|
2013-05-21 01:13:58 +04:00
|
|
|
xu_ewmh_restore_net_wm_state(cc);
|
2008-04-16 00:24:41 +04:00
|
|
|
|
2020-02-27 17:56:39 +03:00
|
|
|
xu_get_wm_state(cc->win, &state);
|
|
|
|
if (state == IconicState)
|
2015-01-23 22:35:11 +03:00
|
|
|
client_hide(cc);
|
|
|
|
else
|
2019-02-28 16:11:53 +03:00
|
|
|
client_show(cc);
|
2015-01-23 22:35:11 +03:00
|
|
|
|
2015-08-25 21:29:10 +03:00
|
|
|
if (mapped) {
|
2018-11-13 20:37:13 +03:00
|
|
|
if (cc->gc) {
|
|
|
|
group_movetogroup(cc, cc->gc->num);
|
|
|
|
goto out;
|
|
|
|
}
|
2015-08-25 21:29:10 +03:00
|
|
|
if (group_restore(cc))
|
|
|
|
goto out;
|
|
|
|
if (group_autogroup(cc))
|
|
|
|
goto out;
|
2016-10-03 17:42:34 +03:00
|
|
|
if (Conf.stickygroups)
|
2015-08-25 21:29:10 +03:00
|
|
|
group_assign(sc->group_active, cc);
|
|
|
|
else
|
|
|
|
group_assign(NULL, cc);
|
|
|
|
}
|
|
|
|
out:
|
2013-04-03 23:20:50 +04:00
|
|
|
XSync(X_Dpy, False);
|
|
|
|
XUngrabServer(X_Dpy);
|
|
|
|
|
2020-02-27 17:56:39 +03:00
|
|
|
return cc;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct client_ctx *
|
|
|
|
client_current(struct screen_ctx *sc)
|
|
|
|
{
|
|
|
|
struct screen_ctx *_sc;
|
|
|
|
struct client_ctx *cc;
|
2015-09-23 17:09:40 +03:00
|
|
|
|
2020-02-27 17:56:39 +03:00
|
|
|
if (sc) {
|
|
|
|
TAILQ_FOREACH(cc, &sc->clientq, entry) {
|
|
|
|
if (cc->flags & CLIENT_ACTIVE)
|
|
|
|
return cc;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
TAILQ_FOREACH(_sc, &Screenq, entry) {
|
|
|
|
TAILQ_FOREACH(cc, &_sc->clientq, entry) {
|
|
|
|
if (cc->flags & CLIENT_ACTIVE)
|
|
|
|
return cc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
|
2015-06-28 22:54:37 +03: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)
|
2020-02-27 17:56:39 +03:00
|
|
|
return cc;
|
2015-06-28 22:54:37 +03:00
|
|
|
}
|
|
|
|
}
|
2020-02-27 17:56:39 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct client_ctx *
|
|
|
|
client_next(struct client_ctx *cc)
|
|
|
|
{
|
|
|
|
struct screen_ctx *sc = cc->sc;
|
|
|
|
struct client_ctx *newcc;
|
|
|
|
|
|
|
|
return(((newcc = TAILQ_NEXT(cc, entry)) != NULL) ?
|
|
|
|
newcc : TAILQ_FIRST(&sc->clientq));
|
|
|
|
}
|
|
|
|
|
|
|
|
struct client_ctx *
|
|
|
|
client_prev(struct client_ctx *cc)
|
|
|
|
{
|
|
|
|
struct screen_ctx *sc = cc->sc;
|
|
|
|
struct client_ctx *newcc;
|
|
|
|
|
|
|
|
return(((newcc = TAILQ_PREV(cc, client_q, entry)) != NULL) ?
|
|
|
|
newcc : TAILQ_LAST(&sc->clientq, client_q));
|
2015-06-28 22:54:37 +03:00
|
|
|
}
|
|
|
|
|
2011-06-24 09:40:09 +04:00
|
|
|
void
|
2019-02-22 22:40:32 +03:00
|
|
|
client_remove(struct client_ctx *cc)
|
2007-04-27 21:58:48 +04:00
|
|
|
{
|
2009-08-27 05:38:08 +04:00
|
|
|
struct screen_ctx *sc = cc->sc;
|
2008-07-11 18:21:28 +04:00
|
|
|
struct winname *wn;
|
2007-04-27 21:58:48 +04:00
|
|
|
|
2014-09-09 00:11:22 +04:00
|
|
|
TAILQ_REMOVE(&sc->clientq, cc, entry);
|
2012-07-03 17:49:03 +04:00
|
|
|
|
|
|
|
xu_ewmh_net_client_list(sc);
|
2015-08-24 18:42:57 +03:00
|
|
|
xu_ewmh_net_client_list_stacking(sc);
|
2007-04-27 21:58:48 +04:00
|
|
|
|
2016-09-14 22:45:33 +03:00
|
|
|
if (cc->flags & CLIENT_ACTIVE)
|
2016-09-20 21:21:32 +03:00
|
|
|
xu_ewmh_net_active_window(sc, None);
|
2016-09-14 22:45:33 +03:00
|
|
|
|
2007-04-27 21:58:48 +04:00
|
|
|
while ((wn = TAILQ_FIRST(&cc->nameq)) != NULL) {
|
|
|
|
TAILQ_REMOVE(&cc->nameq, wn, entry);
|
2013-01-01 18:26:29 +04:00
|
|
|
free(wn->name);
|
2012-11-08 00:34:39 +04:00
|
|
|
free(wn);
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
|
2020-02-27 17:56:39 +03:00
|
|
|
free(cc->name);
|
|
|
|
free(cc->label);
|
|
|
|
free(cc->res_class);
|
|
|
|
free(cc->res_name);
|
2012-11-08 00:34:39 +04:00
|
|
|
free(cc);
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-02-27 17:56:39 +03:00
|
|
|
client_set_active(struct client_ctx *cc)
|
2007-04-27 21:58:48 +04:00
|
|
|
{
|
2013-11-27 04:01:23 +04:00
|
|
|
struct screen_ctx *sc = cc->sc;
|
|
|
|
struct client_ctx *oldcc;
|
2007-04-27 21:58:48 +04:00
|
|
|
|
2013-12-13 00:15:07 +04:00
|
|
|
if (cc->flags & CLIENT_HIDDEN)
|
|
|
|
return;
|
|
|
|
|
2013-11-27 04:01:23 +04:00
|
|
|
XInstallColormap(X_Dpy, cc->colormap);
|
2007-04-27 21:58:48 +04:00
|
|
|
|
2013-11-27 04:01:23 +04:00
|
|
|
if ((cc->flags & CLIENT_INPUT) ||
|
2014-09-15 17:00:49 +04:00
|
|
|
(!(cc->flags & CLIENT_WM_TAKE_FOCUS))) {
|
2013-11-27 04:01:23 +04:00
|
|
|
XSetInputFocus(X_Dpy, cc->win,
|
|
|
|
RevertToPointerRoot, CurrentTime);
|
|
|
|
}
|
|
|
|
if (cc->flags & CLIENT_WM_TAKE_FOCUS)
|
2020-02-27 17:56:39 +03:00
|
|
|
xu_send_clientmsg(cc->win, cwmh[WM_TAKE_FOCUS], Last_Event_Time);
|
2007-04-27 21:58:48 +04:00
|
|
|
|
2019-03-07 17:28:17 +03:00
|
|
|
if ((oldcc = client_current(sc)) != NULL) {
|
2014-09-11 00:30:38 +04:00
|
|
|
oldcc->flags &= ~CLIENT_ACTIVE;
|
2013-11-27 04:01:23 +04:00
|
|
|
client_draw_border(oldcc);
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
|
2017-12-23 00:21:44 +03:00
|
|
|
/* If we're in the middle of cycling, don't change the order. */
|
2013-11-27 04:01:23 +04:00
|
|
|
if (!sc->cycling)
|
|
|
|
client_mtf(cc);
|
|
|
|
|
2014-09-11 00:30:38 +04:00
|
|
|
cc->flags |= CLIENT_ACTIVE;
|
2013-12-13 19:56:44 +04:00
|
|
|
cc->flags &= ~CLIENT_URGENCY;
|
2007-04-27 21:58:48 +04:00
|
|
|
client_draw_border(cc);
|
2013-11-27 04:01:23 +04:00
|
|
|
conf_grab_mouse(cc->win);
|
|
|
|
xu_ewmh_net_active_window(sc, cc->win);
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
|
2011-05-07 21:15:37 +04:00
|
|
|
void
|
2014-09-17 22:41:44 +04:00
|
|
|
client_toggle_freeze(struct client_ctx *cc)
|
2011-05-07 21:15:37 +04:00
|
|
|
{
|
2015-08-24 17:57:19 +03:00
|
|
|
if (cc->flags & CLIENT_FULLSCREEN)
|
|
|
|
return;
|
|
|
|
|
2016-09-02 18:08:44 +03:00
|
|
|
cc->flags ^= CLIENT_FREEZE;
|
2015-08-21 19:30:02 +03:00
|
|
|
xu_ewmh_set_net_wm_state(cc);
|
2011-05-07 21:15:37 +04:00
|
|
|
}
|
|
|
|
|
2014-08-25 16:49:19 +04:00
|
|
|
void
|
2014-09-17 22:41:44 +04:00
|
|
|
client_toggle_hidden(struct client_ctx *cc)
|
2014-09-17 20:00:44 +04:00
|
|
|
{
|
2016-09-02 18:08:44 +03:00
|
|
|
cc->flags ^= CLIENT_HIDDEN;
|
2014-09-17 20:00:44 +04:00
|
|
|
xu_ewmh_set_net_wm_state(cc);
|
|
|
|
}
|
|
|
|
|
2017-12-19 17:30:53 +03: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 16:49:19 +04:00
|
|
|
void
|
2014-09-17 22:41:44 +04:00
|
|
|
client_toggle_sticky(struct client_ctx *cc)
|
2014-08-25 16:49:19 +04:00
|
|
|
{
|
2016-09-02 18:08:44 +03:00
|
|
|
cc->flags ^= CLIENT_STICKY;
|
2014-08-25 16:49:19 +04:00
|
|
|
xu_ewmh_set_net_wm_state(cc);
|
|
|
|
}
|
|
|
|
|
2013-12-16 23:02:17 +04:00
|
|
|
void
|
2014-09-17 22:41:44 +04:00
|
|
|
client_toggle_fullscreen(struct client_ctx *cc)
|
2013-12-16 23:02:17 +04:00
|
|
|
{
|
|
|
|
struct screen_ctx *sc = cc->sc;
|
2015-06-26 20:17:46 +03:00
|
|
|
struct geom area;
|
2013-12-16 23:02:17 +04:00
|
|
|
|
|
|
|
if ((cc->flags & CLIENT_FREEZE) &&
|
|
|
|
!(cc->flags & CLIENT_FULLSCREEN))
|
|
|
|
return;
|
|
|
|
|
2014-09-15 17:00:49 +04:00
|
|
|
if (cc->flags & CLIENT_FULLSCREEN) {
|
2016-09-01 21:38:52 +03:00
|
|
|
if (!(cc->flags & CLIENT_IGNORE))
|
|
|
|
cc->bwidth = Conf.bwidth;
|
2013-12-16 23:02:17 +04:00
|
|
|
cc->geom = cc->fullgeom;
|
|
|
|
cc->flags &= ~(CLIENT_FULLSCREEN | CLIENT_FREEZE);
|
|
|
|
goto resize;
|
|
|
|
}
|
|
|
|
|
|
|
|
cc->fullgeom = cc->geom;
|
|
|
|
|
2015-06-26 20:17:46 +03:00
|
|
|
area = screen_area(sc,
|
2013-12-16 23:02:17 +04:00
|
|
|
cc->geom.x + cc->geom.w / 2,
|
2020-02-27 17:56:39 +03:00
|
|
|
cc->geom.y + cc->geom.h / 2, 0);
|
2013-12-16 23:02:17 +04:00
|
|
|
|
|
|
|
cc->bwidth = 0;
|
2015-06-26 20:17:46 +03:00
|
|
|
cc->geom = area;
|
2013-12-16 23:02:17 +04:00
|
|
|
cc->flags |= (CLIENT_FULLSCREEN | CLIENT_FREEZE);
|
|
|
|
|
|
|
|
resize:
|
|
|
|
client_resize(cc, 0);
|
|
|
|
xu_ewmh_set_net_wm_state(cc);
|
Keep pointer within window on maximize/fullscreen toggle
Spawn a window, maximize it in any way, move the cursor to a window border
that is not on the screen's edge and unmaximize again: While the window
goes back the cursor stays at the screen's edge, i.e. focus is lost to the
underlaying window.
Moving, resizing, tiling or snapping windows in any way always moves the
cursor along iff needed, e.g. using MS-[hjkl] to move a small window from
the center to the edge keeps the cursor within window borders -- no matter
what you do with the keyboard, focus stays on that window.
Make CM-f, CM-m, CM-equal and CMS-equal (default bindings) for toggling
full-screen mode, maximization, vertical maximization and horizontal
maximization of the current window drag the cursor along if needed as well.
OK okan kmos dv
2021-04-22 13:02:55 +03:00
|
|
|
client_ptr_inbound(cc, 1);
|
2013-12-16 23:02:17 +04:00
|
|
|
}
|
|
|
|
|
2007-04-27 21:58:48 +04:00
|
|
|
void
|
2014-09-17 22:41:44 +04:00
|
|
|
client_toggle_maximize(struct client_ctx *cc)
|
2007-04-27 21:58:48 +04:00
|
|
|
{
|
2009-08-27 05:38:08 +04:00
|
|
|
struct screen_ctx *sc = cc->sc;
|
2015-06-26 20:17:46 +03:00
|
|
|
struct geom area;
|
2008-07-16 02:06:48 +04:00
|
|
|
|
2015-08-21 19:14:39 +03:00
|
|
|
if (cc->flags & CLIENT_FREEZE)
|
2011-05-07 21:15:37 +04:00
|
|
|
return;
|
|
|
|
|
2011-09-04 20:59:31 +04:00
|
|
|
if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_MAXIMIZED) {
|
2007-04-27 21:58:48 +04:00
|
|
|
cc->geom = cc->savegeom;
|
2013-12-16 23:02:17 +04:00
|
|
|
cc->flags &= ~CLIENT_MAXIMIZED;
|
2011-09-04 20:59:31 +04:00
|
|
|
goto resize;
|
|
|
|
}
|
|
|
|
|
2014-09-15 17:00:49 +04:00
|
|
|
if (!(cc->flags & CLIENT_VMAXIMIZED)) {
|
2012-07-13 21:01:04 +04:00
|
|
|
cc->savegeom.h = cc->geom.h;
|
2011-09-04 20:59:31 +04:00
|
|
|
cc->savegeom.y = cc->geom.y;
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
|
2014-09-15 17:00:49 +04:00
|
|
|
if (!(cc->flags & CLIENT_HMAXIMIZED)) {
|
2012-07-13 21:01:04 +04:00
|
|
|
cc->savegeom.w = cc->geom.w;
|
2011-09-04 20:59:31 +04:00
|
|
|
cc->savegeom.x = cc->geom.x;
|
|
|
|
}
|
|
|
|
|
2015-06-26 20:17:46 +03:00
|
|
|
area = screen_area(sc,
|
2012-07-16 05:36:30 +04:00
|
|
|
cc->geom.x + cc->geom.w / 2,
|
2020-02-27 17:56:39 +03:00
|
|
|
cc->geom.y + cc->geom.h / 2, 1);
|
2012-07-16 05:36:30 +04:00
|
|
|
|
2015-06-26 20:17:46 +03: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 20:59:31 +04:00
|
|
|
cc->flags |= CLIENT_MAXIMIZED;
|
|
|
|
|
|
|
|
resize:
|
2012-09-09 23:47:47 +04:00
|
|
|
client_resize(cc, 0);
|
2013-05-21 01:13:58 +04:00
|
|
|
xu_ewmh_set_net_wm_state(cc);
|
Keep pointer within window on maximize/fullscreen toggle
Spawn a window, maximize it in any way, move the cursor to a window border
that is not on the screen's edge and unmaximize again: While the window
goes back the cursor stays at the screen's edge, i.e. focus is lost to the
underlaying window.
Moving, resizing, tiling or snapping windows in any way always moves the
cursor along iff needed, e.g. using MS-[hjkl] to move a small window from
the center to the edge keeps the cursor within window borders -- no matter
what you do with the keyboard, focus stays on that window.
Make CM-f, CM-m, CM-equal and CMS-equal (default bindings) for toggling
full-screen mode, maximization, vertical maximization and horizontal
maximization of the current window drag the cursor along if needed as well.
OK okan kmos dv
2021-04-22 13:02:55 +03:00
|
|
|
client_ptr_inbound(cc, 1);
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
|
2008-07-16 02:12:09 +04:00
|
|
|
void
|
2014-09-17 22:41:44 +04:00
|
|
|
client_toggle_vmaximize(struct client_ctx *cc)
|
2008-07-16 02:12:09 +04:00
|
|
|
{
|
2009-08-27 05:38:08 +04:00
|
|
|
struct screen_ctx *sc = cc->sc;
|
2015-06-26 20:17:46 +03:00
|
|
|
struct geom area;
|
2008-07-16 02:12:09 +04:00
|
|
|
|
2015-08-21 19:14:39 +03:00
|
|
|
if (cc->flags & CLIENT_FREEZE)
|
2011-05-07 21:15:37 +04:00
|
|
|
return;
|
|
|
|
|
2008-07-16 02:12:09 +04:00
|
|
|
if (cc->flags & CLIENT_VMAXIMIZED) {
|
2011-06-24 10:01:47 +04:00
|
|
|
cc->geom.y = cc->savegeom.y;
|
2012-07-13 21:01:04 +04:00
|
|
|
cc->geom.h = cc->savegeom.h;
|
2011-06-24 10:01:47 +04:00
|
|
|
cc->flags &= ~CLIENT_VMAXIMIZED;
|
2011-09-04 20:59:31 +04:00
|
|
|
goto resize;
|
2008-07-16 02:12:09 +04:00
|
|
|
}
|
|
|
|
|
2011-09-04 20:59:31 +04:00
|
|
|
cc->savegeom.y = cc->geom.y;
|
2012-07-13 21:01:04 +04:00
|
|
|
cc->savegeom.h = cc->geom.h;
|
2011-09-04 20:59:31 +04:00
|
|
|
|
2015-06-26 20:17:46 +03:00
|
|
|
area = screen_area(sc,
|
2012-07-16 05:36:30 +04:00
|
|
|
cc->geom.x + cc->geom.w / 2,
|
2020-02-27 17:56:39 +03:00
|
|
|
cc->geom.y + cc->geom.h / 2, 1);
|
2012-07-16 05:36:30 +04:00
|
|
|
|
2015-06-26 20:17:46 +03:00
|
|
|
cc->geom.y = area.y;
|
|
|
|
cc->geom.h = area.h - (cc->bwidth * 2);
|
2011-09-04 20:59:31 +04:00
|
|
|
cc->flags |= CLIENT_VMAXIMIZED;
|
|
|
|
|
|
|
|
resize:
|
2012-09-09 23:47:47 +04:00
|
|
|
client_resize(cc, 0);
|
2013-05-21 01:13:58 +04:00
|
|
|
xu_ewmh_set_net_wm_state(cc);
|
Keep pointer within window on maximize/fullscreen toggle
Spawn a window, maximize it in any way, move the cursor to a window border
that is not on the screen's edge and unmaximize again: While the window
goes back the cursor stays at the screen's edge, i.e. focus is lost to the
underlaying window.
Moving, resizing, tiling or snapping windows in any way always moves the
cursor along iff needed, e.g. using MS-[hjkl] to move a small window from
the center to the edge keeps the cursor within window borders -- no matter
what you do with the keyboard, focus stays on that window.
Make CM-f, CM-m, CM-equal and CMS-equal (default bindings) for toggling
full-screen mode, maximization, vertical maximization and horizontal
maximization of the current window drag the cursor along if needed as well.
OK okan kmos dv
2021-04-22 13:02:55 +03:00
|
|
|
client_ptr_inbound(cc, 1);
|
2008-07-16 02:12:09 +04:00
|
|
|
}
|
|
|
|
|
2009-08-25 03:54:41 +04:00
|
|
|
void
|
2014-09-17 22:41:44 +04:00
|
|
|
client_toggle_hmaximize(struct client_ctx *cc)
|
2009-08-25 03:54:41 +04:00
|
|
|
{
|
2009-08-27 05:38:08 +04:00
|
|
|
struct screen_ctx *sc = cc->sc;
|
2015-06-26 20:17:46 +03:00
|
|
|
struct geom area;
|
2009-08-25 03:54:41 +04:00
|
|
|
|
2015-08-21 19:14:39 +03:00
|
|
|
if (cc->flags & CLIENT_FREEZE)
|
2011-05-07 21:15:37 +04:00
|
|
|
return;
|
|
|
|
|
2009-08-25 03:54:41 +04:00
|
|
|
if (cc->flags & CLIENT_HMAXIMIZED) {
|
2011-06-24 10:01:47 +04:00
|
|
|
cc->geom.x = cc->savegeom.x;
|
2012-07-13 21:01:04 +04:00
|
|
|
cc->geom.w = cc->savegeom.w;
|
2011-06-24 10:01:47 +04:00
|
|
|
cc->flags &= ~CLIENT_HMAXIMIZED;
|
2011-09-04 20:59:31 +04:00
|
|
|
goto resize;
|
2012-05-13 19:15:54 +04:00
|
|
|
}
|
2011-09-04 20:59:31 +04:00
|
|
|
|
|
|
|
cc->savegeom.x = cc->geom.x;
|
2012-07-13 21:01:04 +04:00
|
|
|
cc->savegeom.w = cc->geom.w;
|
2011-09-04 20:59:31 +04:00
|
|
|
|
2015-06-26 20:17:46 +03:00
|
|
|
area = screen_area(sc,
|
2012-07-16 05:36:30 +04:00
|
|
|
cc->geom.x + cc->geom.w / 2,
|
2020-02-27 17:56:39 +03:00
|
|
|
cc->geom.y + cc->geom.h / 2, 1);
|
2012-07-16 05:36:30 +04:00
|
|
|
|
2015-06-26 20:17:46 +03:00
|
|
|
cc->geom.x = area.x;
|
|
|
|
cc->geom.w = area.w - (cc->bwidth * 2);
|
2011-09-04 20:59:31 +04:00
|
|
|
cc->flags |= CLIENT_HMAXIMIZED;
|
|
|
|
|
|
|
|
resize:
|
2012-09-09 23:47:47 +04:00
|
|
|
client_resize(cc, 0);
|
2013-05-21 01:13:58 +04:00
|
|
|
xu_ewmh_set_net_wm_state(cc);
|
Keep pointer within window on maximize/fullscreen toggle
Spawn a window, maximize it in any way, move the cursor to a window border
that is not on the screen's edge and unmaximize again: While the window
goes back the cursor stays at the screen's edge, i.e. focus is lost to the
underlaying window.
Moving, resizing, tiling or snapping windows in any way always moves the
cursor along iff needed, e.g. using MS-[hjkl] to move a small window from
the center to the edge keeps the cursor within window borders -- no matter
what you do with the keyboard, focus stays on that window.
Make CM-f, CM-m, CM-equal and CMS-equal (default bindings) for toggling
full-screen mode, maximization, vertical maximization and horizontal
maximization of the current window drag the cursor along if needed as well.
OK okan kmos dv
2021-04-22 13:02:55 +03:00
|
|
|
client_ptr_inbound(cc, 1);
|
2009-08-25 03:54:41 +04:00
|
|
|
}
|
|
|
|
|
2007-04-27 21:58:48 +04:00
|
|
|
void
|
2012-09-09 23:47:47 +04:00
|
|
|
client_resize(struct client_ctx *cc, int reset)
|
2007-04-27 21:58:48 +04:00
|
|
|
{
|
2012-09-09 23:47:47 +04:00
|
|
|
if (reset) {
|
|
|
|
cc->flags &= ~CLIENT_MAXIMIZED;
|
2013-05-21 01:13:58 +04:00
|
|
|
xu_ewmh_set_net_wm_state(cc);
|
2012-09-09 23:47:47 +04:00
|
|
|
}
|
|
|
|
|
2013-11-11 16:51:15 +04:00
|
|
|
client_draw_border(cc);
|
|
|
|
|
2009-01-22 22:01:56 +03:00
|
|
|
XMoveResizeWindow(X_Dpy, cc->win, cc->geom.x,
|
2012-07-13 21:01:04 +04:00
|
|
|
cc->geom.y, cc->geom.w, cc->geom.h);
|
2016-12-07 00:00:13 +03: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-11 01:37:30 +04:00
|
|
|
client_config(cc);
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
client_move(struct client_ctx *cc)
|
|
|
|
{
|
2009-01-22 22:01:56 +03:00
|
|
|
XMoveWindow(X_Dpy, cc->win, cc->geom.x, cc->geom.y);
|
2013-06-11 01:37:30 +04:00
|
|
|
client_config(cc);
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
client_lower(struct client_ctx *cc)
|
|
|
|
{
|
2009-01-16 18:24:14 +03:00
|
|
|
XLowerWindow(X_Dpy, cc->win);
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
client_raise(struct client_ctx *cc)
|
|
|
|
{
|
2009-01-16 18:24:14 +03:00
|
|
|
XRaiseWindow(X_Dpy, cc->win);
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
|
2013-06-11 01:37:30 +04:00
|
|
|
void
|
|
|
|
client_config(struct client_ctx *cc)
|
|
|
|
{
|
|
|
|
XConfigureEvent cn;
|
|
|
|
|
2013-12-17 20:10:43 +04:00
|
|
|
(void)memset(&cn, 0, sizeof(cn));
|
2013-06-11 01:37:30 +04: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 15:54:55 +03:00
|
|
|
void
|
|
|
|
client_ptr_inbound(struct client_ctx *cc, int getpos)
|
|
|
|
{
|
|
|
|
if (getpos)
|
2020-02-27 17:56:39 +03:00
|
|
|
xu_ptr_get(cc->win, &cc->ptr.x, &cc->ptr.y);
|
2017-05-01 15:54:55 +03:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2020-02-27 17:56:39 +03:00
|
|
|
client_ptr_warp(cc);
|
2017-05-01 15:54:55 +03:00
|
|
|
}
|
|
|
|
|
2007-04-27 21:58:48 +04:00
|
|
|
void
|
2020-02-27 17:56:39 +03:00
|
|
|
client_ptr_warp(struct client_ctx *cc)
|
2007-04-27 21:58:48 +04:00
|
|
|
{
|
2020-02-27 17:56:39 +03:00
|
|
|
xu_ptr_set(cc->win, cc->ptr.x, cc->ptr.y);
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-02-27 17:56:39 +03:00
|
|
|
client_ptr_save(struct client_ctx *cc)
|
2007-04-27 21:58:48 +04:00
|
|
|
{
|
2008-07-11 18:21:28 +04:00
|
|
|
int x, y;
|
2007-04-27 21:58:48 +04:00
|
|
|
|
2020-02-27 17:56:39 +03:00
|
|
|
xu_ptr_get(cc->win, &x, &y);
|
2009-05-18 04:23:35 +04:00
|
|
|
if (client_inbound(cc, x, y)) {
|
2007-04-27 21:58:48 +04:00
|
|
|
cc->ptr.x = x;
|
|
|
|
cc->ptr.y = y;
|
2011-02-13 23:09:57 +03:00
|
|
|
} else {
|
2016-09-30 23:55:54 +03:00
|
|
|
cc->ptr.x = cc->geom.w / 2;
|
|
|
|
cc->ptr.y = cc->geom.h / 2;
|
2008-04-16 00:24:41 +04:00
|
|
|
}
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
client_hide(struct client_ctx *cc)
|
|
|
|
{
|
2009-01-16 18:24:14 +03:00
|
|
|
XUnmapWindow(X_Dpy, cc->win);
|
2007-04-27 21:58:48 +04:00
|
|
|
|
2019-02-28 16:11:53 +03:00
|
|
|
if (cc->flags & CLIENT_ACTIVE) {
|
|
|
|
cc->flags &= ~CLIENT_ACTIVE;
|
2016-09-20 21:21:32 +03:00
|
|
|
xu_ewmh_net_active_window(cc->sc, None);
|
2019-02-28 16:11:53 +03:00
|
|
|
}
|
2007-04-27 21:58:48 +04:00
|
|
|
cc->flags |= CLIENT_HIDDEN;
|
2020-02-27 17:56:39 +03:00
|
|
|
xu_set_wm_state(cc->win, IconicState);
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
|
2017-12-29 15:54:54 +03:00
|
|
|
void
|
|
|
|
client_show(struct client_ctx *cc)
|
2007-04-27 21:58:48 +04:00
|
|
|
{
|
2009-01-16 18:24:14 +03:00
|
|
|
XMapRaised(X_Dpy, cc->win);
|
2007-04-27 21:58:48 +04:00
|
|
|
|
|
|
|
cc->flags &= ~CLIENT_HIDDEN;
|
2020-02-27 17:56:39 +03:00
|
|
|
xu_set_wm_state(cc->win, NormalState);
|
2013-12-11 01:27:37 +04:00
|
|
|
client_draw_border(cc);
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
|
2013-12-13 19:56:44 +04:00
|
|
|
void
|
|
|
|
client_urgency(struct client_ctx *cc)
|
|
|
|
{
|
2014-09-11 00:30:38 +04:00
|
|
|
if (!(cc->flags & CLIENT_ACTIVE))
|
2014-02-07 00:58:46 +04:00
|
|
|
cc->flags |= CLIENT_URGENCY;
|
2013-12-13 19:56:44 +04:00
|
|
|
}
|
|
|
|
|
2007-04-27 21:58:48 +04:00
|
|
|
void
|
|
|
|
client_draw_border(struct client_ctx *cc)
|
|
|
|
{
|
2009-08-27 05:38:08 +04:00
|
|
|
struct screen_ctx *sc = cc->sc;
|
2009-05-18 03:40:57 +04:00
|
|
|
unsigned long pixel;
|
2007-04-27 21:58:48 +04:00
|
|
|
|
2014-09-11 00:30:38 +04:00
|
|
|
if (cc->flags & CLIENT_ACTIVE)
|
2012-12-17 21:48:57 +04:00
|
|
|
switch (cc->flags & CLIENT_HIGHLIGHT) {
|
|
|
|
case CLIENT_GROUP:
|
2013-05-20 03:09:59 +04:00
|
|
|
pixel = sc->xftcolor[CWM_COLOR_BORDER_GROUP].pixel;
|
2009-01-16 18:24:14 +03:00
|
|
|
break;
|
2012-12-17 21:48:57 +04:00
|
|
|
case CLIENT_UNGROUP:
|
2013-05-20 03:09:59 +04:00
|
|
|
pixel = sc->xftcolor[CWM_COLOR_BORDER_UNGROUP].pixel;
|
2009-01-16 18:24:14 +03:00
|
|
|
break;
|
|
|
|
default:
|
2013-05-20 03:09:59 +04:00
|
|
|
pixel = sc->xftcolor[CWM_COLOR_BORDER_ACTIVE].pixel;
|
2009-01-16 18:24:14 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
2013-05-20 03:09:59 +04:00
|
|
|
pixel = sc->xftcolor[CWM_COLOR_BORDER_INACTIVE].pixel;
|
2009-01-22 22:01:56 +03:00
|
|
|
|
2013-12-13 19:56:44 +04:00
|
|
|
if (cc->flags & CLIENT_URGENCY)
|
|
|
|
pixel = sc->xftcolor[CWM_COLOR_BORDER_URGENCY].pixel;
|
|
|
|
|
2017-04-27 00:10:54 +03:00
|
|
|
XSetWindowBorderWidth(X_Dpy, cc->win, (unsigned int)cc->bwidth);
|
2009-05-18 03:40:57 +04:00
|
|
|
XSetWindowBorder(X_Dpy, cc->win, pixel);
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
|
2020-02-27 17:56:39 +03:00
|
|
|
static void
|
|
|
|
client_class_hint(struct client_ctx *cc)
|
|
|
|
{
|
|
|
|
XClassHint ch;
|
|
|
|
|
|
|
|
if (XGetClassHint(X_Dpy, cc->win, &ch)) {
|
|
|
|
if (ch.res_class) {
|
|
|
|
cc->res_class = xstrdup(ch.res_class);
|
|
|
|
XFree(ch.res_class);
|
|
|
|
}
|
|
|
|
if (ch.res_name) {
|
|
|
|
cc->res_name = xstrdup(ch.res_name);
|
|
|
|
XFree(ch.res_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-26 16:21:58 +04:00
|
|
|
static void
|
2013-05-19 21:02:04 +04:00
|
|
|
client_wm_protocols(struct client_ctx *cc)
|
2007-04-27 21:58:48 +04:00
|
|
|
{
|
2009-11-28 20:52:12 +03:00
|
|
|
Atom *p;
|
2013-05-19 21:02:04 +04:00
|
|
|
int i, j;
|
|
|
|
|
|
|
|
if (XGetWMProtocols(X_Dpy, cc->win, &p, &j)) {
|
|
|
|
for (i = 0; i < j; i++) {
|
2013-07-15 18:50:44 +04:00
|
|
|
if (p[i] == cwmh[WM_DELETE_WINDOW])
|
2013-11-08 21:35:12 +04:00
|
|
|
cc->flags |= CLIENT_WM_DELETE_WINDOW;
|
2013-07-15 18:50:44 +04:00
|
|
|
else if (p[i] == cwmh[WM_TAKE_FOCUS])
|
2013-11-08 21:35:12 +04:00
|
|
|
cc->flags |= CLIENT_WM_TAKE_FOCUS;
|
2013-05-19 21:02:04 +04:00
|
|
|
}
|
|
|
|
XFree(p);
|
|
|
|
}
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
|
2013-12-11 19:41:11 +04:00
|
|
|
void
|
|
|
|
client_wm_hints(struct client_ctx *cc)
|
|
|
|
{
|
2020-02-27 17:56:39 +03:00
|
|
|
XWMHints *wmh;
|
|
|
|
|
|
|
|
if ((wmh = XGetWMHints(X_Dpy, cc->win)) != NULL) {
|
|
|
|
if ((wmh->flags & InputHint) && (wmh->input))
|
|
|
|
cc->flags |= CLIENT_INPUT;
|
|
|
|
if ((wmh->flags & XUrgencyHint))
|
|
|
|
client_urgency(cc);
|
|
|
|
if ((wmh->flags & StateHint))
|
|
|
|
cc->initial_state = wmh->initial_state;
|
|
|
|
XFree(wmh);
|
|
|
|
}
|
2013-06-11 01:37:30 +04:00
|
|
|
}
|
|
|
|
|
2007-04-27 21:58:48 +04:00
|
|
|
void
|
2019-02-22 22:40:32 +03:00
|
|
|
client_close(struct client_ctx *cc)
|
2007-04-27 21:58:48 +04:00
|
|
|
{
|
2013-11-08 21:35:12 +04:00
|
|
|
if (cc->flags & CLIENT_WM_DELETE_WINDOW)
|
2020-02-27 17:56:39 +03:00
|
|
|
xu_send_clientmsg(cc->win, cwmh[WM_DELETE_WINDOW], CurrentTime);
|
2007-04-27 21:58:48 +04:00
|
|
|
else
|
2007-05-28 22:34:27 +04:00
|
|
|
XKillClient(X_Dpy, cc->win);
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-02-27 17:56:39 +03:00
|
|
|
client_set_name(struct client_ctx *cc)
|
2007-04-27 21:58:48 +04:00
|
|
|
{
|
2020-03-16 20:50:44 +03:00
|
|
|
struct winname *wn, *wnnxt;
|
2016-10-04 18:52:32 +03:00
|
|
|
int i = 0;
|
2007-04-27 21:58:48 +04:00
|
|
|
|
2020-03-16 20:50:44 +03:00
|
|
|
free(cc->name);
|
|
|
|
if (!xu_get_strprop(cc->win, ewmh[_NET_WM_NAME], &cc->name))
|
|
|
|
if (!xu_get_strprop(cc->win, XA_WM_NAME, &cc->name))
|
|
|
|
cc->name = xstrdup("");
|
2007-04-27 21:58:48 +04:00
|
|
|
|
2020-03-16 20:50:44 +03:00
|
|
|
TAILQ_FOREACH_SAFE(wn, &cc->nameq, entry, wnnxt) {
|
|
|
|
if (strcmp(wn->name, cc->name) == 0) {
|
2007-04-27 21:58:48 +04:00
|
|
|
TAILQ_REMOVE(&cc->nameq, wn, entry);
|
2020-03-16 20:50:44 +03:00
|
|
|
free(wn->name);
|
|
|
|
free(wn);
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
2020-02-27 17:56:39 +03:00
|
|
|
i++;
|
2014-09-09 00:37:02 +04:00
|
|
|
}
|
2009-06-20 04:22:39 +04:00
|
|
|
wn = xmalloc(sizeof(*wn));
|
2020-03-16 20:50:44 +03:00
|
|
|
wn->name = xstrdup(cc->name);
|
2007-04-27 21:58:48 +04:00
|
|
|
TAILQ_INSERT_TAIL(&cc->nameq, wn, entry);
|
|
|
|
|
2020-02-27 17:56:39 +03:00
|
|
|
/* Garbage collection. */
|
|
|
|
if ((i + 1) > Conf.nameqlen) {
|
2016-10-04 18:52:32 +03:00
|
|
|
wn = TAILQ_FIRST(&cc->nameq);
|
2007-04-27 21:58:48 +04:00
|
|
|
TAILQ_REMOVE(&cc->nameq, wn, entry);
|
2013-01-01 18:26:29 +04:00
|
|
|
free(wn->name);
|
2012-11-08 00:34:39 +04:00
|
|
|
free(wn);
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-26 16:21:58 +04:00
|
|
|
static void
|
2020-02-27 17:56:39 +03:00
|
|
|
client_placement(struct client_ctx *cc)
|
2007-04-27 21:58:48 +04:00
|
|
|
{
|
2009-08-27 05:38:08 +04:00
|
|
|
struct screen_ctx *sc = cc->sc;
|
2007-04-27 21:58:48 +04:00
|
|
|
|
2015-08-21 19:52:37 +03:00
|
|
|
if (cc->hint.flags & (USPosition | PPosition)) {
|
2018-02-06 18:05:20 +03:00
|
|
|
if (cc->geom.x >= sc->view.w)
|
|
|
|
cc->geom.x = sc->view.w - cc->bwidth - 1;
|
2017-05-05 17:14:19 +03:00
|
|
|
if (cc->geom.x + cc->geom.w + cc->bwidth <= 0)
|
|
|
|
cc->geom.x = -(cc->geom.w + cc->bwidth - 1);
|
2018-02-06 18:05:20 +03:00
|
|
|
if (cc->geom.y >= sc->view.h)
|
|
|
|
cc->geom.x = sc->view.h - cc->bwidth - 1;
|
2017-05-05 17:14:19 +03:00
|
|
|
if (cc->geom.y + cc->geom.h + cc->bwidth <= 0)
|
|
|
|
cc->geom.y = -(cc->geom.h + cc->bwidth - 1);
|
2018-11-08 18:49:42 +03: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 21:58:48 +04:00
|
|
|
} else {
|
2019-02-23 22:17:17 +03:00
|
|
|
struct geom area;
|
|
|
|
int xmouse, ymouse, xslack, yslack;
|
2008-09-30 03:16:46 +04:00
|
|
|
|
2020-02-27 17:56:39 +03:00
|
|
|
xu_ptr_get(sc->rootwin, &xmouse, &ymouse);
|
|
|
|
area = screen_area(sc, xmouse, ymouse, 1);
|
2009-01-22 22:01:56 +03:00
|
|
|
|
2019-02-23 22:17:17 +03:00
|
|
|
xmouse = MAX(MAX(xmouse, area.x) - cc->geom.w / 2, area.x);
|
|
|
|
ymouse = MAX(MAX(ymouse, area.y) - cc->geom.h / 2, area.y);
|
2008-09-30 03:16:46 +04:00
|
|
|
|
2019-02-23 22:17:17 +03:00
|
|
|
xslack = area.x + area.w - cc->geom.w - cc->bwidth * 2;
|
|
|
|
yslack = area.y + area.h - cc->geom.h - cc->bwidth * 2;
|
2008-09-30 03:16:46 +04:00
|
|
|
|
2015-06-26 20:17:46 +03:00
|
|
|
if (xslack >= area.x) {
|
|
|
|
cc->geom.x = MAX(MIN(xmouse, xslack), area.x);
|
2007-04-27 21:58:48 +04:00
|
|
|
} else {
|
2015-06-26 20:17:46 +03:00
|
|
|
cc->geom.x = area.x;
|
2019-02-23 22:17:17 +03:00
|
|
|
cc->geom.w = area.x + area.w;
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
2015-06-26 20:17:46 +03:00
|
|
|
if (yslack >= area.y) {
|
|
|
|
cc->geom.y = MAX(MIN(ymouse, yslack), area.y);
|
2007-04-27 21:58:48 +04:00
|
|
|
} else {
|
2015-06-26 20:17:46 +03:00
|
|
|
cc->geom.y = area.y;
|
2019-02-23 22:17:17 +03:00
|
|
|
cc->geom.h = area.y + area.h;
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-29 21:50:43 +03:00
|
|
|
void
|
2007-04-27 21:58:48 +04:00
|
|
|
client_mtf(struct client_ctx *cc)
|
|
|
|
{
|
2013-11-27 04:01:23 +04:00
|
|
|
struct screen_ctx *sc = cc->sc;
|
2007-04-27 21:58:48 +04:00
|
|
|
|
2014-09-09 00:11:22 +04:00
|
|
|
TAILQ_REMOVE(&sc->clientq, cc, entry);
|
|
|
|
TAILQ_INSERT_HEAD(&sc->clientq, cc, entry);
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
|
2009-08-25 03:49:04 +04:00
|
|
|
void
|
2020-02-27 17:56:39 +03:00
|
|
|
client_get_sizehints(struct client_ctx *cc)
|
2009-08-25 03:49:04 +04:00
|
|
|
{
|
|
|
|
long tmp;
|
2013-11-27 21:04:35 +04:00
|
|
|
XSizeHints size;
|
2009-08-25 03:49:04 +04:00
|
|
|
|
2013-11-27 21:04:35 +04:00
|
|
|
if (!XGetWMNormalHints(X_Dpy, cc->win, &size, &tmp))
|
|
|
|
size.flags = 0;
|
2009-08-25 03:49:04 +04:00
|
|
|
|
2013-11-27 21:04:35 +04:00
|
|
|
cc->hint.flags = size.flags;
|
2013-11-02 23:13:56 +04:00
|
|
|
|
2013-11-27 21:04:35 +04: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-25 03:49:04 +04:00
|
|
|
}
|
2013-11-27 21:04:35 +04: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-25 03:49:04 +04:00
|
|
|
}
|
2013-11-27 21:04:35 +04:00
|
|
|
if (size.flags & PMaxSize) {
|
|
|
|
cc->hint.maxw = size.max_width;
|
|
|
|
cc->hint.maxh = size.max_height;
|
2009-08-25 03:49:04 +04:00
|
|
|
}
|
2013-11-27 21:04:35 +04:00
|
|
|
if (size.flags & PResizeInc) {
|
|
|
|
cc->hint.incw = size.width_inc;
|
|
|
|
cc->hint.inch = size.height_inc;
|
2009-08-25 03:49:04 +04:00
|
|
|
}
|
2011-09-03 13:42:33 +04:00
|
|
|
cc->hint.incw = MAX(1, cc->hint.incw);
|
|
|
|
cc->hint.inch = MAX(1, cc->hint.inch);
|
2015-11-12 21:33:30 +03:00
|
|
|
cc->hint.minw = MAX(1, cc->hint.minw);
|
|
|
|
cc->hint.minh = MAX(1, cc->hint.minh);
|
2009-08-25 05:32:40 +04:00
|
|
|
|
2013-11-27 21:04:35 +04: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-25 03:49:04 +04:00
|
|
|
}
|
|
|
|
}
|
2012-05-13 19:15:54 +04:00
|
|
|
|
2009-08-25 03:49:04 +04:00
|
|
|
void
|
2020-02-27 17:56:39 +03:00
|
|
|
client_apply_sizehints(struct client_ctx *cc)
|
2009-08-25 03:49:04 +04:00
|
|
|
{
|
|
|
|
Bool baseismin;
|
|
|
|
|
2011-09-03 13:42:33 +04:00
|
|
|
baseismin = (cc->hint.basew == cc->hint.minw) &&
|
|
|
|
(cc->hint.baseh == cc->hint.minh);
|
2009-08-25 03:49:04 +04:00
|
|
|
|
|
|
|
/* temporarily remove base dimensions, ICCCM 4.1.2.3 */
|
|
|
|
if (!baseismin) {
|
2012-07-13 21:01:04 +04:00
|
|
|
cc->geom.w -= cc->hint.basew;
|
|
|
|
cc->geom.h -= cc->hint.baseh;
|
2009-08-25 03:49:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* adjust for aspect limits */
|
2013-11-27 18:20:32 +04:00
|
|
|
if (cc->hint.mina && cc->hint.maxa) {
|
|
|
|
if (cc->hint.maxa < (float)cc->geom.w / cc->geom.h)
|
2012-07-13 21:01:04 +04:00
|
|
|
cc->geom.w = cc->geom.h * cc->hint.maxa;
|
2013-11-27 18:20:32 +04:00
|
|
|
else if (cc->hint.mina < (float)cc->geom.h / cc->geom.w)
|
2012-07-13 21:01:04 +04:00
|
|
|
cc->geom.h = cc->geom.w * cc->hint.mina;
|
2009-08-25 03:49:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* remove base dimensions for increment */
|
|
|
|
if (baseismin) {
|
2012-07-13 21:01:04 +04:00
|
|
|
cc->geom.w -= cc->hint.basew;
|
|
|
|
cc->geom.h -= cc->hint.baseh;
|
2009-08-25 03:49:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* adjust for increment value */
|
2012-07-13 21:01:04 +04:00
|
|
|
cc->geom.w -= cc->geom.w % cc->hint.incw;
|
|
|
|
cc->geom.h -= cc->geom.h % cc->hint.inch;
|
2009-08-25 03:49:04 +04:00
|
|
|
|
|
|
|
/* restore base dimensions */
|
2012-07-13 21:01:04 +04:00
|
|
|
cc->geom.w += cc->hint.basew;
|
|
|
|
cc->geom.h += cc->hint.baseh;
|
2009-08-25 03:49:04 +04:00
|
|
|
|
|
|
|
/* adjust for min width/height */
|
2012-07-13 21:01:04 +04:00
|
|
|
cc->geom.w = MAX(cc->geom.w, cc->hint.minw);
|
|
|
|
cc->geom.h = MAX(cc->geom.h, cc->hint.minh);
|
2009-08-25 03:49:04 +04:00
|
|
|
|
|
|
|
/* adjust for max width/height */
|
2011-09-03 13:42:33 +04:00
|
|
|
if (cc->hint.maxw)
|
2012-07-13 21:01:04 +04:00
|
|
|
cc->geom.w = MIN(cc->geom.w, cc->hint.maxw);
|
2011-09-03 13:42:33 +04:00
|
|
|
if (cc->hint.maxh)
|
2012-07-13 21:01:04 +04:00
|
|
|
cc->geom.h = MIN(cc->geom.h, cc->hint.maxh);
|
2009-08-25 03:49:04 +04:00
|
|
|
}
|
|
|
|
|
2009-06-26 16:21:58 +04:00
|
|
|
static void
|
2013-12-11 19:46:47 +04:00
|
|
|
client_mwm_hints(struct client_ctx *cc)
|
2007-04-27 21:58:48 +04:00
|
|
|
{
|
2008-07-11 18:21:28 +04:00
|
|
|
struct mwm_hints *mwmh;
|
2007-04-27 21:58:48 +04:00
|
|
|
|
2020-02-27 17:56:39 +03:00
|
|
|
if (xu_get_prop(cc->win, cwmh[_MOTIF_WM_HINTS],
|
2017-12-23 00:21:44 +03:00
|
|
|
cwmh[_MOTIF_WM_HINTS], MWM_HINTS_ELEMENTS,
|
|
|
|
(unsigned char **)&mwmh) == MWM_HINTS_ELEMENTS) {
|
2015-05-21 02:54:39 +03:00
|
|
|
if (mwmh->flags & MWM_FLAGS_DECORATIONS &&
|
2007-04-27 21:58:48 +04:00
|
|
|
!(mwmh->decorations & MWM_DECOR_ALL) &&
|
|
|
|
!(mwmh->decorations & MWM_DECOR_BORDER))
|
|
|
|
cc->bwidth = 0;
|
2015-03-29 03:21:05 +03:00
|
|
|
XFree(mwmh);
|
2014-09-09 00:37:02 +04:00
|
|
|
}
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
|
|
|
|
2011-09-13 12:41:57 +04:00
|
|
|
void
|
|
|
|
client_transient(struct client_ctx *cc)
|
|
|
|
{
|
|
|
|
struct client_ctx *tc;
|
|
|
|
Window trans;
|
|
|
|
|
|
|
|
if (XGetTransientForHint(X_Dpy, cc->win, &trans)) {
|
2018-11-13 20:37:13 +03:00
|
|
|
if ((tc = client_find(trans)) != NULL) {
|
|
|
|
if (tc->flags & CLIENT_IGNORE) {
|
2011-09-13 12:41:57 +04:00
|
|
|
cc->flags |= CLIENT_IGNORE;
|
2018-11-13 20:37:13 +03:00
|
|
|
cc->bwidth = tc->bwidth;
|
|
|
|
}
|
2011-09-13 12:41:57 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-20 22:11:19 +03:00
|
|
|
int
|
2009-05-18 04:23:35 +04:00
|
|
|
client_inbound(struct client_ctx *cc, int x, int y)
|
2007-04-27 21:58:48 +04:00
|
|
|
{
|
2014-09-07 23:27:30 +04:00
|
|
|
return(x < cc->geom.w && x >= 0 &&
|
2012-07-13 21:01:04 +04:00
|
|
|
y < cc->geom.h && y >= 0);
|
2007-04-27 21:58:48 +04:00
|
|
|
}
|
2011-06-24 10:06:24 +04:00
|
|
|
|
|
|
|
int
|
2013-01-03 01:37:21 +04:00
|
|
|
client_snapcalc(int n0, int n1, int e0, int e1, int snapdist)
|
2011-06-24 10:06:24 +04:00
|
|
|
{
|
2013-01-03 01:37:21 +04:00
|
|
|
int s0, s1;
|
2011-06-24 10:06:24 +04:00
|
|
|
|
|
|
|
s0 = s1 = 0;
|
|
|
|
|
2013-01-03 01:37:21 +04:00
|
|
|
if (abs(e0 - n0) <= snapdist)
|
|
|
|
s0 = e0 - n0;
|
2011-06-24 10:06:24 +04:00
|
|
|
|
2013-01-03 01:37:21 +04:00
|
|
|
if (abs(e1 - n1) <= snapdist)
|
|
|
|
s1 = e1 - n1;
|
2011-06-24 10:06:24 +04:00
|
|
|
|
|
|
|
/* possible to snap in both directions */
|
|
|
|
if (s0 != 0 && s1 != 0)
|
|
|
|
if (abs(s0) < abs(s1))
|
2020-02-27 17:56:39 +03:00
|
|
|
return s0;
|
2011-06-24 10:06:24 +04:00
|
|
|
else
|
2020-02-27 17:56:39 +03:00
|
|
|
return s1;
|
2011-06-24 10:06:24 +04:00
|
|
|
else if (s0 != 0)
|
2020-02-27 17:56:39 +03:00
|
|
|
return s0;
|
2011-06-24 10:06:24 +04:00
|
|
|
else if (s1 != 0)
|
2020-02-27 17:56:39 +03:00
|
|
|
return s1;
|
2011-06-24 10:06:24 +04:00
|
|
|
else
|
2020-02-27 17:56:39 +03:00
|
|
|
return 0;
|
2011-06-24 10:06:24 +04:00
|
|
|
}
|
2013-01-08 19:16:04 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
client_htile(struct client_ctx *cc)
|
|
|
|
{
|
|
|
|
struct client_ctx *ci;
|
|
|
|
struct screen_ctx *sc = cc->sc;
|
2015-06-26 20:17:46 +03:00
|
|
|
struct geom area;
|
2017-04-24 16:31:19 +03:00
|
|
|
int i, n, mh, x, w, h;
|
2013-01-08 19:16:04 +04:00
|
|
|
|
|
|
|
i = n = 0;
|
2019-02-22 17:39:18 +03:00
|
|
|
area = screen_area(sc,
|
|
|
|
cc->geom.x + cc->geom.w / 2,
|
2020-02-27 17:56:39 +03:00
|
|
|
cc->geom.y + cc->geom.h / 2, 1);
|
2019-02-22 17:39:18 +03:00
|
|
|
|
2019-03-07 16:14:41 +03:00
|
|
|
TAILQ_FOREACH(ci, &sc->clientq, entry) {
|
|
|
|
if (ci->gc != cc->gc)
|
|
|
|
continue;
|
2013-01-08 19:16:04 +04:00
|
|
|
if (ci->flags & CLIENT_HIDDEN ||
|
2019-02-22 17:39:18 +03: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 19:16:04 +04:00
|
|
|
continue;
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
if (n == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (cc->flags & CLIENT_VMAXIMIZED ||
|
2015-06-26 20:17:46 +03:00
|
|
|
cc->geom.h + (cc->bwidth * 2) >= area.h)
|
2013-01-08 19:16:04 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
cc->flags &= ~CLIENT_HMAXIMIZED;
|
2015-06-26 20:17:46 +03:00
|
|
|
cc->geom.x = area.x;
|
|
|
|
cc->geom.y = area.y;
|
|
|
|
cc->geom.w = area.w - (cc->bwidth * 2);
|
2020-04-16 16:32:35 +03:00
|
|
|
if (Conf.htile > 0)
|
|
|
|
cc->geom.h = ((area.h - (cc->bwidth * 2)) * Conf.htile) / 100;
|
2013-01-08 19:16:04 +04:00
|
|
|
client_resize(cc, 1);
|
2020-02-27 17:56:39 +03:00
|
|
|
client_ptr_warp(cc);
|
2013-01-08 19:16:04 +04:00
|
|
|
|
|
|
|
mh = cc->geom.h + (cc->bwidth * 2);
|
2015-06-26 20:17:46 +03:00
|
|
|
x = area.x;
|
|
|
|
w = area.w / n;
|
|
|
|
h = area.h - mh;
|
2019-03-07 16:14:41 +03:00
|
|
|
TAILQ_FOREACH(ci, &sc->clientq, entry) {
|
|
|
|
if (ci->gc != cc->gc)
|
|
|
|
continue;
|
2013-01-08 19:16:04 +04:00
|
|
|
if (ci->flags & CLIENT_HIDDEN ||
|
2019-02-22 17:39:18 +03: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 19:16:04 +04:00
|
|
|
continue;
|
|
|
|
ci->bwidth = Conf.bwidth;
|
|
|
|
ci->geom.x = x;
|
2017-04-24 16:31:19 +03:00
|
|
|
ci->geom.y = area.y + mh;
|
2013-01-08 19:16:04 +04:00
|
|
|
ci->geom.w = w - (ci->bwidth * 2);
|
2017-04-24 16:31:19 +03:00
|
|
|
ci->geom.h = h - (ci->bwidth * 2);
|
2013-01-08 19:16:04 +04:00
|
|
|
if (i + 1 == n)
|
2015-06-26 20:17:46 +03:00
|
|
|
ci->geom.w = area.x + area.w -
|
2013-01-08 19:16:04 +04:00
|
|
|
ci->geom.x - (ci->bwidth * 2);
|
|
|
|
x += w;
|
|
|
|
i++;
|
2017-04-24 16:31:19 +03:00
|
|
|
client_resize(ci, 1);
|
2013-01-08 19:16:04 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
client_vtile(struct client_ctx *cc)
|
|
|
|
{
|
|
|
|
struct client_ctx *ci;
|
|
|
|
struct screen_ctx *sc = cc->sc;
|
2015-06-26 20:17:46 +03:00
|
|
|
struct geom area;
|
2017-04-24 16:31:19 +03:00
|
|
|
int i, n, mw, y, w, h;
|
2013-01-08 19:16:04 +04:00
|
|
|
|
|
|
|
i = n = 0;
|
2019-02-22 17:39:18 +03:00
|
|
|
area = screen_area(sc,
|
|
|
|
cc->geom.x + cc->geom.w / 2,
|
2020-02-27 17:56:39 +03:00
|
|
|
cc->geom.y + cc->geom.h / 2, 1);
|
2019-02-22 17:39:18 +03:00
|
|
|
|
2019-03-07 16:14:41 +03:00
|
|
|
TAILQ_FOREACH(ci, &sc->clientq, entry) {
|
|
|
|
if (ci->gc != cc->gc)
|
|
|
|
continue;
|
2013-01-08 19:16:04 +04:00
|
|
|
if (ci->flags & CLIENT_HIDDEN ||
|
2019-02-22 17:39:18 +03: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 19:16:04 +04:00
|
|
|
continue;
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
if (n == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (cc->flags & CLIENT_HMAXIMIZED ||
|
2015-06-26 20:17:46 +03:00
|
|
|
cc->geom.w + (cc->bwidth * 2) >= area.w)
|
2013-01-08 19:16:04 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
cc->flags &= ~CLIENT_VMAXIMIZED;
|
2015-06-26 20:17:46 +03:00
|
|
|
cc->geom.x = area.x;
|
|
|
|
cc->geom.y = area.y;
|
2020-04-16 16:32:35 +03:00
|
|
|
if (Conf.vtile > 0)
|
|
|
|
cc->geom.w = ((area.w - (cc->bwidth * 2)) * Conf.vtile) / 100;
|
2015-06-26 20:17:46 +03:00
|
|
|
cc->geom.h = area.h - (cc->bwidth * 2);
|
2013-01-08 19:16:04 +04:00
|
|
|
client_resize(cc, 1);
|
2020-02-27 17:56:39 +03:00
|
|
|
client_ptr_warp(cc);
|
2013-01-08 19:16:04 +04:00
|
|
|
|
|
|
|
mw = cc->geom.w + (cc->bwidth * 2);
|
2015-06-26 20:17:46 +03:00
|
|
|
y = area.y;
|
|
|
|
h = area.h / n;
|
|
|
|
w = area.w - mw;
|
2019-03-07 16:14:41 +03:00
|
|
|
TAILQ_FOREACH(ci, &sc->clientq, entry) {
|
|
|
|
if (ci->gc != cc->gc)
|
|
|
|
continue;
|
2013-01-08 19:16:04 +04:00
|
|
|
if (ci->flags & CLIENT_HIDDEN ||
|
2019-02-22 17:39:18 +03: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 19:16:04 +04:00
|
|
|
continue;
|
|
|
|
ci->bwidth = Conf.bwidth;
|
2015-06-26 20:17:46 +03:00
|
|
|
ci->geom.x = area.x + mw;
|
2017-04-24 16:31:19 +03:00
|
|
|
ci->geom.y = y;
|
2013-01-08 19:16:04 +04:00
|
|
|
ci->geom.w = w - (ci->bwidth * 2);
|
2017-04-24 16:31:19 +03:00
|
|
|
ci->geom.h = h - (ci->bwidth * 2);
|
2013-01-08 19:16:04 +04:00
|
|
|
if (i + 1 == n)
|
2015-06-26 20:17:46 +03:00
|
|
|
ci->geom.h = area.y + area.h -
|
2013-01-08 19:16:04 +04:00
|
|
|
ci->geom.y - (ci->bwidth * 2);
|
|
|
|
y += h;
|
|
|
|
i++;
|
2017-04-24 16:31:19 +03:00
|
|
|
client_resize(ci, 1);
|
2013-01-08 19:16:04 +04:00
|
|
|
}
|
|
|
|
}
|