* Please see COPYING for details
*
* Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
* (see AUTHORS)
* All rights reserved.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- * $Id$ */
+ */
+#include "config.h"
#include "conky.h"
+#include "logging.h"
+#include "common.h"
-#ifdef X11
+#include "x11.h"
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xmd.h>
#include <X11/Xutil.h>
+
#ifdef XFT
#include <X11/Xft/Xft.h>
+int use_xft = 0;
#endif
#ifdef HAVE_XDBE
int use_xdbe;
#endif
-#ifdef XFT
-int use_xft = 0;
-#endif
-
/* some basic X11 stuff */
Display *display;
int display_width;
struct conky_window window;
/* local prototypes */
-static void update_workarea();
+static void update_workarea(void);
static Window find_desktop_window(Window *p_root, Window *p_desktop);
static Window find_subwindow(Window win, int w, int h);
/* X11 initializer */
-void init_X11()
+void init_X11(void)
{
if ((display = XOpenDisplay(0)) == NULL) {
CRIT_ERR("can't open display: %s", XDisplayName(0));
update_workarea();
}
-static void update_workarea()
+static void update_workarea(void)
{
Window root = RootWindow(display, screen);
unsigned long nitems, bytes;
XFree(buf);
XFree(children);
fprintf(stderr,
- "Conky: desktop window (%lx) found from __SWM_VROOT property\n",
+ PACKAGE_NAME": desktop window (%lx) found from __SWM_VROOT property\n",
win);
fflush(stderr);
*p_root = win;
if (win != root) {
fprintf(stderr,
- "Conky: desktop window (%lx) is subwindow of root window (%lx)\n",
+ PACKAGE_NAME": desktop window (%lx) is subwindow of root window (%lx)\n",
win, root);
} else {
- fprintf(stderr, "Conky: desktop window (%lx) is root window\n", win);
+ fprintf(stderr, PACKAGE_NAME": desktop window (%lx) is root window\n", win);
}
fflush(stderr);
}
/* sets background to ParentRelative for the Window and all parents */
-inline void set_transparent_background(Window win)
+void set_transparent_background(Window win)
{
static int colour_set = -1;
XLowerWindow(display, window.window);
- fprintf(stderr, "Conky: window type - override\n");
+ fprintf(stderr, PACKAGE_NAME": window type - override\n");
fflush(stderr);
} else { /* window.type != TYPE_OVERRIDE */
XWMHints wmHint;
Atom xa;
+ if (window.type == TYPE_DOCK) {
+ window.x = window.y = 0;
+ }
/* Parent is root window so WM can take control */
window.window = XCreateWindow(display, window.root, window.x,
window.y, w, h, 0, CopyFromParent, InputOutput, CopyFromParent,
/* allow decorated windows to be given input focus by WM */
wmHint.input =
TEST_HINT(window.hints, HINT_UNDECORATED) ? False : True;
- wmHint.initial_state = NormalState;
+ wmHint.initial_state = ((window.type == TYPE_DOCK) ?
+ WithdrawnState : NormalState);
XmbSetWMProperties(display, window.window, window.title, NULL, argv,
argc, NULL, &wmHint, &classHint);
switch (window.type) {
case TYPE_DESKTOP:
prop = ATOM(_NET_WM_WINDOW_TYPE_DESKTOP);
- fprintf(stderr, "Conky: window type - desktop\n");
+ fprintf(stderr, PACKAGE_NAME": window type - desktop\n");
+ fflush(stderr);
+ break;
+ case TYPE_DOCK:
+ prop = ATOM(_NET_WM_WINDOW_TYPE_DOCK);
+ fprintf(stderr, PACKAGE_NAME": window type - dock\n");
fflush(stderr);
break;
case TYPE_NORMAL:
default:
prop = ATOM(_NET_WM_WINDOW_TYPE_NORMAL);
- fprintf(stderr, "Conky: window type - normal\n");
+ fprintf(stderr, PACKAGE_NAME": window type - normal\n");
fflush(stderr);
break;
}
/* Window decorations */
if (TEST_HINT(window.hints, HINT_UNDECORATED)) {
- /* fprintf(stderr, "Conky: hint - undecorated\n");
+ /* fprintf(stderr, PACKAGE_NAME": hint - undecorated\n");
fflush(stderr); */
xa = ATOM(_MOTIF_WM_HINTS);
/* Below other windows */
if (TEST_HINT(window.hints, HINT_BELOW)) {
- /* fprintf(stderr, "Conky: hint - below\n");
+ /* fprintf(stderr, PACKAGE_NAME": hint - below\n");
fflush(stderr); */
xa = ATOM(_WIN_LAYER);
/* Above other windows */
if (TEST_HINT(window.hints, HINT_ABOVE)) {
- /* fprintf(stderr, "Conky: hint - above\n");
+ /* fprintf(stderr, PACKAGE_NAME": hint - above\n");
fflush(stderr); */
xa = ATOM(_WIN_LAYER);
/* Sticky */
if (TEST_HINT(window.hints, HINT_STICKY)) {
- /* fprintf(stderr, "Conky: hint - sticky\n");
+ /* fprintf(stderr, PACKAGE_NAME": hint - sticky\n");
fflush(stderr); */
xa = ATOM(_NET_WM_DESKTOP);
/* Skip taskbar */
if (TEST_HINT(window.hints, HINT_SKIP_TASKBAR)) {
- /* fprintf(stderr, "Conky: hint - skip_taskbar\n");
+ /* fprintf(stderr, PACKAGE_NAME": hint - skip_taskbar\n");
fflush(stderr); */
xa = ATOM(_NET_WM_STATE);
/* Skip pager */
if (TEST_HINT(window.hints, HINT_SKIP_PAGER)) {
- /* fprintf(stderr, "Conky: hint - skip_pager\n");
+ /* fprintf(stderr, PACKAGE_NAME": hint - skip_pager\n");
fflush(stderr); */
xa = ATOM(_NET_WM_STATE);
}
} /* else { window.type != TYPE_OVERRIDE */
- fprintf(stderr, "Conky: drawing to created window (%lx)\n",
+ fprintf(stderr, PACKAGE_NAME": drawing to created window (0x%lx)\n",
window.window);
fflush(stderr);
window.height = attrs.height;
}
- fprintf(stderr, "Conky: drawing to desktop window\n");
+ fprintf(stderr, PACKAGE_NAME": drawing to desktop window\n");
}
/* Drawable is same as window. This may be changed by double buffering. */
window.window, XdbeBackground);
if (window.back_buffer != None) {
window.drawable = window.back_buffer;
- fprintf(stderr, "Conky: drawing to double buffer\n");
+ fprintf(stderr, PACKAGE_NAME": drawing to double buffer\n");
} else {
use_xdbe = 0;
}
}
}
if (!use_xdbe) {
- fprintf(stderr, "Conky: drawing to single buffer\n");
+ fprintf(stderr, PACKAGE_NAME": drawing to single buffer\n");
}
#endif
if (!XParseColor(display, DefaultColormap(display, screen), name, &color)) {
/* lets check if it's a hex colour with the # missing in front
* if yes, then do something about it */
- char newname[64];
+ char newname[DEFAULT_TEXT_BUFFER_SIZE];
newname[0] = '#';
- strncpy(&newname[1], name, 62);
+ strncpy(&newname[1], name, DEFAULT_TEXT_BUFFER_SIZE - 1);
/* now lets try again */
if (!XParseColor(display, DefaultColormap(display, screen), &newname[0],
&color)) {
return (long) color.pixel;
}
-void create_gc()
+void create_gc(void)
{
XGCValues values;
GCFunction | GCGraphicsExposures, &values);
}
-#endif /* X11 */
+void update_x11info(void)
+{
+ struct information *current_info = &info;
+ current_info->x11.monitor.number = XScreenCount(display);
+ current_info->x11.monitor.current = XDefaultScreen(display);
+}