Fixed wrong re-generation of 'config-paths.h' file
[wmaker-crm.git] / src / wcore.c
blobac896a521b5d4256cde26148dddb0acb8984a826
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 along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "wconfig.h"
23 #include <X11/Xlib.h>
24 #include <X11/Xutil.h>
26 #include <stdlib.h>
27 #include <string.h>
29 #include "WindowMaker.h"
30 #include "wcore.h"
32 /****** Global Variables ******/
33 extern WPreferences wPreferences;
35 /* cursors */
36 extern Cursor wCursor[WCUR_LAST];
38 extern XContext wWinContext;
41 *----------------------------------------------------------------------
42 * wCoreCreateTopLevel--
43 * Creates a toplevel window used for icons, menus and dialogs.
45 * Returns:
46 * The created window.
47 *----------------------------------------------------------------------
49 WCoreWindow *wCoreCreateTopLevel(WScreen * screen, int x, int y, int width, int height, int bwidth)
51 WCoreWindow *core;
52 int vmask;
53 XSetWindowAttributes attribs;
55 core = wmalloc(sizeof(WCoreWindow));
57 /* don't set CWBackPixel so that transparent XRender windows
58 are see-through */
59 vmask = /*CWBackPixmap|CWBackPixel| */ CWBorderPixel | CWCursor | CWEventMask
60 | CWOverrideRedirect;
61 attribs.override_redirect = True;
62 attribs.cursor = wCursor[WCUR_DEFAULT];
63 attribs.background_pixmap = None;
64 attribs.background_pixel = screen->black_pixel;
65 attribs.border_pixel = screen->frame_border_pixel;
66 attribs.event_mask = SubstructureRedirectMask | ButtonPressMask
67 | ButtonReleaseMask | ButtonMotionMask | ExposureMask | EnterWindowMask | LeaveWindowMask;
69 vmask |= CWColormap;
70 attribs.colormap = screen->w_colormap;
72 core->window = XCreateWindow(dpy, screen->root_win, x, y, width, height,
73 bwidth, screen->w_depth, CopyFromParent, screen->w_visual, vmask, &attribs);
74 core->width = width;
75 core->height = height;
76 core->screen_ptr = screen;
78 core->descriptor.self = core;
80 XClearWindow(dpy, core->window);
82 XSaveContext(dpy, core->window, wWinContext, (XPointer) & core->descriptor);
84 return core;
88 *----------------------------------------------------------------------
89 * wCoreCreate--
90 * Creates a brand new child window.
91 * The window will have a border width of 0 and color is black.
93 * Returns:
94 * A initialized core window structure.
96 * Side effects:
97 * A window context for the created window is saved.
99 * Notes:
100 * The event mask is initialized to a default value.
102 *----------------------------------------------------------------------
104 WCoreWindow *wCoreCreate(WCoreWindow * parent, int x, int y, int width, int height)
106 WCoreWindow *core;
107 int vmask;
108 XSetWindowAttributes attribs;
110 core = wmalloc(sizeof(WCoreWindow));
112 vmask = /*CWBackPixmap|CWBackPixel| */ CWBorderPixel | CWCursor | CWEventMask;
113 attribs.cursor = wCursor[WCUR_DEFAULT];
114 attribs.background_pixmap = None;
115 attribs.background_pixel = parent->screen_ptr->black_pixel;
116 attribs.event_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask
117 | ButtonReleaseMask | ButtonMotionMask | ExposureMask | EnterWindowMask | LeaveWindowMask;
119 vmask |= CWColormap;
120 attribs.colormap = parent->screen_ptr->w_colormap;
122 core->window =
123 XCreateWindow(dpy, parent->window, x, y, width, height, 0,
124 parent->screen_ptr->w_depth, CopyFromParent,
125 parent->screen_ptr->w_visual, vmask, &attribs);
126 core->width = width;
127 core->height = height;
128 core->screen_ptr = parent->screen_ptr;
130 core->descriptor.self = core;
132 XSaveContext(dpy, core->window, wWinContext, (XPointer) & core->descriptor);
133 return core;
136 void wCoreDestroy(WCoreWindow * core)
138 if (core->stacking) {
139 wfree(core->stacking);
141 XDeleteContext(dpy, core->window, wWinContext);
142 XDestroyWindow(dpy, core->window);
143 wfree(core);
146 void wCoreConfigure(WCoreWindow * core, int req_x, int req_y, int req_w, int req_h)
148 XWindowChanges xwc;
149 unsigned int mask;
151 mask = CWX | CWY;
152 xwc.x = req_x;
153 xwc.y = req_y;
155 if (req_w <= 0)
156 req_w = core->width;
157 if (req_h <= 0)
158 req_h = core->height;
160 if (req_w != core->width || req_h != core->height) {
161 mask |= CWWidth | CWHeight;
162 xwc.width = req_w;
163 xwc.height = req_h;
164 core->width = req_w;
165 core->height = req_h;
167 XConfigureWindow(dpy, core->window, mask, &xwc);