engines/Makefile
engines/openbox/Makefile
plugins/Makefile
+ plugins/keyboard/Makefile
doc/Makefile
doc/doxygen/Makefile
data/Makefile
screen_update_struts();
- dispatch_client(Event_Client_New, client);
+ dispatch_client(Event_Client_New, client, 0, 0);
client_showhide(client);
- dispatch_client(Event_Client_Mapped, client);
+ dispatch_client(Event_Client_Mapped, client, 0, 0);
/* grab all mouse bindings */
/*pointer_grab_all(client, TRUE);XXX*/
g_message("Unmanaging window: %lx", client->window);
- dispatch_client(Event_Client_Destroy, client);
+ dispatch_client(Event_Client_Destroy, client, 0, 0);
/* remove the window from our save set */
XChangeSaveSet(ob_display, client->window, SetModeDelete);
/* fire the urgent callback if we're mapped, otherwise, wait until
after we're mapped */
if (self->frame)
- dispatch_client(Event_Client_Urgent, self);
+ dispatch_client(Event_Client_Urgent, self, self->urgent, 0);
}
}
engine_frame_show(self->frame);
else
engine_frame_hide(self->frame);
-
- dispatch_client(Event_Client_Visible, self);
}
gboolean client_normal(Client *self) {
client_shade(self, TRUE);
}
if (self->urgent)
- dispatch_client(Event_Client_Urgent, self);
+ dispatch_client(Event_Client_Urgent, self, self->urgent, 0);
if (self->max_vert && self->max_horz) {
self->max_vert = self->max_horz = FALSE;
XSendEvent(ob_display, self->window, FALSE, NoEventMask, &ce);
}
-void client_set_desktop(Client *self, unsigned int target)
+void client_set_desktop(Client *self, guint target)
{
+ guint old;
+
if (target == self->desktop) return;
g_message("Setting desktop %u\n", target);
target == DESKTOP_ALL))
return;
+ old = self->desktop;
self->desktop = target;
PROP_SET32(self->window, net_wm_desktop, cardinal, target);
/* the frame can display the current desktop state */
/* 'move' the window to the new desktop */
client_showhide(self);
screen_update_struts();
+
+ dispatch_client(Event_Client_Desktop, self, target, old);
}
static Client *search_modal_tree(Client *node, Client *skip)
void client_close(Client *self);
/*! Sends the window to the specified desktop */
-void client_set_desktop(Client *self, unsigned int target);
+void client_set_desktop(Client *self, guint target);
/*! Return a modal child of the client window
@return A modal child of the client window, or 0 if none was found.
}
}
-void dispatch_client(EventType e, Client *c)
+void dispatch_client(EventType e, Client *c, int num0, int num1)
{
guint i;
GSList *it;
g_assert(c != NULL);
obe.type = e;
- obe.data.client = c;
+ obe.data.c.client = c;
+ obe.data.c.num[0] = num0;
+ obe.data.c.num[1] = num1;
i = 0;
while (e > 1) {
}
}
-void dispatch_ob(EventType e)
+void dispatch_ob(EventType e, int num0, int num1)
{
guint i;
GSList *it;
ObEvent obe;
obe.type = e;
+ obe.data.o.num[0] = num0;
+ obe.data.o.num[1] = num1;
i = 0;
while (e > 1) {
ObEvent obe;
obe.type = e;
- obe.data.signal = signal;
+ obe.data.s.signal = signal;
i = 0;
while (e > 1) {
Event_Client_Focus = 1 << 11, /* focused */
Event_Client_Unfocus = 1 << 12, /* unfocused */
Event_Client_Urgent = 1 << 13, /* entered/left urgent state */
- Event_Client_Visible = 1 << 14, /* shown/hidden (not on a workspace or
- show-the-desktop change though) */
+ Event_Client_Desktop = 1 << 15, /* moved to a new desktop */
- Event_Ob_Desktop = 1 << 15, /* changed desktops */
- Event_Ob_NumDesktops = 1 << 16, /* changed the number of desktops */
- Event_Ob_ShowDesktop = 1 << 17, /* entered/left show-the-desktop mode */
+ Event_Ob_Desktop = 1 << 16, /* changed desktops */
+ Event_Ob_NumDesktops = 1 << 17, /* changed the number of desktops */
+ Event_Ob_ShowDesktop = 1 << 18, /* entered/left show-the-desktop mode */
- Event_Signal = 1 << 18, /* a signal from the OS */
+ Event_Signal = 1 << 19, /* a signal from the OS */
- EVENT_RANGE = 1 << 19
+ EVENT_RANGE = 1 << 20
} EventType;
typedef struct {
Client *client;
} EventData_X;
-typedef union {
- EventData_X x; /* for Event_X_* event types */
- Client *client; /* for Event_Client_* event types */
+typedef struct {
+ Client *client;
+ int num[2];
+ /* Event_Client_Desktop: num[0] = new number, num[1] = old number
+ Event_Client_Urgent: num[0] = urgent state
+ */
+} EventData_Client;
+
+typedef struct {
+ int num[2];
+ /* Event_Ob_Desktop: num[0] = new number, num[1] = old number
+ Event_Ob_NumDesktops: num[0] = new number, num[1] = old number
+ Event_Ob_ShowDesktop: num[0] = new show-desktop mode
+ */
+} EventData_Ob;
+
+typedef struct {
int signal;
+} EventData_Signal;
+
+typedef struct {
+ EventData_X x; /* for Event_X_* event types */
+ EventData_Client c; /* for Event_Client_* event types */
+ EventData_Ob o; /* for Event_Ob_* event types */
+ EventData_Signal s; /* for Event_Signal */
} EventData;
typedef struct {
void dispatch_register(EventMask mask, EventHandler h, void *data);
void dispatch_x(XEvent *e, Client *c);
-void dispatch_client(EventType e, Client *c);
-void dispatch_ob(EventType e);
+void dispatch_client(EventType e, Client *c, int num0, int num1);
+void dispatch_ob(EventType e, int num0, int num1);
void dispatch_signal(int signal);
#endif
g_assert(module == NULL);
path = g_build_filename(ENGINEDIR, name, NULL);
- module = g_module_open(path, G_MODULE_BIND_LAZY);
+ module = g_module_open(path, 0);
g_free(path);
if (module == NULL) {
path = g_build_filename(g_get_home_dir(), ".openbox", "engines", name,
NULL);
- module = g_module_open(path, G_MODULE_BIND_LAZY);
+ module = g_module_open(path, 0);
g_free(path);
}
}
if (focus_client != NULL)
- dispatch_client(Event_Client_Unfocus, focus_client);
+ dispatch_client(Event_Client_Unfocus, focus_client, 0, 0);
focus_client = client;
PROP_SET32(ob_root, net_active_window, window, active);
if (focus_client != NULL)
- dispatch_client(Event_Client_Focus, focus_client);
+ dispatch_client(Event_Client_Focus, focus_client, 0, 0);
}
plugin_startup();
/* XXX load all plugins!! */
- plugin_open("foo");
+ plugin_open("focus");
/* get all the existing windows */
client_manage_all();
void signal_handler(const ObEvent *e, void *data)
{
- switch (e->data.signal) {
+ int s;
+
+ s = e->data.s.signal;
+ switch (s) {
case SIGUSR1:
g_message("Caught SIGUSR1 signal. Restarting.");
ob_shutdown = ob_restart = TRUE;
case SIGINT:
case SIGTERM:
case SIGPIPE:
- g_message("Caught signal %d. Exiting.", e->data.signal);
+ g_message("Caught signal %d. Exiting.", s);
ob_shutdown = TRUE;
break;
case SIGFPE:
case SIGSEGV:
- g_error("Caught signal %d. Aborting and dumping core.",e->data.signal);
+ g_error("Caught signal %d. Aborting and dumping core.", s);
}
}
static gpointer load_sym(GModule *module, char *name, char *symbol)
{
- gpointer var = NULL;
- if (!g_module_symbol(module, symbol, &var))
- g_warning("Failed to load symbol '%s' from plugin '%s'", symbol, name);
+ gpointer var;
+ if (!g_module_symbol(module, symbol, &var)) {
+ g_warning("Failed to load symbol '%s' from plugin '%s'",
+ symbol, name);
+ var = NULL;
+ }
return var;
}
p = g_new(Plugin, 1);
path = g_build_filename(PLUGINDIR, name, NULL);
- p->module = g_module_open(path, G_MODULE_BIND_LAZY);
+ p->module = g_module_open(path, 0);
g_free(path);
if (p->module == NULL) {
path = g_build_filename(g_get_home_dir(), ".openbox", "plugins", name,
NULL);
- p->module = g_module_open(path, G_MODULE_BIND_LAZY);
+ p->module = g_module_open(path, 0);
g_free(path);
}
return NULL;
}
- p->startup = load_sym(p->module, name, "startup");
- p->shutdown = load_sym(p->module, name, "shutdown");
+ p->startup = load_sym(p->module, name, "plugin_startup");
+ p->shutdown = load_sym(p->module, name, "plugin_shutdown");
if (p->startup == NULL || p->shutdown == NULL) {
g_module_close(p->module);
void screen_set_num_desktops(guint num)
{
- unsigned long *viewport;
+ guint old;
+ gulong *viewport;
g_assert(num > 0);
}
*/
+ old = screen_num_desktops;
screen_num_desktops = num;
PROP_SET32(ob_root, net_number_of_desktops, cardinal, num);
/* set the viewport hint */
- viewport = g_new0(unsigned long, num * 2);
+ viewport = g_new0(gulong, num * 2);
PROP_SET32A(ob_root, net_desktop_viewport, cardinal, viewport, num * 2);
g_free(viewport);
/* may be some unnamed desktops that we need to fill in with names */
screen_update_desktop_names();
- dispatch_ob(Event_Ob_NumDesktops);
+ dispatch_ob(Event_Ob_NumDesktops, num, old);
/* change our desktop if we're on one that no longer exists! */
if (screen_desktop >= screen_num_desktops)
void screen_set_desktop(guint num)
{
GList *it;
-
- guint old = screen_desktop;
+ guint old;
g_assert(num < screen_num_desktops);
g_message("Moving to desktop %u", num);
+ old = screen_desktop;
screen_desktop = num;
PROP_SET32(ob_root, net_current_desktop, cardinal, num);
engine_frame_show(c->frame);
}
- dispatch_ob(Event_Ob_Desktop);
+ dispatch_ob(Event_Ob_Desktop, num, old);
}
void screen_update_layout()
}
}
- show = show ? 1 : 0; /* make it boolean */
+ show = !!show; /* make it boolean */
PROP_SET32(ob_root, net_showing_desktop, cardinal, show);
- dispatch_ob(Event_Ob_ShowDesktop);
+ dispatch_ob(Event_Ob_ShowDesktop, show, 0);
}
void screen_install_colormap(Client *client, gboolean install)
plugindir=$(libdir)/openbox/plugins
+SUBDIRS = keyboard
+
CPPFLAGS=$(XFT_CFLAGS) $(GLIB_CFLAGS) @CPPFLAGS@ \
-DPLUGINDIR=\"$(plugindir)\" \
-DG_LOG_DOMAIN=\"Openbox-Plugin\"
--- /dev/null
+plugindir=$(libdir)/openbox/plugins
+
+CPPFLAGS=$(XFT_CFLAGS) $(GLIB_CFLAGS) @CPPFLAGS@ \
+-DPLUGINDIR=\"$(plugindir)\" \
+-DG_LOG_DOMAIN=\"Openbox-Plugin\"
+
+plugin_LTLIBRARIES=focus.la
+
+focus_la_LDFLAGS=-module -avoid-version
+focus_la_SOURCES=focus.c
+
+noinst_HEADERS=
+
+MAINTAINERCLEANFILES= Makefile.in
+
+distclean-local:
+ $(RM) *\~ *.orig *.rej .\#*
--- /dev/null
+#include "../../kernel/dispatch.h"
+
+static void press(ObEvent *e, void *foo)
+{
+}
+
+void plugin_startup()
+{
+ dispatch_register(Event_X_KeyPress, (EventHandler)press, NULL);
+
+ /* XXX parse config file! */
+}
+
+void plugin_shutdown()
+{
+ dispatch_register(0, (EventHandler)press, NULL);
+}
+