Files
wmaker/wmlib/app.c
T

88 lines
2.0 KiB
C
Raw Normal View History

1998-09-29 22:36:29 +00:00
/* app.c - application context stuff
2004-10-12 21:28:27 +00:00
*
1998-09-29 22:36:29 +00:00
* WMlib - WindowMaker application programming interface
2004-10-12 21:28:27 +00:00
*
2003-01-16 23:30:45 +00:00
* Copyright (C) 1997-2003 Alfredo K. Kojima
2004-10-12 21:28:27 +00:00
*
1998-09-29 22:36:29 +00:00
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
2004-10-12 21:28:27 +00:00
*
1998-09-29 22:36:29 +00:00
* This library 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
* Library General Public License for more details.
2004-10-12 21:28:27 +00:00
*
1998-09-29 22:36:29 +00:00
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <X11/Xlib.h>
#include <stdlib.h>
#include <string.h>
1998-09-29 22:36:29 +00:00
#include "WMaker.h"
#include "app.h"
WMAppContext*
WMAppCreateWithMain(Display *display, int screen_number, Window main_window)
{
wmAppContext *ctx;
2004-10-12 21:28:27 +00:00
1998-09-29 22:36:29 +00:00
ctx = malloc(sizeof(wmAppContext));
if (!ctx)
2004-10-12 21:28:27 +00:00
return NULL;
1998-09-29 22:36:29 +00:00
ctx->dpy = display;
ctx->screen_number = screen_number;
ctx->our_leader_hint = False;
ctx->main_window = main_window;
ctx->windows = malloc(sizeof(Window));
if (!ctx->windows) {
2004-10-12 21:28:27 +00:00
free(ctx);
return NULL;
1998-09-29 22:36:29 +00:00
}
ctx->win_count = 1;
ctx->windows[0] = main_window;
ctx->main_menu = NULL;
2004-10-12 21:28:27 +00:00
1998-09-29 22:36:29 +00:00
ctx->last_menu_tag = 100;
return ctx;
}
2004-10-12 21:28:27 +00:00
int
1998-09-29 22:36:29 +00:00
WMAppAddWindow(WMAppContext *app, Window window)
{
Window *win;
2004-10-12 21:28:27 +00:00
1998-09-29 22:36:29 +00:00
win = malloc(sizeof(Window)*(app->win_count+1));
if (!win)
2004-10-12 21:28:27 +00:00
return False;
1998-09-29 22:36:29 +00:00
memcpy(win, app->windows, sizeof(Window)*app->win_count);
1999-03-09 14:58:01 +00:00
free(app->windows);
1998-09-29 22:36:29 +00:00
win[app->win_count] = window;
app->windows = win;
app->win_count++;
return True;
}
2004-10-12 21:28:27 +00:00
int
1998-09-29 22:36:29 +00:00
WMAppSetMainMenu(WMAppContext *app, WMMenu *menu)
{
app->main_menu = menu;
return True;
}