From 4f6908feed54691d4b6e418fccde90c4ddfc1617 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Thu, 18 Sep 2003 07:43:33 +0000 Subject: [PATCH] add gnomepanelproxy --- Makefile.am | 13 ++- tools/gnome-panel-control/.cvsignore | 4 + tools/gnome-panel-control/Makefile | 4 + .../gnome-panel-control/gnome-panel-control.c | 100 ++++++++++++++++++ 4 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 tools/gnome-panel-control/.cvsignore create mode 100644 tools/gnome-panel-control/Makefile create mode 100644 tools/gnome-panel-control/gnome-panel-control.c diff --git a/Makefile.am b/Makefile.am index bda4fce8..8612a207 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,7 +26,8 @@ lib_LTLIBRARIES = \ bin_PROGRAMS = \ openbox/openbox \ - tools/kdetrayproxy/kdetrayproxy + tools/kdetrayproxy/kdetrayproxy \ + tools/gnomepanelproxy/gnomepanelproxy ## render ## @@ -201,6 +202,16 @@ tools_kdetrayproxy_kdetrayproxy_SOURCES = \ tools/kdetrayproxy/kdetrayproxy.c +## gnomepanelproxy ## + +tools_gnomepanelproxy_gnomepanelproxy_CPPFLAGS = \ + $(X_CFLAGS) +tools_gnomepanelproxy_gnomepanelproxy_LDADD = \ + $(X_LIBS) +tools_gnomepanelproxy_gnomepanelproxy_SOURCES = \ + tools/gnomepanelproxy/gnomepanelproxy.c + + ## themes ## allegro_themedir = $(themedir)/Allegro/openbox-3 diff --git a/tools/gnome-panel-control/.cvsignore b/tools/gnome-panel-control/.cvsignore new file mode 100644 index 00000000..190cf9eb --- /dev/null +++ b/tools/gnome-panel-control/.cvsignore @@ -0,0 +1,4 @@ +.deps +.dirstamp +.libs +gnomepanelproxy diff --git a/tools/gnome-panel-control/Makefile b/tools/gnome-panel-control/Makefile new file mode 100644 index 00000000..cfc46539 --- /dev/null +++ b/tools/gnome-panel-control/Makefile @@ -0,0 +1,4 @@ +all clean install: + $(MAKE) -C ../.. -$(MAKEFLAGS) $@ + +.PHONY: all clean install diff --git a/tools/gnome-panel-control/gnome-panel-control.c b/tools/gnome-panel-control/gnome-panel-control.c new file mode 100644 index 00000000..fe84a4f1 --- /dev/null +++ b/tools/gnome-panel-control/gnome-panel-control.c @@ -0,0 +1,100 @@ +#include +#include +#include +#include + +typedef enum +{ + NONE, + MAIN_MENU, + RUN_DIALOG +} Action; + +int main(int argc, char **argv) +{ + int i; + Action a = NONE; + + for (i = 1; i < argc; ++i) { + if (!strcmp(argv[i], "--help")) { + a = NONE; + break; + } + if (!strcmp(argv[i], "--main-menu")) { + a = MAIN_MENU; + break; + } + if (!strcmp(argv[i], "--run-dialog")) { + a = RUN_DIALOG; + break; + } + } + + if (!a) { + printf("Usage: gnomepanelproxy ACTION\n\n"); + printf("Actions:\n"); + printf(" --help Display this help and exit\n"); + printf(" --main-menu Show the main menu\n"); + printf(" --run-dialog Show the run dialog\n\n"); + return 0; + } + + { + Display *d; + Window root; + XClientMessageEvent ce; + Atom act_atom; + Time timestamp; + + d = XOpenDisplay(NULL); + if (!d) { + fprintf(stderr, + "Unable to open the X display specified by the DISPLAY " + "environment variable. Ensure you have permission to " + "connect to the display."); + return 1; + } + root = RootWindowOfScreen(DefaultScreenOfDisplay(d)); + + switch (a) { + case MAIN_MENU: + act_atom = XInternAtom(d, "_GNOME_PANEL_ACTION_MAIN_MENU", False); + break; + case RUN_DIALOG: + act_atom = XInternAtom(d, "_GNOME_PANEL_ACTION_RUN_DIALOG", False); + break; + default: + assert(0); + } + + /* Generate a timestamp */ + { + XEvent event; + Window win; + + win = XCreateSimpleWindow(d, root, 0, 0, 1, 1, 0, 0, 0); + + XSelectInput(d, win, PropertyChangeMask); + + XChangeProperty(d, win, act_atom, act_atom, 8, + PropModeAppend, NULL, 0); + XWindowEvent(d, win, PropertyChangeMask, &event); + + XDestroyWindow(d, win); + + timestamp = event.xproperty.time; + } + + ce.type = ClientMessage; + ce.window = root; + ce.message_type = XInternAtom(d, "_GNOME_PANEL_ACTION", False); + ce.format = 32; + ce.data.l[0] = act_atom; + ce.data.l[1] = timestamp; + XSendEvent(d, root, False, StructureNotifyMask, (XEvent*) &ce); + + XCloseDisplay(d); + } + + return 0; +} -- 2.39.2