2009-07-28 21:44:22 +00:00
|
|
|
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
|
|
|
*
|
|
|
|
* Conky, a system monitor, based on torsmo
|
2005-08-05 01:06:17 +00:00
|
|
|
*
|
2007-08-10 19:53:44 +00:00
|
|
|
* Any original torsmo code is licensed under the BSD license
|
|
|
|
*
|
|
|
|
* All code written since the fork of torsmo is licensed under the GPL
|
|
|
|
*
|
|
|
|
* Please see COPYING for details
|
|
|
|
*
|
|
|
|
* Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
|
2009-03-30 04:55:30 +00:00
|
|
|
* Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
|
2008-02-20 20:30:45 +00:00
|
|
|
* (see AUTHORS)
|
2007-08-10 19:53:44 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2008-02-20 20:30:45 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2005-08-05 01:06:17 +00:00
|
|
|
*
|
2009-07-27 20:47:19 +00:00
|
|
|
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
|
|
|
*
|
2008-12-09 23:35:49 +00:00
|
|
|
*/
|
2005-08-05 01:06:17 +00:00
|
|
|
|
2008-12-15 21:40:24 +00:00
|
|
|
#include "config.h"
|
2005-07-20 00:30:40 +00:00
|
|
|
#include "conky.h"
|
2008-12-15 21:40:24 +00:00
|
|
|
#include "logging.h"
|
|
|
|
#include "common.h"
|
2005-08-30 00:22:55 +00:00
|
|
|
|
2008-12-15 21:40:24 +00:00
|
|
|
#include "x11.h"
|
2005-07-20 00:30:40 +00:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xatom.h>
|
2006-03-08 06:31:18 +00:00
|
|
|
#include <X11/Xmd.h>
|
2005-07-20 00:30:40 +00:00
|
|
|
#include <X11/Xutil.h>
|
2009-03-19 04:02:25 +00:00
|
|
|
#ifdef IMLIB2
|
2009-05-06 03:45:05 +00:00
|
|
|
#include "imlib2.h"
|
2009-03-19 04:02:25 +00:00
|
|
|
#endif /* IMLIB2 */
|
2008-12-15 21:40:24 +00:00
|
|
|
|
2005-07-20 00:30:40 +00:00
|
|
|
#ifdef XFT
|
|
|
|
#include <X11/Xft/Xft.h>
|
2008-12-15 21:40:24 +00:00
|
|
|
int use_xft = 0;
|
2005-07-20 00:30:40 +00:00
|
|
|
#endif
|
|
|
|
|
2006-11-07 02:19:58 +00:00
|
|
|
#ifdef HAVE_XDBE
|
2005-07-20 00:30:40 +00:00
|
|
|
int use_xdbe;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* some basic X11 stuff */
|
2009-05-28 13:45:15 +00:00
|
|
|
Display *display = NULL;
|
2005-07-20 00:30:40 +00:00
|
|
|
int display_width;
|
|
|
|
int display_height;
|
|
|
|
int screen;
|
2005-08-25 09:24:26 +00:00
|
|
|
static int set_transparent;
|
|
|
|
static int background_colour;
|
2005-07-20 00:30:40 +00:00
|
|
|
|
|
|
|
/* workarea from _NET_WORKAREA, this is where window / text is aligned */
|
|
|
|
int workarea[4];
|
|
|
|
|
|
|
|
/* Window stuff */
|
|
|
|
struct conky_window window;
|
|
|
|
|
|
|
|
/* local prototypes */
|
2008-03-29 02:01:03 +00:00
|
|
|
static void update_workarea(void);
|
2006-03-07 19:46:51 +00:00
|
|
|
static Window find_desktop_window(Window *p_root, Window *p_desktop);
|
2005-07-20 00:30:40 +00:00
|
|
|
static Window find_subwindow(Window win, int w, int h);
|
|
|
|
|
|
|
|
/* X11 initializer */
|
2009-04-01 17:06:31 +00:00
|
|
|
void init_X11(const char *disp)
|
2005-07-20 00:30:40 +00:00
|
|
|
{
|
2009-06-07 04:53:40 +00:00
|
|
|
if (!display) {
|
|
|
|
if ((display = XOpenDisplay(disp)) == NULL) {
|
2009-08-01 07:34:21 +00:00
|
|
|
CRIT_ERR(NULL, NULL, "can't open display: %s", XDisplayName(disp));
|
2009-06-07 04:53:40 +00:00
|
|
|
}
|
2008-02-20 20:30:45 +00:00
|
|
|
}
|
2005-07-20 00:30:40 +00:00
|
|
|
|
|
|
|
screen = DefaultScreen(display);
|
|
|
|
display_width = DisplayWidth(display, screen);
|
|
|
|
display_height = DisplayHeight(display, screen);
|
|
|
|
|
2009-07-14 14:57:51 +00:00
|
|
|
get_x11_desktop_info(display, 0);
|
|
|
|
|
2005-07-20 00:30:40 +00:00
|
|
|
update_workarea();
|
|
|
|
}
|
|
|
|
|
2008-03-29 02:01:03 +00:00
|
|
|
static void update_workarea(void)
|
2005-07-20 00:30:40 +00:00
|
|
|
{
|
|
|
|
/* default work area is display */
|
|
|
|
workarea[0] = 0;
|
|
|
|
workarea[1] = 0;
|
|
|
|
workarea[2] = display_width;
|
|
|
|
workarea[3] = display_height;
|
|
|
|
}
|
|
|
|
|
2008-02-20 20:30:45 +00:00
|
|
|
/* Find root window and desktop window.
|
|
|
|
* Return desktop window on success,
|
|
|
|
* and set root and desktop byref return values.
|
|
|
|
* Return 0 on failure. */
|
2006-03-07 19:46:51 +00:00
|
|
|
static Window find_desktop_window(Window *p_root, Window *p_desktop)
|
2005-07-20 00:30:40 +00:00
|
|
|
{
|
|
|
|
Atom type;
|
|
|
|
int format, i;
|
|
|
|
unsigned long nitems, bytes;
|
|
|
|
unsigned int n;
|
|
|
|
Window root = RootWindow(display, screen);
|
|
|
|
Window win = root;
|
|
|
|
Window troot, parent, *children;
|
|
|
|
unsigned char *buf = NULL;
|
|
|
|
|
2008-02-20 20:30:45 +00:00
|
|
|
if (!p_root || !p_desktop) {
|
|
|
|
return 0;
|
|
|
|
}
|
2006-03-07 19:46:51 +00:00
|
|
|
|
2005-07-20 00:30:40 +00:00
|
|
|
/* some window managers set __SWM_VROOT to some child of root window */
|
|
|
|
|
|
|
|
XQueryTree(display, root, &troot, &parent, &children, &n);
|
|
|
|
for (i = 0; i < (int) n; i++) {
|
2008-02-20 20:30:45 +00:00
|
|
|
if (XGetWindowProperty(display, children[i], ATOM(__SWM_VROOT), 0, 1,
|
2009-07-27 21:34:06 +00:00
|
|
|
False, XA_WINDOW, &type, &format, &nitems, &bytes, &buf)
|
2008-02-20 20:30:45 +00:00
|
|
|
== Success && type == XA_WINDOW) {
|
2005-07-20 00:30:40 +00:00
|
|
|
win = *(Window *) buf;
|
|
|
|
XFree(buf);
|
|
|
|
XFree(children);
|
|
|
|
fprintf(stderr,
|
2009-07-27 21:34:06 +00:00
|
|
|
PACKAGE_NAME": desktop window (%lx) found from __SWM_VROOT property\n",
|
|
|
|
win);
|
2006-03-06 23:35:41 +00:00
|
|
|
fflush(stderr);
|
2008-02-20 20:30:45 +00:00
|
|
|
*p_root = win;
|
|
|
|
*p_desktop = win;
|
2005-07-20 00:30:40 +00:00
|
|
|
return win;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (buf) {
|
|
|
|
XFree(buf);
|
|
|
|
buf = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
XFree(children);
|
|
|
|
|
|
|
|
/* get subwindows from root */
|
|
|
|
win = find_subwindow(root, -1, -1);
|
|
|
|
|
|
|
|
update_workarea();
|
|
|
|
|
|
|
|
win = find_subwindow(win, workarea[2], workarea[3]);
|
|
|
|
|
|
|
|
if (buf) {
|
|
|
|
XFree(buf);
|
|
|
|
buf = 0;
|
|
|
|
}
|
|
|
|
|
2008-02-20 20:30:45 +00:00
|
|
|
if (win != root) {
|
2005-07-20 00:30:40 +00:00
|
|
|
fprintf(stderr,
|
2009-07-27 21:34:06 +00:00
|
|
|
PACKAGE_NAME": desktop window (%lx) is subwindow of root window (%lx)\n",
|
|
|
|
win, root);
|
2008-02-20 20:30:45 +00:00
|
|
|
} else {
|
2008-07-12 10:25:05 +00:00
|
|
|
fprintf(stderr, PACKAGE_NAME": desktop window (%lx) is root window\n", win);
|
2008-02-20 20:30:45 +00:00
|
|
|
}
|
2005-07-20 00:30:40 +00:00
|
|
|
|
2006-03-06 23:35:41 +00:00
|
|
|
fflush(stderr);
|
2006-03-07 19:46:51 +00:00
|
|
|
|
2008-02-20 20:30:45 +00:00
|
|
|
*p_root = root;
|
|
|
|
*p_desktop = win;
|
2006-03-07 19:46:51 +00:00
|
|
|
|
2005-07-20 00:30:40 +00:00
|
|
|
return win;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* sets background to ParentRelative for the Window and all parents */
|
2008-06-21 14:18:44 +00:00
|
|
|
void set_transparent_background(Window win)
|
2005-07-20 00:30:40 +00:00
|
|
|
{
|
2005-08-26 02:16:35 +00:00
|
|
|
static int colour_set = -1;
|
2008-02-20 20:30:45 +00:00
|
|
|
|
2005-08-25 09:24:26 +00:00
|
|
|
if (set_transparent) {
|
|
|
|
Window parent = win;
|
|
|
|
unsigned int i;
|
2008-02-20 20:30:45 +00:00
|
|
|
|
2005-08-26 02:16:35 +00:00
|
|
|
for (i = 0; i < 50 && parent != RootWindow(display, screen); i++) {
|
2005-08-25 09:24:26 +00:00
|
|
|
Window r, *children;
|
|
|
|
unsigned int n;
|
2008-02-20 20:30:45 +00:00
|
|
|
|
2005-08-25 09:24:26 +00:00
|
|
|
XSetWindowBackgroundPixmap(display, parent, ParentRelative);
|
2008-02-20 20:30:45 +00:00
|
|
|
|
2005-08-25 09:24:26 +00:00
|
|
|
XQueryTree(display, parent, &r, &parent, &children, &n);
|
|
|
|
XFree(children);
|
2008-02-20 20:30:45 +00:00
|
|
|
}
|
2005-08-26 02:16:35 +00:00
|
|
|
} else if (colour_set != background_colour) {
|
2005-08-25 09:24:26 +00:00
|
|
|
XSetWindowBackground(display, win, background_colour);
|
2005-08-26 02:16:35 +00:00
|
|
|
colour_set = background_colour;
|
2008-02-20 20:30:45 +00:00
|
|
|
}
|
2005-07-20 00:30:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-20 03:34:43 +00:00
|
|
|
void destroy_window(void)
|
|
|
|
{
|
2009-07-15 14:33:18 +00:00
|
|
|
if(window.xftdraw) {
|
|
|
|
XftDrawDestroy(window.xftdraw);
|
|
|
|
}
|
|
|
|
if(window.gc) {
|
|
|
|
XFreeGC(display, window.gc);
|
|
|
|
}
|
2009-05-20 03:34:43 +00:00
|
|
|
memset(&window, 0, sizeof(struct conky_window));
|
|
|
|
}
|
|
|
|
|
2008-02-20 20:30:45 +00:00
|
|
|
void init_window(int own_window, int w, int h, int set_trans, int back_colour,
|
|
|
|
char **argv, int argc)
|
2005-07-20 00:30:40 +00:00
|
|
|
{
|
2008-02-20 20:30:45 +00:00
|
|
|
/* There seems to be some problems with setting transparent background
|
|
|
|
* (on fluxbox this time). It doesn't happen always and I don't know why it
|
2005-07-20 00:30:40 +00:00
|
|
|
* happens but I bet the bug is somewhere here. */
|
2005-08-25 09:24:26 +00:00
|
|
|
set_transparent = set_trans;
|
|
|
|
background_colour = back_colour;
|
2005-07-20 00:30:40 +00:00
|
|
|
|
2006-02-14 06:15:38 +00:00
|
|
|
#ifdef OWN_WINDOW
|
|
|
|
if (own_window) {
|
2008-02-20 20:30:45 +00:00
|
|
|
if (!find_desktop_window(&window.root, &window.desktop)) {
|
|
|
|
return;
|
|
|
|
}
|
2006-03-09 18:51:57 +00:00
|
|
|
|
2008-02-20 20:30:45 +00:00
|
|
|
if (window.type == TYPE_OVERRIDE) {
|
2006-03-09 18:51:57 +00:00
|
|
|
|
2008-02-20 20:30:45 +00:00
|
|
|
/* An override_redirect True window.
|
|
|
|
* No WM hints or button processing needed. */
|
|
|
|
XSetWindowAttributes attrs = { ParentRelative, 0L, 0, 0L, 0, 0,
|
|
|
|
Always, 0L, 0L, False, StructureNotifyMask | ExposureMask, 0L,
|
|
|
|
True, 0, 0 };
|
2006-03-09 18:51:57 +00:00
|
|
|
|
2008-02-20 20:30:45 +00:00
|
|
|
/* Parent is desktop window (which might be a child of root) */
|
|
|
|
window.window = XCreateWindow(display, window.desktop, window.x,
|
2009-07-27 21:34:06 +00:00
|
|
|
window.y, w, h, 0, CopyFromParent, InputOutput, CopyFromParent,
|
|
|
|
CWBackPixel | CWOverrideRedirect, &attrs);
|
2006-03-09 18:51:57 +00:00
|
|
|
|
2008-02-20 20:30:45 +00:00
|
|
|
XLowerWindow(display, window.window);
|
2006-03-09 18:51:57 +00:00
|
|
|
|
2008-07-12 10:25:05 +00:00
|
|
|
fprintf(stderr, PACKAGE_NAME": window type - override\n");
|
2008-02-20 20:30:45 +00:00
|
|
|
fflush(stderr);
|
|
|
|
} else { /* window.type != TYPE_OVERRIDE */
|
2006-03-09 18:51:57 +00:00
|
|
|
|
2008-02-20 20:30:45 +00:00
|
|
|
/* A window managed by the window manager.
|
|
|
|
* Process hints and buttons. */
|
|
|
|
XSetWindowAttributes attrs = { ParentRelative, 0L, 0, 0L, 0, 0,
|
|
|
|
Always, 0L, 0L, False, StructureNotifyMask | ExposureMask |
|
2009-07-27 21:34:06 +00:00
|
|
|
ButtonPressMask | ButtonReleaseMask, 0L, False, 0, 0 };
|
2006-03-06 05:58:58 +00:00
|
|
|
|
|
|
|
XClassHint classHint;
|
|
|
|
XWMHints wmHint;
|
2006-03-06 23:35:41 +00:00
|
|
|
Atom xa;
|
2005-07-20 00:30:40 +00:00
|
|
|
|
2008-12-07 20:44:56 +00:00
|
|
|
if (window.type == TYPE_DOCK) {
|
|
|
|
window.x = window.y = 0;
|
|
|
|
}
|
2006-03-09 18:51:57 +00:00
|
|
|
/* Parent is root window so WM can take control */
|
2008-02-20 20:30:45 +00:00
|
|
|
window.window = XCreateWindow(display, window.root, window.x,
|
2009-07-27 21:34:06 +00:00
|
|
|
window.y, w, h, 0, CopyFromParent, InputOutput, CopyFromParent,
|
|
|
|
CWBackPixel | CWOverrideRedirect, &attrs);
|
2006-01-26 01:27:41 +00:00
|
|
|
|
2006-12-23 06:01:16 +00:00
|
|
|
classHint.res_name = window.class_name;
|
2006-03-06 05:58:58 +00:00
|
|
|
classHint.res_class = classHint.res_name;
|
|
|
|
|
|
|
|
wmHint.flags = InputHint | StateHint;
|
2008-02-20 20:30:45 +00:00
|
|
|
/* allow decorated windows to be given input focus by WM */
|
|
|
|
wmHint.input =
|
|
|
|
TEST_HINT(window.hints, HINT_UNDECORATED) ? False : True;
|
2009-07-27 21:34:06 +00:00
|
|
|
if (window.type == TYPE_DOCK || window.type == TYPE_PANEL) {
|
2009-06-13 21:36:28 +00:00
|
|
|
wmHint.initial_state = WithdrawnState;
|
2009-07-27 21:34:06 +00:00
|
|
|
} else {
|
2009-06-13 21:36:28 +00:00
|
|
|
wmHint.initial_state = NormalState;
|
2009-07-27 21:34:06 +00:00
|
|
|
}
|
2006-03-06 05:58:58 +00:00
|
|
|
|
2008-02-20 20:30:45 +00:00
|
|
|
XmbSetWMProperties(display, window.window, window.title, NULL, argv,
|
2009-07-27 21:34:06 +00:00
|
|
|
argc, NULL, &wmHint, &classHint);
|
2006-03-06 05:58:58 +00:00
|
|
|
|
|
|
|
/* Sets an empty WM_PROTOCOLS property */
|
2008-02-20 20:30:45 +00:00
|
|
|
XSetWMProtocols(display, window.window, NULL, 0);
|
2006-03-06 23:35:41 +00:00
|
|
|
|
2006-03-08 22:17:27 +00:00
|
|
|
/* Set window type */
|
2008-02-20 20:30:45 +00:00
|
|
|
if ((xa = ATOM(_NET_WM_WINDOW_TYPE)) != None) {
|
2006-03-08 22:17:27 +00:00
|
|
|
Atom prop;
|
2008-02-20 20:30:45 +00:00
|
|
|
|
|
|
|
switch (window.type) {
|
|
|
|
case TYPE_DESKTOP:
|
|
|
|
prop = ATOM(_NET_WM_WINDOW_TYPE_DESKTOP);
|
2008-07-12 10:25:05 +00:00
|
|
|
fprintf(stderr, PACKAGE_NAME": window type - desktop\n");
|
2008-02-20 20:30:45 +00:00
|
|
|
fflush(stderr);
|
|
|
|
break;
|
2008-04-29 21:31:04 +00:00
|
|
|
case TYPE_DOCK:
|
|
|
|
prop = ATOM(_NET_WM_WINDOW_TYPE_DOCK);
|
2008-07-12 10:25:05 +00:00
|
|
|
fprintf(stderr, PACKAGE_NAME": window type - dock\n");
|
2008-04-29 21:31:04 +00:00
|
|
|
fflush(stderr);
|
|
|
|
break;
|
2009-06-13 21:36:28 +00:00
|
|
|
case TYPE_PANEL:
|
|
|
|
prop = ATOM(_NET_WM_WINDOW_TYPE_DOCK);
|
|
|
|
fprintf(stderr, PACKAGE_NAME": window type - panel\n");
|
|
|
|
fflush(stderr);
|
|
|
|
break;
|
2008-02-20 20:30:45 +00:00
|
|
|
case TYPE_NORMAL:
|
|
|
|
default:
|
|
|
|
prop = ATOM(_NET_WM_WINDOW_TYPE_NORMAL);
|
2008-07-12 10:25:05 +00:00
|
|
|
fprintf(stderr, PACKAGE_NAME": window type - normal\n");
|
2008-02-20 20:30:45 +00:00
|
|
|
fflush(stderr);
|
|
|
|
break;
|
2006-03-08 22:17:27 +00:00
|
|
|
}
|
2008-02-20 20:30:45 +00:00
|
|
|
XChangeProperty(display, window.window, xa, XA_ATOM, 32,
|
2009-07-27 21:34:06 +00:00
|
|
|
PropModeReplace, (unsigned char *) &prop, 1);
|
2006-03-06 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set desired hints */
|
2008-02-20 20:30:45 +00:00
|
|
|
|
2006-03-06 23:35:41 +00:00
|
|
|
/* Window decorations */
|
2008-02-20 20:30:45 +00:00
|
|
|
if (TEST_HINT(window.hints, HINT_UNDECORATED)) {
|
2008-07-12 10:25:05 +00:00
|
|
|
/* fprintf(stderr, PACKAGE_NAME": hint - undecorated\n");
|
2009-07-27 21:34:06 +00:00
|
|
|
fflush(stderr); */
|
2008-02-20 20:30:45 +00:00
|
|
|
|
|
|
|
xa = ATOM(_MOTIF_WM_HINTS);
|
|
|
|
if (xa != None) {
|
|
|
|
long prop[5] = { 2, 0, 0, 0, 0 };
|
|
|
|
XChangeProperty(display, window.window, xa, xa, 32,
|
2009-07-27 21:34:06 +00:00
|
|
|
PropModeReplace, (unsigned char *) prop, 5);
|
2008-02-20 20:30:45 +00:00
|
|
|
}
|
2006-03-06 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Below other windows */
|
2008-02-20 20:30:45 +00:00
|
|
|
if (TEST_HINT(window.hints, HINT_BELOW)) {
|
2008-07-12 10:25:05 +00:00
|
|
|
/* fprintf(stderr, PACKAGE_NAME": hint - below\n");
|
2009-07-27 21:34:06 +00:00
|
|
|
fflush(stderr); */
|
2008-02-20 20:30:45 +00:00
|
|
|
|
|
|
|
xa = ATOM(_WIN_LAYER);
|
|
|
|
if (xa != None) {
|
|
|
|
long prop = 0;
|
|
|
|
|
|
|
|
XChangeProperty(display, window.window, xa, XA_CARDINAL, 32,
|
2009-07-27 21:34:06 +00:00
|
|
|
PropModeAppend, (unsigned char *) &prop, 1);
|
2008-02-20 20:30:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
xa = ATOM(_NET_WM_STATE);
|
|
|
|
if (xa != None) {
|
|
|
|
Atom xa_prop = ATOM(_NET_WM_STATE_BELOW);
|
|
|
|
|
|
|
|
XChangeProperty(display, window.window, xa, XA_ATOM, 32,
|
2009-07-27 21:34:06 +00:00
|
|
|
PropModeAppend, (unsigned char *) &xa_prop, 1);
|
2008-02-20 20:30:45 +00:00
|
|
|
}
|
2006-03-06 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Above other windows */
|
2008-02-20 20:30:45 +00:00
|
|
|
if (TEST_HINT(window.hints, HINT_ABOVE)) {
|
2008-07-12 10:25:05 +00:00
|
|
|
/* fprintf(stderr, PACKAGE_NAME": hint - above\n");
|
2009-07-27 21:34:06 +00:00
|
|
|
fflush(stderr); */
|
2008-02-20 20:30:45 +00:00
|
|
|
|
|
|
|
xa = ATOM(_WIN_LAYER);
|
|
|
|
if (xa != None) {
|
|
|
|
long prop = 6;
|
|
|
|
|
|
|
|
XChangeProperty(display, window.window, xa, XA_CARDINAL, 32,
|
2009-07-27 21:34:06 +00:00
|
|
|
PropModeAppend, (unsigned char *) &prop, 1);
|
2008-02-20 20:30:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
xa = ATOM(_NET_WM_STATE);
|
|
|
|
if (xa != None) {
|
|
|
|
Atom xa_prop = ATOM(_NET_WM_STATE_ABOVE);
|
|
|
|
|
|
|
|
XChangeProperty(display, window.window, xa, XA_ATOM, 32,
|
2009-07-27 21:34:06 +00:00
|
|
|
PropModeAppend, (unsigned char *) &xa_prop, 1);
|
2008-02-20 20:30:45 +00:00
|
|
|
}
|
|
|
|
}
|
2006-03-06 23:35:41 +00:00
|
|
|
|
|
|
|
/* Sticky */
|
2008-02-20 20:30:45 +00:00
|
|
|
if (TEST_HINT(window.hints, HINT_STICKY)) {
|
2008-07-12 10:25:05 +00:00
|
|
|
/* fprintf(stderr, PACKAGE_NAME": hint - sticky\n");
|
2009-07-27 21:34:06 +00:00
|
|
|
fflush(stderr); */
|
2008-02-20 20:30:45 +00:00
|
|
|
|
|
|
|
xa = ATOM(_NET_WM_DESKTOP);
|
|
|
|
if (xa != None) {
|
|
|
|
CARD32 xa_prop = 0xFFFFFFFF;
|
|
|
|
|
|
|
|
XChangeProperty(display, window.window, xa, XA_CARDINAL, 32,
|
2009-07-27 21:34:06 +00:00
|
|
|
PropModeAppend, (unsigned char *) &xa_prop, 1);
|
2008-02-20 20:30:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
xa = ATOM(_NET_WM_STATE);
|
|
|
|
if (xa != None) {
|
|
|
|
Atom xa_prop = ATOM(_NET_WM_STATE_STICKY);
|
|
|
|
|
|
|
|
XChangeProperty(display, window.window, xa, XA_ATOM, 32,
|
2009-07-27 21:34:06 +00:00
|
|
|
PropModeAppend, (unsigned char *) &xa_prop, 1);
|
2008-02-20 20:30:45 +00:00
|
|
|
}
|
|
|
|
}
|
2006-03-06 23:35:41 +00:00
|
|
|
|
|
|
|
/* Skip taskbar */
|
2008-02-20 20:30:45 +00:00
|
|
|
if (TEST_HINT(window.hints, HINT_SKIP_TASKBAR)) {
|
2008-07-12 10:25:05 +00:00
|
|
|
/* fprintf(stderr, PACKAGE_NAME": hint - skip_taskbar\n");
|
2009-07-27 21:34:06 +00:00
|
|
|
fflush(stderr); */
|
2008-02-20 20:30:45 +00:00
|
|
|
|
|
|
|
xa = ATOM(_NET_WM_STATE);
|
|
|
|
if (xa != None) {
|
|
|
|
Atom xa_prop = ATOM(_NET_WM_STATE_SKIP_TASKBAR);
|
|
|
|
|
|
|
|
XChangeProperty(display, window.window, xa, XA_ATOM, 32,
|
2009-07-27 21:34:06 +00:00
|
|
|
PropModeAppend, (unsigned char *) &xa_prop, 1);
|
2008-02-20 20:30:45 +00:00
|
|
|
}
|
|
|
|
}
|
2006-03-06 23:35:41 +00:00
|
|
|
|
|
|
|
/* Skip pager */
|
2008-02-20 20:30:45 +00:00
|
|
|
if (TEST_HINT(window.hints, HINT_SKIP_PAGER)) {
|
2008-07-12 10:25:05 +00:00
|
|
|
/* fprintf(stderr, PACKAGE_NAME": hint - skip_pager\n");
|
2009-07-27 21:34:06 +00:00
|
|
|
fflush(stderr); */
|
2006-03-06 23:35:41 +00:00
|
|
|
|
2008-02-20 20:30:45 +00:00
|
|
|
xa = ATOM(_NET_WM_STATE);
|
|
|
|
if (xa != None) {
|
|
|
|
Atom xa_prop = ATOM(_NET_WM_STATE_SKIP_PAGER);
|
|
|
|
|
|
|
|
XChangeProperty(display, window.window, xa, XA_ATOM, 32,
|
2009-07-27 21:34:06 +00:00
|
|
|
PropModeAppend, (unsigned char *) &xa_prop, 1);
|
2008-02-20 20:30:45 +00:00
|
|
|
}
|
|
|
|
}
|
2009-07-27 21:34:06 +00:00
|
|
|
}
|
2008-02-20 20:30:45 +00:00
|
|
|
|
2008-07-12 10:25:05 +00:00
|
|
|
fprintf(stderr, PACKAGE_NAME": drawing to created window (0x%lx)\n",
|
2009-07-27 21:34:06 +00:00
|
|
|
window.window);
|
2006-03-09 18:51:57 +00:00
|
|
|
fflush(stderr);
|
|
|
|
|
|
|
|
XMapWindow(display, window.window);
|
2009-03-19 04:02:25 +00:00
|
|
|
|
2009-07-27 21:34:06 +00:00
|
|
|
} else
|
|
|
|
#endif /* OWN_WINDOW */
|
2005-07-20 00:30:40 +00:00
|
|
|
{
|
|
|
|
XWindowAttributes attrs;
|
|
|
|
|
2008-02-20 20:30:45 +00:00
|
|
|
if (!window.window) {
|
|
|
|
window.window = find_desktop_window(&window.root, &window.desktop);
|
|
|
|
}
|
2005-07-20 00:30:40 +00:00
|
|
|
|
|
|
|
if (XGetWindowAttributes(display, window.window, &attrs)) {
|
|
|
|
window.width = attrs.width;
|
|
|
|
window.height = attrs.height;
|
|
|
|
}
|
2006-02-14 06:15:38 +00:00
|
|
|
|
2008-07-12 10:25:05 +00:00
|
|
|
fprintf(stderr, PACKAGE_NAME": drawing to desktop window\n");
|
2005-07-20 00:30:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Drawable is same as window. This may be changed by double buffering. */
|
|
|
|
window.drawable = window.window;
|
|
|
|
|
2006-11-07 02:19:58 +00:00
|
|
|
#ifdef HAVE_XDBE
|
2005-07-20 00:30:40 +00:00
|
|
|
if (use_xdbe) {
|
|
|
|
int major, minor;
|
2008-02-20 20:30:45 +00:00
|
|
|
|
2005-07-20 00:30:40 +00:00
|
|
|
if (!XdbeQueryExtension(display, &major, &minor)) {
|
|
|
|
use_xdbe = 0;
|
|
|
|
} else {
|
2008-02-20 20:30:45 +00:00
|
|
|
window.back_buffer = XdbeAllocateBackBufferName(display,
|
2009-07-27 21:34:06 +00:00
|
|
|
window.window, XdbeBackground);
|
2005-07-20 00:30:40 +00:00
|
|
|
if (window.back_buffer != None) {
|
|
|
|
window.drawable = window.back_buffer;
|
2008-07-12 10:25:05 +00:00
|
|
|
fprintf(stderr, PACKAGE_NAME": drawing to double buffer\n");
|
2008-02-20 20:30:45 +00:00
|
|
|
} else {
|
2005-07-20 00:30:40 +00:00
|
|
|
use_xdbe = 0;
|
2008-02-20 20:30:45 +00:00
|
|
|
}
|
2005-07-20 00:30:40 +00:00
|
|
|
}
|
2008-02-20 20:30:45 +00:00
|
|
|
if (!use_xdbe) {
|
2009-08-01 18:45:43 +00:00
|
|
|
NORM_ERR("failed to set up double buffer");
|
2008-02-20 20:30:45 +00:00
|
|
|
}
|
2005-07-20 00:30:40 +00:00
|
|
|
}
|
2008-02-20 20:30:45 +00:00
|
|
|
if (!use_xdbe) {
|
2008-07-12 10:25:05 +00:00
|
|
|
fprintf(stderr, PACKAGE_NAME": drawing to single buffer\n");
|
2008-02-20 20:30:45 +00:00
|
|
|
}
|
2005-07-20 00:30:40 +00:00
|
|
|
#endif
|
2009-07-08 08:09:06 +00:00
|
|
|
window.visual = DefaultVisual(display, DefaultScreen(display));
|
|
|
|
window.colourmap = DefaultColormap(display, DefaultScreen(display));
|
2009-03-19 04:02:25 +00:00
|
|
|
#ifdef IMLIB2
|
2009-05-06 03:45:05 +00:00
|
|
|
{
|
2009-07-08 08:09:06 +00:00
|
|
|
cimlib_init(display, window.drawable, window.visual, window.colourmap);
|
2009-05-06 03:45:05 +00:00
|
|
|
}
|
2009-03-19 04:02:25 +00:00
|
|
|
#endif /* IMLIB2 */
|
2005-07-20 00:30:40 +00:00
|
|
|
XFlush(display);
|
|
|
|
|
2009-07-14 14:57:51 +00:00
|
|
|
XSelectInput(display, window.window, ExposureMask | PropertyChangeMask
|
2005-07-20 00:30:40 +00:00
|
|
|
#ifdef OWN_WINDOW
|
2009-07-27 21:34:06 +00:00
|
|
|
| (own_window ? (StructureNotifyMask |
|
|
|
|
ButtonPressMask | ButtonReleaseMask) : 0)
|
2005-07-20 00:30:40 +00:00
|
|
|
#endif
|
2009-07-27 21:34:06 +00:00
|
|
|
);
|
2005-07-20 00:30:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static Window find_subwindow(Window win, int w, int h)
|
|
|
|
{
|
|
|
|
unsigned int i, j;
|
|
|
|
Window troot, parent, *children;
|
|
|
|
unsigned int n;
|
|
|
|
|
|
|
|
/* search subwindows with same size as display or work area */
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
XQueryTree(display, win, &troot, &parent, &children, &n);
|
|
|
|
|
|
|
|
for (j = 0; j < n; j++) {
|
|
|
|
XWindowAttributes attrs;
|
|
|
|
|
2008-02-20 20:30:45 +00:00
|
|
|
if (XGetWindowAttributes(display, children[j], &attrs)) {
|
|
|
|
/* Window must be mapped and same size as display or
|
|
|
|
* work space */
|
|
|
|
if (attrs.map_state != 0 && ((attrs.width == display_width
|
2009-07-27 21:34:06 +00:00
|
|
|
&& attrs.height == display_height)
|
|
|
|
|| (attrs.width == w && attrs.height == h))) {
|
2005-07-20 00:30:40 +00:00
|
|
|
win = children[j];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
XFree(children);
|
2008-02-20 20:30:45 +00:00
|
|
|
if (j == n) {
|
2005-07-20 00:30:40 +00:00
|
|
|
break;
|
2008-02-20 20:30:45 +00:00
|
|
|
}
|
2005-07-20 00:30:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return win;
|
|
|
|
}
|
|
|
|
|
|
|
|
long get_x11_color(const char *name)
|
|
|
|
{
|
2005-07-28 04:48:27 +00:00
|
|
|
XColor color;
|
2008-02-20 20:30:45 +00:00
|
|
|
|
2005-07-20 00:30:40 +00:00
|
|
|
color.pixel = 0;
|
2008-02-20 20:30:45 +00:00
|
|
|
if (!XParseColor(display, DefaultColormap(display, screen), name, &color)) {
|
2005-12-31 17:36:16 +00:00
|
|
|
/* lets check if it's a hex colour with the # missing in front
|
2008-02-20 20:30:45 +00:00
|
|
|
* if yes, then do something about it */
|
2008-04-22 22:54:22 +00:00
|
|
|
char newname[DEFAULT_TEXT_BUFFER_SIZE];
|
2008-02-20 20:30:45 +00:00
|
|
|
|
2005-12-31 17:36:16 +00:00
|
|
|
newname[0] = '#';
|
2008-04-22 22:54:22 +00:00
|
|
|
strncpy(&newname[1], name, DEFAULT_TEXT_BUFFER_SIZE - 1);
|
2005-12-31 17:36:16 +00:00
|
|
|
/* now lets try again */
|
2008-02-20 20:30:45 +00:00
|
|
|
if (!XParseColor(display, DefaultColormap(display, screen), &newname[0],
|
2009-07-27 21:34:06 +00:00
|
|
|
&color)) {
|
2009-08-01 18:45:43 +00:00
|
|
|
NORM_ERR("can't parse X color '%s'", name);
|
2005-12-31 17:36:16 +00:00
|
|
|
return 0xFF00FF;
|
|
|
|
}
|
2005-07-20 00:30:40 +00:00
|
|
|
}
|
2008-02-20 20:30:45 +00:00
|
|
|
if (!XAllocColor(display, DefaultColormap(display, screen), &color)) {
|
2009-08-01 18:45:43 +00:00
|
|
|
NORM_ERR("can't allocate X color '%s'", name);
|
2008-02-20 20:30:45 +00:00
|
|
|
}
|
2005-07-20 00:30:40 +00:00
|
|
|
|
|
|
|
return (long) color.pixel;
|
|
|
|
}
|
|
|
|
|
2008-03-29 02:01:03 +00:00
|
|
|
void create_gc(void)
|
2005-07-20 00:30:40 +00:00
|
|
|
{
|
|
|
|
XGCValues values;
|
2008-02-20 20:30:45 +00:00
|
|
|
|
2005-07-20 00:30:40 +00:00
|
|
|
values.graphics_exposures = 0;
|
|
|
|
values.function = GXcopy;
|
|
|
|
window.gc = XCreateGC(display, window.drawable,
|
2009-07-27 21:34:06 +00:00
|
|
|
GCFunction | GCGraphicsExposures, &values);
|
2005-07-20 00:30:40 +00:00
|
|
|
}
|
2005-08-29 17:06:31 +00:00
|
|
|
|
2009-07-14 14:57:51 +00:00
|
|
|
//Get current desktop number
|
2009-07-14 15:43:27 +00:00
|
|
|
static inline void get_x11_desktop_current(Display *current_display, Window root, Atom atom)
|
2008-06-21 20:37:58 +00:00
|
|
|
{
|
2009-07-27 21:34:06 +00:00
|
|
|
Atom actual_type;
|
2009-07-11 08:50:02 +00:00
|
|
|
int actual_format;
|
|
|
|
unsigned long nitems;
|
|
|
|
unsigned long bytes_after;
|
|
|
|
unsigned char *prop = NULL;
|
2008-06-21 20:37:58 +00:00
|
|
|
struct information *current_info = &info;
|
2009-07-11 08:50:02 +00:00
|
|
|
|
2009-07-28 03:01:55 +00:00
|
|
|
if (atom == None) return;
|
|
|
|
|
2009-07-14 15:43:27 +00:00
|
|
|
if ( (XGetWindowProperty( current_display, root, atom,
|
2009-07-27 21:34:06 +00:00
|
|
|
0, 1L, False, XA_CARDINAL,
|
|
|
|
&actual_type, &actual_format, &nitems,
|
|
|
|
&bytes_after, &prop ) == Success ) &&
|
|
|
|
(actual_type == XA_CARDINAL) &&
|
|
|
|
(nitems == 1L) && (actual_format == 32) ) {
|
|
|
|
current_info->x11.desktop.current = prop[0]+1;
|
2009-07-14 14:57:51 +00:00
|
|
|
}
|
|
|
|
if(prop) {
|
2009-07-27 21:34:06 +00:00
|
|
|
XFree(prop);
|
2009-07-14 14:57:51 +00:00
|
|
|
}
|
|
|
|
}
|
2009-07-11 08:50:02 +00:00
|
|
|
|
2009-07-14 14:57:51 +00:00
|
|
|
//Get total number of available desktops
|
2009-07-14 15:43:27 +00:00
|
|
|
static inline void get_x11_desktop_number(Display *current_display, Window root, Atom atom)
|
2009-07-14 14:57:51 +00:00
|
|
|
{
|
2009-07-27 21:34:06 +00:00
|
|
|
Atom actual_type;
|
2009-07-14 14:57:51 +00:00
|
|
|
int actual_format;
|
|
|
|
unsigned long nitems;
|
|
|
|
unsigned long bytes_after;
|
|
|
|
unsigned char *prop = NULL;
|
|
|
|
struct information *current_info = &info;
|
|
|
|
|
2009-07-28 03:01:55 +00:00
|
|
|
if (atom == None) return;
|
|
|
|
|
2009-07-14 15:43:27 +00:00
|
|
|
if ( (XGetWindowProperty( current_display, root, atom,
|
2009-07-27 21:34:06 +00:00
|
|
|
0, 1L, False, XA_CARDINAL,
|
|
|
|
&actual_type, &actual_format, &nitems,
|
|
|
|
&bytes_after, &prop ) == Success ) &&
|
|
|
|
(actual_type == XA_CARDINAL) &&
|
|
|
|
(nitems == 1L) && (actual_format == 32) ) {
|
|
|
|
current_info->x11.desktop.number = prop[0];
|
2009-07-14 14:57:51 +00:00
|
|
|
}
|
|
|
|
if(prop) {
|
2009-07-27 21:34:06 +00:00
|
|
|
XFree(prop);
|
2009-07-11 08:50:02 +00:00
|
|
|
}
|
2009-07-14 14:57:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Get all desktop names
|
2009-07-14 15:43:27 +00:00
|
|
|
static inline void get_x11_desktop_names(Display *current_display, Window root, Atom atom)
|
2009-07-14 14:57:51 +00:00
|
|
|
{
|
2009-07-27 21:34:06 +00:00
|
|
|
Atom actual_type;
|
2009-07-14 14:57:51 +00:00
|
|
|
int actual_format;
|
|
|
|
unsigned long nitems;
|
|
|
|
unsigned long bytes_after;
|
|
|
|
unsigned char *prop = NULL;
|
|
|
|
struct information *current_info = &info;
|
2009-07-11 08:50:02 +00:00
|
|
|
|
2009-07-28 03:01:55 +00:00
|
|
|
if (atom == None) return;
|
|
|
|
|
2009-07-14 15:43:27 +00:00
|
|
|
if ( (XGetWindowProperty( current_display, root, atom,
|
2009-07-27 21:34:06 +00:00
|
|
|
0, (~0L), False, ATOM(UTF8_STRING),
|
|
|
|
&actual_type, &actual_format, &nitems,
|
|
|
|
&bytes_after, &prop ) == Success ) &&
|
|
|
|
(actual_type == ATOM(UTF8_STRING)) &&
|
|
|
|
(nitems > 0L) && (actual_format == 8) ) {
|
|
|
|
|
|
|
|
if(current_info->x11.desktop.all_names) {
|
|
|
|
free(current_info->x11.desktop.all_names);
|
|
|
|
current_info->x11.desktop.all_names = NULL;
|
|
|
|
}
|
|
|
|
current_info->x11.desktop.all_names = malloc(nitems*sizeof(char));
|
|
|
|
memcpy(current_info->x11.desktop.all_names, prop, nitems);
|
|
|
|
current_info->x11.desktop.nitems = nitems;
|
2009-07-14 14:57:51 +00:00
|
|
|
}
|
|
|
|
if(prop) {
|
2009-07-27 21:34:06 +00:00
|
|
|
XFree(prop);
|
2009-07-11 08:50:02 +00:00
|
|
|
}
|
2009-07-14 14:57:51 +00:00
|
|
|
}
|
2009-07-11 08:50:02 +00:00
|
|
|
|
2009-07-14 14:57:51 +00:00
|
|
|
//Get current desktop name
|
|
|
|
static inline void get_x11_desktop_current_name(char *names)
|
|
|
|
{
|
|
|
|
struct information *current_info = &info;
|
|
|
|
unsigned int i = 0, j = 0;
|
|
|
|
int k = 0;
|
|
|
|
|
|
|
|
while ( i < current_info->x11.desktop.nitems ) {
|
2009-07-27 21:34:06 +00:00
|
|
|
if ( names[i++] == '\0' ) {
|
|
|
|
if ( ++k == current_info->x11.desktop.current ) {
|
|
|
|
if (current_info->x11.desktop.name) {
|
|
|
|
free(current_info->x11.desktop.name);
|
|
|
|
current_info->x11.desktop.name = NULL;
|
|
|
|
}
|
|
|
|
current_info->x11.desktop.name = malloc((i-j)*sizeof(char));
|
|
|
|
//desktop names can be empty but should always be not null
|
|
|
|
strcpy( current_info->x11.desktop.name, (char *)&names[j] );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
j = i;
|
|
|
|
}
|
2009-07-11 08:50:02 +00:00
|
|
|
}
|
2009-07-14 14:57:51 +00:00
|
|
|
}
|
|
|
|
|
2009-07-14 15:43:27 +00:00
|
|
|
void get_x11_desktop_info(Display *current_display, Atom atom)
|
2009-07-14 14:57:51 +00:00
|
|
|
{
|
2009-07-27 21:34:06 +00:00
|
|
|
Window root;
|
2009-07-14 14:57:51 +00:00
|
|
|
static Atom atom_current, atom_number, atom_names;
|
|
|
|
struct information *current_info = &info;
|
2009-07-14 17:17:14 +00:00
|
|
|
XWindowAttributes window_attributes;
|
2009-07-11 08:50:02 +00:00
|
|
|
|
2009-07-14 15:43:27 +00:00
|
|
|
root = RootWindow(current_display, current_info->x11.monitor.current);
|
2009-07-14 14:57:51 +00:00
|
|
|
|
2009-07-28 03:01:55 +00:00
|
|
|
/* Check if we initialise else retrieve changed property */
|
2009-07-14 14:57:51 +00:00
|
|
|
if (atom == 0) {
|
2009-07-27 21:34:06 +00:00
|
|
|
atom_current = XInternAtom(current_display, "_NET_CURRENT_DESKTOP", True);
|
|
|
|
atom_number = XInternAtom(current_display, "_NET_NUMBER_OF_DESKTOPS", True);
|
|
|
|
atom_names = XInternAtom(current_display, "_NET_DESKTOP_NAMES", True);
|
|
|
|
get_x11_desktop_current(current_display, root, atom_current);
|
|
|
|
get_x11_desktop_number(current_display, root, atom_number);
|
|
|
|
get_x11_desktop_names(current_display, root, atom_names);
|
|
|
|
get_x11_desktop_current_name(current_info->x11.desktop.all_names);
|
|
|
|
|
2009-07-28 03:01:55 +00:00
|
|
|
/* Set the PropertyChangeMask on the root window, if not set */
|
2009-07-27 21:34:06 +00:00
|
|
|
XGetWindowAttributes(display, root, &window_attributes);
|
|
|
|
if (!(window_attributes.your_event_mask & PropertyChangeMask)) {
|
|
|
|
XSetWindowAttributes attributes;
|
|
|
|
attributes.event_mask = window_attributes.your_event_mask | PropertyChangeMask;
|
|
|
|
XChangeWindowAttributes(display, root, CWEventMask, &attributes);
|
|
|
|
XGetWindowAttributes(display, root, &window_attributes);
|
|
|
|
}
|
2009-07-14 14:57:51 +00:00
|
|
|
} else {
|
2009-07-27 21:34:06 +00:00
|
|
|
if (atom == atom_current) {
|
|
|
|
get_x11_desktop_current(current_display, root, atom_current);
|
|
|
|
get_x11_desktop_current_name(current_info->x11.desktop.all_names);
|
|
|
|
} else if (atom == atom_number) {
|
|
|
|
get_x11_desktop_number(current_display, root, atom_number);
|
|
|
|
} else if (atom == atom_names) {
|
|
|
|
get_x11_desktop_names(current_display, root, atom_names);
|
|
|
|
get_x11_desktop_current_name(current_info->x11.desktop.all_names);
|
|
|
|
}
|
2009-07-14 14:57:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void update_x11info(void)
|
|
|
|
{
|
|
|
|
struct information *current_info = &info;
|
|
|
|
current_info->x11.monitor.number = XScreenCount(display);
|
|
|
|
current_info->x11.monitor.current = XDefaultScreen(display);
|
2008-06-21 20:37:58 +00:00
|
|
|
}
|
2009-06-13 21:36:28 +00:00
|
|
|
|
2009-07-13 21:19:32 +00:00
|
|
|
#ifdef OWN_WINDOW
|
2009-06-13 21:36:28 +00:00
|
|
|
/* reserve window manager space */
|
|
|
|
void set_struts(int sidenum)
|
|
|
|
{
|
|
|
|
Atom strut;
|
|
|
|
if ((strut = ATOM(_NET_WM_STRUT)) != None) {
|
|
|
|
/* reserve space at left, right, top, bottom */
|
|
|
|
signed long sizes[12] = {0};
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* define strut depth */
|
|
|
|
switch (sidenum) {
|
|
|
|
case 0:
|
|
|
|
/* left side */
|
|
|
|
sizes[0] = window.x + window.width;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
/* right side */
|
|
|
|
sizes[1] = display_width - window.x;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
/* top side */
|
|
|
|
sizes[2] = window.y + window.height;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
/* bottom side */
|
|
|
|
sizes[3] = display_height - window.y;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* define partial strut length */
|
|
|
|
if (sidenum <= 1) {
|
|
|
|
sizes[4 + (sidenum*2)] = window.y;
|
|
|
|
sizes[5 + (sidenum*2)] = window.y + window.height;
|
|
|
|
} else if (sidenum <= 3) {
|
|
|
|
sizes[4 + (sidenum*2)] = window.x;
|
|
|
|
sizes[5 + (sidenum*2)] = window.x + window.width;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check constraints */
|
|
|
|
for (i = 0; i < 12; i++) {
|
|
|
|
if (sizes[i] < 0) {
|
|
|
|
sizes[i] = 0;
|
|
|
|
} else {
|
|
|
|
if (i <= 1 || i >= 8) {
|
|
|
|
if (sizes[i] > display_width) {
|
|
|
|
sizes[i] = display_width;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (sizes[i] > display_height) {
|
|
|
|
sizes[i] = display_height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
XChangeProperty(display, window.window, strut, XA_CARDINAL, 32,
|
|
|
|
PropModeReplace, (unsigned char *) &sizes, 4);
|
|
|
|
|
|
|
|
if ((strut = ATOM(_NET_WM_STRUT_PARTIAL)) != None) {
|
|
|
|
XChangeProperty(display, window.window, strut, XA_CARDINAL, 32,
|
|
|
|
PropModeReplace, (unsigned char *) &sizes, 12);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-07-13 21:19:32 +00:00
|
|
|
#endif /* OWN_WINDOW */
|