mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 20:38:08 +01:00
864 lines
23 KiB
Diff
864 lines
23 KiB
Diff
Description: This patch creates the wmlib folder. Is needed for libwmaker0-dev, used by wterm and fsviewer debian applications.
|
|
Author: Rodolfo García Peñas (kix) <kix@kix.es>
|
|
Last-Update: 2011-10-05
|
|
--- a/configure.ac
|
|
+++ b/configure.ac
|
|
@@ -636,6 +636,9 @@
|
|
fi
|
|
fi
|
|
|
|
+# for wmlib
|
|
+AC_SUBST(XCFLAGS)
|
|
+
|
|
AC_SUBST(XLFLAGS)
|
|
AC_SUBST(XLIBS)
|
|
AC_SUBST(X_EXTRA_LIBS)
|
|
@@ -866,7 +869,7 @@
|
|
WINGs/Makefile WINGs/WINGs/Makefile WINGs/Documentation/Makefile \
|
|
WINGs/Examples/Makefile WINGs/Resources/Makefile WINGs/Tests/Makefile \
|
|
WINGs/Extras/Makefile WINGs/po/Makefile \
|
|
- wrlib/Makefile wrlib/tests/Makefile \
|
|
+ wmlib/Makefile wrlib/Makefile wrlib/tests/Makefile \
|
|
src/Makefile src/wconfig.h \
|
|
doc/Makefile doc/sk/Makefile doc/cs/Makefile \
|
|
doc/ru/Makefile \
|
|
--- /dev/null
|
|
+++ b/wmlib/app.c
|
|
@@ -0,0 +1,79 @@
|
|
+/* app.c - application context stuff
|
|
+ *
|
|
+ * WMlib - WindowMaker application programming interface
|
|
+ *
|
|
+ * Copyright (C) 1997-2003 Alfredo K. Kojima
|
|
+ *
|
|
+ * 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.
|
|
+ *
|
|
+ * 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.
|
|
+ *
|
|
+ * 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>
|
|
+
|
|
+#include "WMaker.h"
|
|
+#include "app.h"
|
|
+
|
|
+WMAppContext *WMAppCreateWithMain(Display * display, int screen_number, Window main_window)
|
|
+{
|
|
+ wmAppContext *ctx;
|
|
+
|
|
+ ctx = malloc(sizeof(wmAppContext));
|
|
+ if (!ctx)
|
|
+ return NULL;
|
|
+
|
|
+ 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) {
|
|
+ free(ctx);
|
|
+ return NULL;
|
|
+ }
|
|
+ ctx->win_count = 1;
|
|
+ ctx->windows[0] = main_window;
|
|
+
|
|
+ ctx->main_menu = NULL;
|
|
+
|
|
+ ctx->last_menu_tag = 100;
|
|
+
|
|
+ return ctx;
|
|
+}
|
|
+
|
|
+int WMAppAddWindow(WMAppContext * app, Window window)
|
|
+{
|
|
+ Window *win;
|
|
+
|
|
+ win = malloc(sizeof(Window) * (app->win_count + 1));
|
|
+ if (!win)
|
|
+ return False;
|
|
+
|
|
+ memcpy(win, app->windows, sizeof(Window) * app->win_count);
|
|
+
|
|
+ free(app->windows);
|
|
+
|
|
+ win[app->win_count] = window;
|
|
+ app->windows = win;
|
|
+ app->win_count++;
|
|
+
|
|
+ return True;
|
|
+}
|
|
+
|
|
+int WMAppSetMainMenu(WMAppContext * app, WMMenu * menu)
|
|
+{
|
|
+ app->main_menu = menu;
|
|
+ return True;
|
|
+}
|
|
--- /dev/null
|
|
+++ b/wmlib/app.h
|
|
@@ -0,0 +1,40 @@
|
|
+/* app.h - private declarations for application context
|
|
+ *
|
|
+ * WMlib - WindowMaker application programming interface
|
|
+ *
|
|
+ * Copyright (C) 1997-2003 Alfredo K. Kojima
|
|
+ *
|
|
+ * 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.
|
|
+ *
|
|
+ * 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.
|
|
+ *
|
|
+ * 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.
|
|
+ */
|
|
+
|
|
+#ifndef _APP_H_
|
|
+#define _APP_H_
|
|
+
|
|
+typedef struct _wmAppContext {
|
|
+ Display *dpy;
|
|
+ int screen_number;
|
|
+
|
|
+ int our_leader_hint; /* if app leader hint was set by us */
|
|
+ Window main_window; /* main window of the application */
|
|
+ Window *windows;
|
|
+ int win_count; /* size of windows array */
|
|
+
|
|
+ WMMenu *main_menu;
|
|
+
|
|
+ int last_menu_tag;
|
|
+} wmAppContext;
|
|
+
|
|
+#endif
|
|
+
|
|
--- /dev/null
|
|
+++ b/wmlib/command.c
|
|
@@ -0,0 +1,74 @@
|
|
+/* command.c - WindowMaker commands
|
|
+ *
|
|
+ * WMlib - WindowMaker application programming interface
|
|
+ *
|
|
+ * Copyright (C) 1997-2003 Alfredo K. Kojima
|
|
+ *
|
|
+ * 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.
|
|
+ *
|
|
+ * 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.
|
|
+ *
|
|
+ * 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 "WMaker.h"
|
|
+#include "app.h"
|
|
+
|
|
+static Atom getwmfunc(Display * dpy)
|
|
+{
|
|
+ return XInternAtom(dpy, "_WINDOWMAKER_WM_FUNCTION", False);
|
|
+}
|
|
+
|
|
+void WMHideApplication(WMAppContext * app)
|
|
+{
|
|
+ XEvent event;
|
|
+
|
|
+ event.xclient.type = ClientMessage;
|
|
+ event.xclient.message_type = getwmfunc(app->dpy);
|
|
+ event.xclient.format = 32;
|
|
+ event.xclient.display = app->dpy;
|
|
+ event.xclient.window = app->main_window;
|
|
+ event.xclient.data.l[0] = WMFHideApplication;
|
|
+ event.xclient.data.l[1] = 0;
|
|
+ event.xclient.data.l[2] = 0;
|
|
+ event.xclient.data.l[3] = 0;
|
|
+ XSendEvent(app->dpy, RootWindow(app->dpy, app->screen_number), False,
|
|
+ SubstructureNotifyMask | SubstructureRedirectMask, &event);
|
|
+}
|
|
+
|
|
+void WMHideOthers(WMAppContext * app)
|
|
+{
|
|
+ XEvent event;
|
|
+
|
|
+ event.xclient.type = ClientMessage;
|
|
+ event.xclient.message_type = getwmfunc(app->dpy);
|
|
+ event.xclient.format = 32;
|
|
+ event.xclient.display = app->dpy;
|
|
+ event.xclient.window = app->main_window;
|
|
+ event.xclient.data.l[0] = WMFHideOtherApplications;
|
|
+ event.xclient.data.l[1] = 0;
|
|
+ event.xclient.data.l[2] = 0;
|
|
+ event.xclient.data.l[3] = 0;
|
|
+ XSendEvent(app->dpy, RootWindow(app->dpy, app->screen_number), False,
|
|
+ SubstructureNotifyMask | SubstructureRedirectMask, &event);
|
|
+}
|
|
+
|
|
+void WMSetWindowAttributes(Display * dpy, Window window, GNUstepWMAttributes * attributes)
|
|
+{
|
|
+ Atom atom;
|
|
+
|
|
+ atom = XInternAtom(dpy, "_GNUSTEP_WM_ATTR", False);
|
|
+ XChangeProperty(dpy, window, atom, atom, 32, PropModeReplace,
|
|
+ (unsigned char *)attributes, sizeof(GNUstepWMAttributes) / sizeof(CARD32));
|
|
+}
|
|
--- /dev/null
|
|
+++ b/wmlib/event.c
|
|
@@ -0,0 +1,86 @@
|
|
+/* event.c - WindowMaker event handler
|
|
+ *
|
|
+ * WMlib - WindowMaker application programming interface
|
|
+ *
|
|
+ * Copyright (C) 1997-2003 Alfredo K. Kojima
|
|
+ *
|
|
+ * 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.
|
|
+ *
|
|
+ * 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.
|
|
+ *
|
|
+ * 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 <stdlib.h>
|
|
+#include <stdio.h>
|
|
+#include <X11/Xlib.h>
|
|
+#include <X11/Xutil.h>
|
|
+
|
|
+#include "WMaker.h"
|
|
+#include "app.h"
|
|
+#include "menu.h"
|
|
+
|
|
+static Atom _XA_WINDOWMAKER_MENU = 0;
|
|
+
|
|
+enum {
|
|
+ wmSelectItem = 1
|
|
+};
|
|
+
|
|
+static wmMenuEntry *findEntry(WMMenu * menu, int tag)
|
|
+{
|
|
+ wmMenuEntry *entry = menu->first;
|
|
+
|
|
+ while (entry) {
|
|
+ if (entry->tag == tag) {
|
|
+ return entry;
|
|
+ }
|
|
+ if (entry->cascade) {
|
|
+ wmMenuEntry *tmp;
|
|
+ tmp = findEntry(entry->cascade, tag);
|
|
+ if (tmp)
|
|
+ return tmp;
|
|
+ }
|
|
+ entry = entry->next;
|
|
+ }
|
|
+ return NULL;
|
|
+}
|
|
+
|
|
+static void wmHandleMenuEvents(WMAppContext * app, XEvent * event)
|
|
+{
|
|
+ wmMenuEntry *entry;
|
|
+
|
|
+ switch (event->xclient.data.l[1]) {
|
|
+ case wmSelectItem:
|
|
+ entry = findEntry(app->main_menu, event->xclient.data.l[2]);
|
|
+ if (entry && entry->callback) {
|
|
+ (*entry->callback) (entry->clientData, event->xclient.data.l[2], event->xclient.data.l[0]);
|
|
+ }
|
|
+ break;
|
|
+ }
|
|
+}
|
|
+
|
|
+int WMProcessEvent(WMAppContext * app, XEvent * event)
|
|
+{
|
|
+ int proc = False;
|
|
+ if (!_XA_WINDOWMAKER_MENU) {
|
|
+ _XA_WINDOWMAKER_MENU = XInternAtom(app->dpy, "_WINDOWMAKER_MENU", False);
|
|
+ }
|
|
+ switch (event->type) {
|
|
+ case ClientMessage:
|
|
+ if (event->xclient.format == 32
|
|
+ && event->xclient.message_type == _XA_WINDOWMAKER_MENU
|
|
+ && event->xclient.window == app->main_window) {
|
|
+ wmHandleMenuEvents(app, event);
|
|
+ proc = True;
|
|
+ }
|
|
+ }
|
|
+ return proc;
|
|
+}
|
|
--- /dev/null
|
|
+++ b/wmlib/Makefile.am
|
|
@@ -0,0 +1,51 @@
|
|
+
|
|
+AUTOMAKE_OPTIONS = no-dependencies
|
|
+
|
|
+libWMaker_la_LDFLAGS = -version-info 1:1:0
|
|
+lib_LTLIBRARIES = libWMaker.la
|
|
+
|
|
+include_HEADERS = WMaker.h
|
|
+
|
|
+INCLUDES = $(DFLAGS) @XCFLAGS@
|
|
+
|
|
+libWMaker_a_AR = $(QUIET_AR) $(AR) $(ARFLAGS)
|
|
+
|
|
+libWMaker_la_SOURCES = \
|
|
+ menu.c \
|
|
+ app.c \
|
|
+ event.c \
|
|
+ command.c \
|
|
+ app.h \
|
|
+ menu.h
|
|
+
|
|
+DISTCLEANFILES = wmlib.pc
|
|
+
|
|
+wmlib.pc: Makefile
|
|
+ @echo "Generating $@"
|
|
+ @echo 'Name: wmlib' > $@
|
|
+ @echo 'Description: WindowMaker library' >> $@
|
|
+ @echo 'Version: $(VERSION)' >> $@
|
|
+ @echo 'Requires: wrlib' >> $@
|
|
+ @echo 'Libs: $(lib_search_path) -lWUtil $(NETLIBS) $(INTLIBS) >> $@
|
|
+ @echo 'Cflags: $(inc_search_path)' >> $@
|
|
+
|
|
+install-exec-local:
|
|
+ @$(NORMAL_INSTALL)
|
|
+ $(mkinstalldirs) $(DESTDIR)$(libdir)/pkgconfig
|
|
+ @list='wmlib.pc'; for p in $$list; do \
|
|
+ if test -f $$p; then \
|
|
+ echo "$(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/pkgconfig/"; \
|
|
+ $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/pkgconfig/; \
|
|
+ else :; fi; \
|
|
+ done
|
|
+
|
|
+LIBTOOL = $(SHELL) $(top_srcdir)/libtool $(LIBTOOL_ARG)
|
|
+
|
|
+.c.o:
|
|
+ $(QUIET)$(COMPILE) -c $<
|
|
+
|
|
+.c.obj:
|
|
+ $(QUIET)$(COMPILE) -c `$(CYGPATH_W) '$<'`
|
|
+
|
|
+.c.lo:
|
|
+ $(QUIET)$(LTCOMPILE) -c -o $@ $<
|
|
--- /dev/null
|
|
+++ b/wmlib/menu.c
|
|
@@ -0,0 +1,238 @@
|
|
+/* menu.c - menu interface functions
|
|
+ *
|
|
+ * WMlib - WindowMaker application programming interface
|
|
+ *
|
|
+ * Copyright (C) 1997-2003 Alfredo K. Kojima
|
|
+ *
|
|
+ * 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.
|
|
+ *
|
|
+ * 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.
|
|
+ *
|
|
+ * 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 <stdlib.h>
|
|
+#include <stdio.h>
|
|
+#include <string.h>
|
|
+#include <X11/Xlib.h>
|
|
+#include <X11/Xutil.h>
|
|
+
|
|
+#include "WMaker.h"
|
|
+#include "app.h"
|
|
+#include "menu.h"
|
|
+
|
|
+WMMenu *WMMenuCreate(WMAppContext * app, char *title)
|
|
+{
|
|
+ wmMenu *menu;
|
|
+
|
|
+ if (strlen(title) > 255)
|
|
+ return NULL;
|
|
+
|
|
+ menu = malloc(sizeof(wmMenu));
|
|
+ if (!menu)
|
|
+ return NULL;
|
|
+
|
|
+ menu->appcontext = app;
|
|
+ menu->parent = NULL;
|
|
+ menu->title = title;
|
|
+ menu->entries = NULL;
|
|
+ menu->first = NULL;
|
|
+
|
|
+ menu->realized = False;
|
|
+ menu->code = app->last_menu_tag++;
|
|
+
|
|
+ menu->entryline = malloc(strlen(title) + 32);
|
|
+ menu->entryline2 = malloc(32);
|
|
+ if (!menu->entryline || !menu->entryline2) {
|
|
+ if (menu->entryline)
|
|
+ free(menu->entryline);
|
|
+ free(menu);
|
|
+ return NULL;
|
|
+ }
|
|
+ sprintf(menu->entryline, "%i %i %s", wmBeginMenu, menu->code, title);
|
|
+ sprintf(menu->entryline2, "%i %i", wmEndMenu, menu->code);
|
|
+ return menu;
|
|
+}
|
|
+
|
|
+int
|
|
+WMMenuAddItem(WMMenu * menu, char *text, WMMenuAction action,
|
|
+ void *clientData, WMFreeFunction freedata, char *rtext)
|
|
+{
|
|
+ wmMenuEntry *entry;
|
|
+
|
|
+ /* max size of right side text */
|
|
+ if (rtext && strlen(rtext) > 4)
|
|
+ return -1;
|
|
+
|
|
+ /* max size of menu text */
|
|
+ if (strlen(text) > 255)
|
|
+ return -1;
|
|
+
|
|
+ entry = malloc(sizeof(wmMenuEntry));
|
|
+ if (!entry)
|
|
+ return -1;
|
|
+
|
|
+ entry->entryline = malloc(strlen(text) + 100);
|
|
+ if (!entry->entryline) {
|
|
+ free(menu);
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ if (menu->entries)
|
|
+ entry->order = menu->entries->order + 1;
|
|
+ else {
|
|
+ entry->order = 0;
|
|
+ menu->first = entry;
|
|
+ }
|
|
+ entry->next = NULL;
|
|
+ entry->prev = menu->entries;
|
|
+ if (menu->entries)
|
|
+ menu->entries->next = entry;
|
|
+ menu->entries = entry;
|
|
+
|
|
+ entry->menu = menu;
|
|
+ entry->text = text;
|
|
+ entry->shortcut = rtext;
|
|
+ entry->callback = action;
|
|
+ entry->clientData = clientData;
|
|
+ entry->free = freedata;
|
|
+ entry->tag = menu->appcontext->last_menu_tag++;
|
|
+ entry->cascade = NULL;
|
|
+ entry->enabled = True;
|
|
+
|
|
+ if (!rtext)
|
|
+ sprintf(entry->entryline, "%i %i %i %i %s", wmNormalItem, menu->code, entry->tag, True, text);
|
|
+ else
|
|
+ sprintf(entry->entryline, "%i %i %i %i %s %s", wmDoubleItem,
|
|
+ menu->code, entry->tag, True, rtext, text);
|
|
+ return entry->tag;
|
|
+}
|
|
+
|
|
+int WMMenuAddSubmenu(WMMenu * menu, char *text, WMMenu * submenu)
|
|
+{
|
|
+ wmMenuEntry *entry;
|
|
+
|
|
+ /* max size of menu text */
|
|
+ if (strlen(text) > 255)
|
|
+ return -1;
|
|
+
|
|
+ entry = malloc(sizeof(wmMenuEntry));
|
|
+ if (!entry)
|
|
+ return -1;
|
|
+
|
|
+ entry->entryline = malloc(strlen(text) + 100);
|
|
+ if (!entry->entryline) {
|
|
+ free(menu);
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ if (menu->entries)
|
|
+ entry->order = menu->entries->order + 1;
|
|
+ else {
|
|
+ entry->order = 0;
|
|
+ menu->first = entry;
|
|
+ }
|
|
+ entry->next = NULL;
|
|
+ entry->prev = menu->entries;
|
|
+ if (menu->entries)
|
|
+ menu->entries->next = entry;
|
|
+ menu->entries = entry;
|
|
+ entry->menu = menu;
|
|
+ entry->text = text;
|
|
+ entry->shortcut = NULL;
|
|
+ entry->callback = NULL;
|
|
+ entry->clientData = NULL;
|
|
+ entry->tag = menu->appcontext->last_menu_tag++;
|
|
+ entry->cascade = submenu;
|
|
+ entry->enabled = True;
|
|
+
|
|
+ sprintf(entry->entryline, "%i %i %i %i %i %s", wmSubmenuItem,
|
|
+ menu->code, entry->tag, True, submenu->code, text);
|
|
+ return entry->tag;
|
|
+}
|
|
+
|
|
+static int countItems(WMMenu * menu)
|
|
+{
|
|
+ wmMenuEntry *entry = menu->first;
|
|
+ int c;
|
|
+
|
|
+ c = 1;
|
|
+ while (entry) {
|
|
+ c++;
|
|
+ if (entry->cascade) {
|
|
+ c += countItems(entry->cascade);
|
|
+ }
|
|
+ entry = entry->next;
|
|
+ }
|
|
+ c++;
|
|
+ return c;
|
|
+}
|
|
+
|
|
+static void addItems(char **slist, int *index, WMMenu * menu)
|
|
+{
|
|
+ wmMenuEntry *entry = menu->first;
|
|
+
|
|
+ slist[(*index)++] = menu->entryline;
|
|
+ while (entry) {
|
|
+ slist[(*index)++] = entry->entryline;
|
|
+ if (entry->cascade) {
|
|
+ addItems(slist, index, entry->cascade);
|
|
+ }
|
|
+ entry = entry->next;
|
|
+ }
|
|
+ slist[(*index)++] = menu->entryline2;
|
|
+}
|
|
+
|
|
+static Atom getatom(Display * dpy)
|
|
+{
|
|
+ static Atom atom = 0;
|
|
+
|
|
+ if (atom == 0) {
|
|
+ atom = XInternAtom(dpy, WMMENU_PROPNAME, False);
|
|
+ }
|
|
+ return atom;
|
|
+}
|
|
+
|
|
+int WMRealizeMenus(WMAppContext * app)
|
|
+{
|
|
+ int i, count;
|
|
+ char **slist;
|
|
+ XTextProperty text_prop;
|
|
+
|
|
+ if (!app->main_menu)
|
|
+ return False;
|
|
+
|
|
+ /* first count how many menu items there are */
|
|
+ count = countItems(app->main_menu);
|
|
+ if (count == 0)
|
|
+ return True;
|
|
+
|
|
+ count++;
|
|
+ slist = malloc(count * sizeof(char *));
|
|
+ if (!slist) {
|
|
+ return False;
|
|
+ }
|
|
+
|
|
+ slist[0] = "WMMenu 0";
|
|
+ i = 1;
|
|
+ addItems(slist, &i, app->main_menu);
|
|
+
|
|
+ if (!XStringListToTextProperty(slist, i, &text_prop)) {
|
|
+ free(slist);
|
|
+ return False;
|
|
+ }
|
|
+ free(slist);
|
|
+ XSetTextProperty(app->dpy, app->main_window, &text_prop, getatom(app->dpy));
|
|
+
|
|
+ XFree(text_prop.value);
|
|
+
|
|
+ return True;
|
|
+}
|
|
--- /dev/null
|
|
+++ b/wmlib/menu.h
|
|
@@ -0,0 +1,75 @@
|
|
+/* menu.h - private menu declarations
|
|
+ *
|
|
+ * WMlib - WindowMaker application programming interface
|
|
+ *
|
|
+ * Copyright (C) 1997-2003 Alfredo K. Kojima
|
|
+ *
|
|
+ * 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.
|
|
+ *
|
|
+ * 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.
|
|
+ *
|
|
+ * 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.
|
|
+ */
|
|
+
|
|
+#ifndef _MENU_H_
|
|
+#define _MENU_H_
|
|
+
|
|
+#define WMMENU_PROPNAME "_WINDOWMAKER_MENU"
|
|
+
|
|
+typedef struct _wmMenuEntry {
|
|
+ struct _wmMenuEntry *next;
|
|
+ struct _wmMenuEntry *prev;
|
|
+
|
|
+ struct _wmMenu *menu; /* menu for the entry */
|
|
+
|
|
+ char *text; /* entry text */
|
|
+ char *shortcut;
|
|
+ WMMenuAction callback;
|
|
+ void *clientData; /* data to pass to callback */
|
|
+ WMFreeFunction free; /* function to free clientData */
|
|
+ int tag; /* unique entry ID */
|
|
+
|
|
+ struct _wmMenu *cascade; /* cascade menu */
|
|
+ short order;
|
|
+ short enabled; /* entry is selectable */
|
|
+
|
|
+ char *entryline;
|
|
+} wmMenuEntry;
|
|
+
|
|
+
|
|
+typedef struct _wmMenu {
|
|
+ wmAppContext *appcontext;
|
|
+ int code;
|
|
+
|
|
+ struct _wmMenu *parent;
|
|
+
|
|
+ char *title; /* menu title */
|
|
+ wmMenuEntry *entries; /* list of entries */
|
|
+ wmMenuEntry *first; /* first of list of entries */
|
|
+ int realized;
|
|
+
|
|
+ char *entryline;
|
|
+ char *entryline2;
|
|
+} wmMenu;
|
|
+
|
|
+
|
|
+
|
|
+enum {
|
|
+ wmBeginMenu = 1,
|
|
+ wmEndMenu = 2,
|
|
+ wmNormalItem = 10,
|
|
+ wmDoubleItem = 11,
|
|
+ wmSubmenuItem = 12
|
|
+};
|
|
+
|
|
+
|
|
+#endif
|
|
+
|
|
--- /dev/null
|
|
+++ b/wmlib/WMaker.h
|
|
@@ -0,0 +1,161 @@
|
|
+/*
|
|
+ * WindowMaker interface definitions
|
|
+ *
|
|
+ * Copyright (C) 1997-2003 Alfredo K. Kojima
|
|
+ *
|
|
+ * 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.
|
|
+ *
|
|
+ * 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.
|
|
+ *
|
|
+ * 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.
|
|
+ */
|
|
+
|
|
+#ifndef _WMLIB_H_
|
|
+#define _WMLIB_H_
|
|
+
|
|
+/* the definitions in this file can change at any time. WINGs has more
|
|
+ * stable definitions */
|
|
+
|
|
+#include <X11/Xlib.h>
|
|
+#include <X11/Xmd.h>
|
|
+
|
|
+#ifdef __cplusplus
|
|
+extern "C" {
|
|
+#endif /* __cplusplus */
|
|
+
|
|
+typedef struct {
|
|
+ CARD32 flags;
|
|
+ CARD32 window_style;
|
|
+ CARD32 window_level;
|
|
+ CARD32 reserved;
|
|
+ Pixmap miniaturize_pixmap; /* pixmap for miniaturize button */
|
|
+ Pixmap close_pixmap; /* pixmap for close button */
|
|
+ Pixmap miniaturize_mask; /* miniaturize pixmap mask */
|
|
+ Pixmap close_mask; /* close pixmap mask */
|
|
+ CARD32 extra_flags;
|
|
+} GNUstepWMAttributes;
|
|
+
|
|
+#define GSWindowStyleAttr (1<<0)
|
|
+#define GSWindowLevelAttr (1<<1)
|
|
+#define GSMiniaturizePixmapAttr (1<<3)
|
|
+#define GSClosePixmapAttr (1<<4)
|
|
+#define GSMiniaturizeMaskAttr (1<<5)
|
|
+#define GSCloseMaskAttr (1<<6)
|
|
+#define GSExtraFlagsAttr (1<<7)
|
|
+
|
|
+
|
|
+
|
|
+#define GSClientResizeFlag (1<<0)
|
|
+#define GSFullKeyboardEventsFlag (1<<1)
|
|
+#define GSMenuWindowFlag (1<<2)
|
|
+#define GSIconWindowFlag (1<<3)
|
|
+#define GSSkipWindowListFlag (1<<4)
|
|
+#define GSNoApplicationIconFlag (1<<5)
|
|
+#define GSDarkGrayTitlebarFlag (1<<8)
|
|
+
|
|
+
|
|
+#define WMFHideOtherApplications 10
|
|
+#define WMFHideApplication 12
|
|
+
|
|
+
|
|
+#ifndef _DEFINED_GNUSTEP_WINDOW_INFO
|
|
+#define _DEFINED_GNUSTEP_WINDOW_INFO
|
|
+/*
|
|
+ * Window levels are taken from GNUstep (gui/AppKit/NSWindow.h)
|
|
+ * NSDesktopWindowLevel intended to be the level at which things
|
|
+ * on the desktop sit ... so you should be able
|
|
+ * to put a desktop background just below it.
|
|
+ *
|
|
+ * Applications are actually permitted to use any value in the
|
|
+ * range INT_MIN+1 to INT_MAX
|
|
+ */
|
|
+enum {
|
|
+ WMDesktopWindowLevel = -1000, /* GNUstep addition */
|
|
+ WMNormalWindowLevel = 0,
|
|
+ WMFloatingWindowLevel = 3,
|
|
+ WMSubmenuWindowLevel = 3,
|
|
+ WMTornOffMenuWindowLevel = 3,
|
|
+ WMMainMenuWindowLevel = 20,
|
|
+ WMDockWindowLevel = 21, /* Deprecated - use NSStatusWindowLevel */
|
|
+ WMStatusWindowLevel = 21,
|
|
+ WMModalPanelWindowLevel = 100,
|
|
+ WMPopUpMenuWindowLevel = 101,
|
|
+ WMScreenSaverWindowLevel = 1000
|
|
+};
|
|
+
|
|
+
|
|
+/* window attributes */
|
|
+enum {
|
|
+ WMBorderlessWindowMask = 0,
|
|
+ WMTitledWindowMask = 1,
|
|
+ WMClosableWindowMask = 2,
|
|
+ WMMiniaturizableWindowMask = 4,
|
|
+ WMResizableWindowMask = 8,
|
|
+ WMIconWindowMask = 64,
|
|
+ WMMiniWindowMask = 128
|
|
+};
|
|
+#endif
|
|
+
|
|
+typedef struct _wmAppContext WMAppContext;
|
|
+
|
|
+typedef struct _wmMenu WMMenu;
|
|
+
|
|
+typedef void (*WMMenuAction)(void *clientdata, int code, Time timestamp);
|
|
+
|
|
+typedef void (*WMFreeFunction)(void *clientdata);
|
|
+
|
|
+int WMProcessEvent(WMAppContext *app, XEvent *event);
|
|
+
|
|
+
|
|
+WMAppContext *WMAppCreateWithMain(Display *display, int screen_number,
|
|
+ Window main_window);
|
|
+
|
|
+WMAppContext *WMAppCreate(Display *display, int screen_number);
|
|
+
|
|
+int WMAppAddWindow(WMAppContext *app, Window window);
|
|
+
|
|
+int WMAppSetMainMenu(WMAppContext *app, WMMenu *menu);
|
|
+
|
|
+
|
|
+int WMRealizeMenus(WMAppContext *app);
|
|
+
|
|
+
|
|
+void WMSetWindowAttributes(Display *dpy, Window window,
|
|
+ GNUstepWMAttributes *attributes);
|
|
+
|
|
+
|
|
+void WMHideApplication(WMAppContext *app);
|
|
+void WMHideOthers(WMAppContext *app);
|
|
+
|
|
+/*
|
|
+ * WARNING: the menu related functions might be removed in the future.
|
|
+ */
|
|
+WMMenu *WMMenuCreate(WMAppContext *app, char *title);
|
|
+
|
|
+int WMMenuAddItem(WMMenu *menu, char *text, WMMenuAction action,
|
|
+ void *clientData, WMFreeFunction freedata, char *rtext);
|
|
+
|
|
+int WMMenuInsertItem(WMMenu *menu, int index, char *text,
|
|
+ WMMenuAction *action, char *rtext);
|
|
+
|
|
+int WMMenuRemoveItem(WMMenu *menu, int index);
|
|
+
|
|
+int WMMenuAddSubmenu(WMMenu *menu, char *title, WMMenu *submenu);
|
|
+
|
|
+void WMMenuSetEnabled(WMMenu *menu, int index, int enabled);
|
|
+
|
|
+void WMMenuDestroy(WMMenu *menu, int submenus);
|
|
+
|
|
+#ifdef __cplusplus
|
|
+}
|
|
+#endif /* __cplusplus */
|
|
+
|
|
+#endif
|
|
--- a/Makefile.am
|
|
+++ b/Makefile.am
|
|
@@ -31,7 +31,7 @@
|
|
|
|
ACLOCAL_AMFLAGS = -I m4
|
|
|
|
-SUBDIRS = wrlib WINGs src util po WindowMaker WPrefs.app doc
|
|
+SUBDIRS = wrlib WINGs src util po WindowMaker wmlib WPrefs.app doc
|
|
|
|
EXTRA_DIST = TODO BUGS BUGFORM FAQ FAQ.I18N INSTALL \
|
|
INSTALL-WMAKER README.definable-cursor \
|