Fixed paths, because mr Alex "Big Mouth" Perez was unable to get them right
[wmaker-crm.git] / src / wcore.c
blob6da6225689cfc4d46317dd00a526c33c53d7eb42
1 /*
2 * Window Maker window manager
4 * Copyright (c) 1997-2003 Alfredo K. Kojima
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 * USA.
22 #include "wconfig.h"
24 #include <X11/Xlib.h>
25 #include <X11/Xutil.h>
27 #include <stdlib.h>
28 #include <string.h>
30 #include "WindowMaker.h"
31 #include "wcore.h"
34 /****** Global Variables ******/
35 extern WPreferences wPreferences;
37 /* cursors */
38 extern Cursor wCursor[WCUR_LAST];
40 extern XContext wWinContext;
44 *----------------------------------------------------------------------
45 * wCoreCreateTopLevel--
46 * Creates a toplevel window used for icons, menus and dialogs.
48 * Returns:
49 * The created window.
50 *----------------------------------------------------------------------
52 WCoreWindow*
53 wCoreCreateTopLevel(WScreen *screen, int x, int y, int width, int height,
54 int bwidth)
56 WCoreWindow *core;
57 int vmask;
58 XSetWindowAttributes attribs;
60 core = wmalloc(sizeof(WCoreWindow));
61 memset(core, 0, sizeof(WCoreWindow));
63 /* don't set CWBackPixel so that transparent XRender windows
64 are see-through */
65 vmask = /*CWBackPixmap|CWBackPixel|*/CWBorderPixel|CWCursor|CWEventMask
66 |CWOverrideRedirect;
67 attribs.override_redirect = True;
68 attribs.cursor = wCursor[WCUR_DEFAULT];
69 attribs.background_pixmap = None;
70 attribs.background_pixel = screen->black_pixel;
71 attribs.border_pixel = screen->frame_border_pixel;
72 attribs.event_mask = SubstructureRedirectMask | ButtonPressMask
73 | ButtonReleaseMask | ButtonMotionMask | ExposureMask | EnterWindowMask
74 | LeaveWindowMask;
76 vmask |= CWColormap;
77 attribs.colormap = screen->w_colormap;
79 core->window = XCreateWindow(dpy, screen->root_win, x, y, width, height,
80 bwidth, screen->w_depth, CopyFromParent,
81 screen->w_visual, vmask, &attribs);
82 core->width = width;
83 core->height = height;
84 core->screen_ptr = screen;
86 core->descriptor.self = core;
88 XClearWindow(dpy, core->window);
90 XSaveContext(dpy, core->window, wWinContext, (XPointer)&core->descriptor);
92 return core;
97 *----------------------------------------------------------------------
98 * wCoreCreate--
99 * Creates a brand new child window.
100 * The window will have a border width of 0 and color is black.
102 * Returns:
103 * A initialized core window structure.
105 * Side effects:
106 * A window context for the created window is saved.
108 * Notes:
109 * The event mask is initialized to a default value.
111 *----------------------------------------------------------------------
113 WCoreWindow*
114 wCoreCreate(WCoreWindow *parent, int x, int y, int width, int height)
116 WCoreWindow *core;
117 int vmask;
118 XSetWindowAttributes attribs;
120 core=wmalloc(sizeof(WCoreWindow));
121 memset(core, 0, sizeof(WCoreWindow));
123 vmask = /*CWBackPixmap|CWBackPixel|*/CWBorderPixel|CWCursor|CWEventMask;
124 attribs.cursor = wCursor[WCUR_DEFAULT];
125 attribs.background_pixmap = None;
126 attribs.background_pixel = parent->screen_ptr->black_pixel;
127 attribs.event_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask
128 | ButtonReleaseMask | ButtonMotionMask | ExposureMask | EnterWindowMask
129 | LeaveWindowMask;
131 vmask |= CWColormap;
132 attribs.colormap = parent->screen_ptr->w_colormap;
134 core->window =
135 XCreateWindow(dpy, parent->window, x, y, width, height, 0,
136 parent->screen_ptr->w_depth, CopyFromParent,
137 parent->screen_ptr->w_visual, vmask, &attribs);
138 core->width=width;
139 core->height=height;
140 core->screen_ptr = parent->screen_ptr;
142 core->descriptor.self = core;
144 XSaveContext(dpy, core->window, wWinContext, (XPointer)&core->descriptor);
145 return core;
150 void
151 wCoreDestroy(WCoreWindow *core)
153 if (core->stacking) {
154 wfree(core->stacking);
156 XDeleteContext(dpy, core->window, wWinContext);
157 XDestroyWindow(dpy, core->window);
158 wfree(core);
162 void
163 wCoreConfigure(WCoreWindow *core, int req_x, int req_y, int req_w, int req_h)
165 XWindowChanges xwc;
166 unsigned int mask;
168 mask = CWX|CWY;
169 xwc.x = req_x;
170 xwc.y = req_y;
172 if (req_w <= 0)
173 req_w = core->width;
174 if (req_h <= 0)
175 req_h = core->height;
177 if (req_w != core->width || req_h != core->height) {
178 mask |= CWWidth | CWHeight;
179 xwc.width = req_w;
180 xwc.height = req_h;
181 core->width = req_w;
182 core->height = req_h;
184 XConfigureWindow(dpy, core->window, mask, &xwc);