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,
25 #include <X11/Xutil.h>
30 #include "WindowMaker.h"
33 /****** Global Variables ******/
34 extern WPreferences wPreferences;
37 extern Cursor wCursor[WCUR_LAST];
39 extern XContext wWinContext;
42 *----------------------------------------------------------------------
43 * wCoreCreateTopLevel--
44 * Creates a toplevel window used for icons, menus and dialogs.
48 *----------------------------------------------------------------------
50 WCoreWindow *wCoreCreateTopLevel(WScreen * screen, int x, int y, int width, int height, int bwidth)
54 XSetWindowAttributes attribs;
56 core = wmalloc(sizeof(WCoreWindow));
57 memset(core, 0, sizeof(WCoreWindow));
59 /* don't set CWBackPixel so that transparent XRender windows
61 vmask = /*CWBackPixmap|CWBackPixel| */ CWBorderPixel | CWCursor | CWEventMask
63 attribs.override_redirect = True;
64 attribs.cursor = wCursor[WCUR_DEFAULT];
65 attribs.background_pixmap = None;
66 attribs.background_pixel = screen->black_pixel;
67 attribs.border_pixel = screen->frame_border_pixel;
68 attribs.event_mask = SubstructureRedirectMask | ButtonPressMask
69 | ButtonReleaseMask | ButtonMotionMask | ExposureMask | EnterWindowMask | LeaveWindowMask;
72 attribs.colormap = screen->w_colormap;
74 core->window = XCreateWindow(dpy, screen->root_win, x, y, width, height,
75 bwidth, screen->w_depth, CopyFromParent, screen->w_visual, vmask, &attribs);
77 core->height = height;
78 core->screen_ptr = screen;
80 core->descriptor.self = core;
82 XClearWindow(dpy, core->window);
84 XSaveContext(dpy, core->window, wWinContext, (XPointer) & core->descriptor);
90 *----------------------------------------------------------------------
92 * Creates a brand new child window.
93 * The window will have a border width of 0 and color is black.
96 * A initialized core window structure.
99 * A window context for the created window is saved.
102 * The event mask is initialized to a default value.
104 *----------------------------------------------------------------------
106 WCoreWindow *wCoreCreate(WCoreWindow * parent, int x, int y, int width, int height)
110 XSetWindowAttributes attribs;
112 core = wmalloc(sizeof(WCoreWindow));
113 memset(core, 0, sizeof(WCoreWindow));
115 vmask = /*CWBackPixmap|CWBackPixel| */ CWBorderPixel | CWCursor | CWEventMask;
116 attribs.cursor = wCursor[WCUR_DEFAULT];
117 attribs.background_pixmap = None;
118 attribs.background_pixel = parent->screen_ptr->black_pixel;
119 attribs.event_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask
120 | ButtonReleaseMask | ButtonMotionMask | ExposureMask | EnterWindowMask | LeaveWindowMask;
123 attribs.colormap = parent->screen_ptr->w_colormap;
126 XCreateWindow(dpy, parent->window, x, y, width, height, 0,
127 parent->screen_ptr->w_depth, CopyFromParent,
128 parent->screen_ptr->w_visual, vmask, &attribs);
130 core->height = height;
131 core->screen_ptr = parent->screen_ptr;
133 core->descriptor.self = core;
135 XSaveContext(dpy, core->window, wWinContext, (XPointer) & core->descriptor);
139 void wCoreDestroy(WCoreWindow * core)
141 if (core->stacking) {
142 wfree(core->stacking);
144 XDeleteContext(dpy, core->window, wWinContext);
145 XDestroyWindow(dpy, core->window);
149 void wCoreConfigure(WCoreWindow * core, int req_x, int req_y, int req_w, int req_h)
161 req_h = core->height;
163 if (req_w != core->width || req_h != core->height) {
164 mask |= CWWidth | CWHeight;
168 core->height = req_h;
170 XConfigureWindow(dpy, core->window, mask, &xwc);