add a keyboard plugin
This commit is contained in:
parent
9185ca5c1a
commit
bfea000a74
13 changed files with 121 additions and 48 deletions
|
@ -62,6 +62,7 @@ AC_CONFIG_FILES([Makefile po/Makefile.in
|
|||
engines/Makefile
|
||||
engines/openbox/Makefile
|
||||
plugins/Makefile
|
||||
plugins/keyboard/Makefile
|
||||
doc/Makefile
|
||||
doc/doxygen/Makefile
|
||||
data/Makefile
|
||||
|
|
|
@ -195,11 +195,11 @@ void client_manage(Window window)
|
|||
|
||||
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*/
|
||||
|
@ -223,7 +223,7 @@ void client_unmanage(Client *client)
|
|||
|
||||
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);
|
||||
|
@ -926,7 +926,7 @@ void client_update_wmhints(Client *self)
|
|||
/* 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1220,8 +1220,6 @@ static void client_showhide(Client *self)
|
|||
engine_frame_show(self->frame);
|
||||
else
|
||||
engine_frame_hide(self->frame);
|
||||
|
||||
dispatch_client(Event_Client_Visible, self);
|
||||
}
|
||||
|
||||
gboolean client_normal(Client *self) {
|
||||
|
@ -1246,7 +1244,7 @@ static void client_apply_startup_state(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;
|
||||
|
@ -1626,8 +1624,10 @@ void client_close(Client *self)
|
|||
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);
|
||||
|
@ -1636,6 +1636,7 @@ void client_set_desktop(Client *self, unsigned int 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 */
|
||||
|
@ -1643,6 +1644,8 @@ void client_set_desktop(Client *self, unsigned int target)
|
|||
/* '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)
|
||||
|
|
|
@ -372,7 +372,7 @@ void client_shade(Client *self, gboolean shade);
|
|||
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.
|
||||
|
|
|
@ -143,7 +143,7 @@ void dispatch_x(XEvent *xe, Client *c)
|
|||
}
|
||||
}
|
||||
|
||||
void dispatch_client(EventType e, Client *c)
|
||||
void dispatch_client(EventType e, Client *c, int num0, int num1)
|
||||
{
|
||||
guint i;
|
||||
GSList *it;
|
||||
|
@ -152,7 +152,9 @@ void dispatch_client(EventType e, Client *c)
|
|||
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) {
|
||||
|
@ -166,13 +168,15 @@ void dispatch_client(EventType e, Client *c)
|
|||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -194,7 +198,7 @@ void dispatch_signal(int signal)
|
|||
ObEvent obe;
|
||||
|
||||
obe.type = e;
|
||||
obe.data.signal = signal;
|
||||
obe.data.s.signal = signal;
|
||||
|
||||
i = 0;
|
||||
while (e > 1) {
|
||||
|
|
|
@ -23,16 +23,15 @@ typedef enum {
|
|||
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 {
|
||||
|
@ -40,10 +39,31 @@ 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 {
|
||||
|
@ -58,8 +78,8 @@ typedef unsigned int EventMask;
|
|||
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
|
||||
|
|
|
@ -23,13 +23,13 @@ static gboolean load(char *name)
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ void focus_set_client(Client *client)
|
|||
}
|
||||
|
||||
if (focus_client != NULL)
|
||||
dispatch_client(Event_Client_Unfocus, focus_client);
|
||||
dispatch_client(Event_Client_Unfocus, focus_client, 0, 0);
|
||||
|
||||
focus_client = client;
|
||||
|
||||
|
@ -57,5 +57,5 @@ void focus_set_client(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);
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ int main(int argc, char **argv)
|
|||
plugin_startup();
|
||||
|
||||
/* XXX load all plugins!! */
|
||||
plugin_open("foo");
|
||||
plugin_open("focus");
|
||||
|
||||
/* get all the existing windows */
|
||||
client_manage_all();
|
||||
|
@ -174,7 +174,10 @@ int main(int argc, char **argv)
|
|||
|
||||
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;
|
||||
|
@ -188,12 +191,12 @@ void signal_handler(const ObEvent *e, void *data)
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,9 +14,12 @@ typedef struct {
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -28,13 +31,13 @@ static Plugin *plugin_new(char *name)
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -43,8 +46,8 @@ static Plugin *plugin_new(char *name)
|
|||
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);
|
||||
|
|
|
@ -195,7 +195,8 @@ void screen_resize()
|
|||
|
||||
void screen_set_num_desktops(guint num)
|
||||
{
|
||||
unsigned long *viewport;
|
||||
guint old;
|
||||
gulong *viewport;
|
||||
|
||||
g_assert(num > 0);
|
||||
|
||||
|
@ -218,11 +219,12 @@ void screen_set_num_desktops(guint num)
|
|||
}
|
||||
*/
|
||||
|
||||
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);
|
||||
|
||||
|
@ -235,7 +237,7 @@ void screen_set_num_desktops(guint num)
|
|||
/* 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)
|
||||
|
@ -245,13 +247,13 @@ void screen_set_num_desktops(guint num)
|
|||
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);
|
||||
|
||||
|
@ -271,7 +273,7 @@ void screen_set_desktop(guint num)
|
|||
engine_frame_show(c->frame);
|
||||
}
|
||||
|
||||
dispatch_ob(Event_Ob_Desktop);
|
||||
dispatch_ob(Event_Ob_Desktop, num, old);
|
||||
}
|
||||
|
||||
void screen_update_layout()
|
||||
|
@ -392,10 +394,10 @@ void screen_show_desktop(gboolean show)
|
|||
}
|
||||
}
|
||||
|
||||
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)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
plugindir=$(libdir)/openbox/plugins
|
||||
|
||||
SUBDIRS = keyboard
|
||||
|
||||
CPPFLAGS=$(XFT_CFLAGS) $(GLIB_CFLAGS) @CPPFLAGS@ \
|
||||
-DPLUGINDIR=\"$(plugindir)\" \
|
||||
-DG_LOG_DOMAIN=\"Openbox-Plugin\"
|
||||
|
|
17
plugins/keyboard/Makefile.am
Normal file
17
plugins/keyboard/Makefile.am
Normal file
|
@ -0,0 +1,17 @@
|
|||
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 .\#*
|
18
plugins/keyboard/keyboard.c
Normal file
18
plugins/keyboard/keyboard.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
#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);
|
||||
}
|
||||
|
Loading…
Reference in a new issue