114 lines
3.4 KiB
C
114 lines
3.4 KiB
C
/*
|
|
* Window Maker window manager
|
|
*
|
|
* Copyright (c) 1997-2003 Alfredo K. Kojima
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
*/
|
|
|
|
#include "wconfig.h"
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include "WindowMaker.h"
|
|
#include "backend/backend.h"
|
|
#include "wcore.h"
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
* wCoreCreateTopLevel--
|
|
* Creates a toplevel window used for icons, menus and dialogs.
|
|
*
|
|
* Returns:
|
|
* The created window.
|
|
*--------------------------------------------------------------------- */
|
|
WCoreWindow *wCoreCreateTopLevel(WScreen *screen, int x, int y, int width, int height, int bwidth, int depth, Visual *visual, WMNativeColormap colormap, WMPixel border_pixel)
|
|
{
|
|
WCoreWindow *core;
|
|
|
|
core = wmalloc(sizeof(WCoreWindow));
|
|
|
|
core->window = wm_backend->frame_create_toplevel(screen, x, y, width, height,
|
|
bwidth, depth, (void *)visual,
|
|
(unsigned long)colormap,
|
|
border_pixel);
|
|
core->width = width;
|
|
core->height = height;
|
|
core->screen_ptr = screen;
|
|
core->descriptor.self = core;
|
|
|
|
wm_backend->context_save(core->window, WM_CTX_CLIENT_WIN, &core->descriptor);
|
|
|
|
return core;
|
|
}
|
|
|
|
/*----------------------------------------------------------------------
|
|
* wCoreCreate--
|
|
* Creates a brand new child window.
|
|
* The window will have a border width of 0 and color is black.
|
|
*
|
|
* Returns:
|
|
* A initialized core window structure.
|
|
*
|
|
* Side effects:
|
|
* A window context for the created window is saved.
|
|
*
|
|
* Notes:
|
|
* The event mask is initialized to a default value.
|
|
*--------------------------------------------------------------------- */
|
|
WCoreWindow *wCoreCreate(WCoreWindow *parent, int x, int y, int width, int height)
|
|
{
|
|
WCoreWindow *core;
|
|
|
|
core = wmalloc(sizeof(WCoreWindow));
|
|
|
|
core->window = wm_backend->frame_create_child(parent->window, parent->screen_ptr,
|
|
x, y, width, height);
|
|
core->width = width;
|
|
core->height = height;
|
|
core->screen_ptr = parent->screen_ptr;
|
|
core->descriptor.self = core;
|
|
|
|
wm_backend->context_save(core->window, WM_CTX_CLIENT_WIN, &core->descriptor);
|
|
return core;
|
|
}
|
|
|
|
void wCoreDestroy(WCoreWindow * core)
|
|
{
|
|
if (core->stacking)
|
|
wfree(core->stacking);
|
|
|
|
wm_backend->context_delete(core->window, WM_CTX_CLIENT_WIN);
|
|
wm_backend->frame_destroy(core->screen_ptr, core->window);
|
|
wfree(core);
|
|
}
|
|
|
|
void wCoreConfigure(WCoreWindow * core, int req_x, int req_y, int req_w, int req_h)
|
|
{
|
|
if (req_w <= 0)
|
|
req_w = core->width;
|
|
|
|
if (req_h <= 0)
|
|
req_h = core->height;
|
|
|
|
if (req_w != core->width || req_h != core->height) {
|
|
core->width = req_w;
|
|
core->height = req_h;
|
|
}
|
|
|
|
wm_backend->frame_configure(core->window, req_x, req_y, req_w, req_h);
|
|
}
|