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.
24 #include <X11/Xutil.h>
29 #include "WindowMaker.h"
32 /****** Global Variables ******/
33 extern WPreferences wPreferences
;
36 extern Cursor wCursor
[WCUR_LAST
];
37 extern XContext wWinContext
;
39 /*----------------------------------------------------------------------
40 * wCoreCreateTopLevel--
41 * Creates a toplevel window used for icons, menus and dialogs.
45 *--------------------------------------------------------------------- */
46 WCoreWindow
*wCoreCreateTopLevel(WScreen
*screen
, int x
, int y
, int width
, int height
, int bwidth
, int depth
, Visual
*visual
, Colormap colormap
)
50 XSetWindowAttributes attribs
;
52 core
= wmalloc(sizeof(WCoreWindow
));
54 vmask
= CWBackPixel
| CWBorderPixel
| CWCursor
| CWEventMask
| CWOverrideRedirect
| CWColormap
;
55 attribs
.override_redirect
= True
;
56 attribs
.cursor
= wCursor
[WCUR_DEFAULT
];
57 attribs
.background_pixel
= screen
->black_pixel
;
58 attribs
.border_pixel
= screen
->frame_border_pixel
;
59 attribs
.event_mask
= SubstructureRedirectMask
| ButtonPressMask
|
60 ButtonReleaseMask
| ButtonMotionMask
|
61 ExposureMask
| EnterWindowMask
| LeaveWindowMask
;
63 attribs
.colormap
= colormap
;
65 core
->window
= XCreateWindow(dpy
, screen
->root_win
, x
, y
, width
, height
,
66 bwidth
, depth
, CopyFromParent
, visual
, vmask
, &attribs
);
68 core
->height
= height
;
69 core
->screen_ptr
= screen
;
70 core
->descriptor
.self
= core
;
72 XClearWindow(dpy
, core
->window
);
73 XSaveContext(dpy
, core
->window
, wWinContext
, (XPointer
) & core
->descriptor
);
78 /*----------------------------------------------------------------------
80 * Creates a brand new child window.
81 * The window will have a border width of 0 and color is black.
84 * A initialized core window structure.
87 * A window context for the created window is saved.
90 * The event mask is initialized to a default value.
91 *--------------------------------------------------------------------- */
92 WCoreWindow
*wCoreCreate(WCoreWindow
*parent
, int x
, int y
, int width
, int height
)
96 XSetWindowAttributes attribs
;
98 core
= wmalloc(sizeof(WCoreWindow
));
100 vmask
= CWBackPixel
| CWCursor
| CWEventMask
| CWColormap
;
101 attribs
.cursor
= wCursor
[WCUR_DEFAULT
];
102 attribs
.background_pixel
= parent
->screen_ptr
->black_pixel
;
103 attribs
.event_mask
= KeyPressMask
| KeyReleaseMask
| ButtonPressMask
|
104 ButtonReleaseMask
| ButtonMotionMask
|
105 ExposureMask
| EnterWindowMask
| LeaveWindowMask
;
106 attribs
.colormap
= parent
->screen_ptr
->w_colormap
;
107 core
->window
= XCreateWindow(dpy
, parent
->window
, x
, y
, width
, height
, 0,
108 parent
->screen_ptr
->w_depth
, CopyFromParent
,
109 parent
->screen_ptr
->w_visual
, vmask
, &attribs
);
112 core
->height
= height
;
113 core
->screen_ptr
= parent
->screen_ptr
;
114 core
->descriptor
.self
= core
;
116 XSaveContext(dpy
, core
->window
, wWinContext
, (XPointer
) & core
->descriptor
);
120 void wCoreDestroy(WCoreWindow
* core
)
123 wfree(core
->stacking
);
125 XDeleteContext(dpy
, core
->window
, wWinContext
);
126 XDestroyWindow(dpy
, core
->window
);
130 void wCoreConfigure(WCoreWindow
* core
, int req_x
, int req_y
, int req_w
, int req_h
)
143 req_h
= core
->height
;
145 if (req_w
!= core
->width
|| req_h
!= core
->height
) {
146 mask
|= CWWidth
| CWHeight
;
150 core
->height
= req_h
;
152 XConfigureWindow(dpy
, core
->window
, mask
, &xwc
);