kernel/config.h \
kernel/debug.c \
kernel/debug.h \
- kernel/dispatch.c \
- kernel/dispatch.h \
kernel/dock.c \
kernel/dock.h \
kernel/event.c \
#include "startup.h"
#include "screen.h"
#include "moveresize.h"
+#include "place.h"
#include "prop.h"
#include "extensions.h"
#include "frame.h"
#include "grab.h"
#include "focus.h"
#include "stacking.h"
-#include "dispatch.h"
#include "openbox.h"
#include "group.h"
#include "config.h"
frame_grab_client(self->frame, self);
- client_apply_startup_state(self);
-
grab_server(FALSE);
+ client_apply_startup_state(self);
+
/* update the focus lists */
focus_order_add_new(self);
#endif
}
- dispatch_client(Event_Client_New, self, 0, 0);
+ if (ob_state() == OB_STATE_RUNNING) {
+ int x = self->area.x, ox = x;
+ int y = self->area.y, oy = y;
+
+ place_client(self, &x, &y);
+
+ client_find_onscreen(self, &x, &y,
+ self->frame->area.width,
+ self->frame->area.height,
+ client_normal(self));
+
+ if (x != ox || y != oy)
+ client_configure(self, OB_CORNER_TOPLEFT, x, y,
+ self->area.width, self->area.height,
+ TRUE, TRUE);
+ }
/* make sure the window is visible */
- if (ob_state() == OB_STATE_RUNNING)
client_move_onscreen(self, client_normal(self));
client_showhide(self);
keyboard_grab_for_client(self, TRUE);
mouse_grab_for_client(self, TRUE);
- dispatch_client(Event_Client_Mapped, self, 0, 0);
-
ob_debug("Managed window 0x%lx (%s)\n", window, self->class);
}
ob_debug("Unmanaging window: %lx (%s)\n", self->window, self->class);
- dispatch_client(Event_Client_Destroy, self, 0, 0);
g_assert(self != NULL);
keyboard_grab_for_client(self, FALSE);
self->group = NULL;
}
- /* dispatch the unmapped event */
- dispatch_client(Event_Client_Unmapped, self, 0, 0);
- g_assert(self != NULL);
-
/* give the client its border back */
client_toggle_border(self, TRUE);
ur ? "ON" : "OFF");
/* fire the urgent callback if we're mapped, otherwise, wait until
after we're mapped */
- if (self->frame)
- dispatch_client(Event_Client_Urgent, self, self->urgent, 0);
+ if (self->frame) {
+ /* XXX do shit */
+ }
}
}
client_shade(self, TRUE);
}
if (self->urgent)
- dispatch_client(Event_Client_Urgent, self, self->urgent, 0);
+ /* XXX do shit */;
if (self->max_vert && self->max_horz) {
self->max_vert = self->max_horz = FALSE;
client_change_state(self);
client_showhide(self);
screen_update_areas();
-
- dispatch_client(iconic ? Event_Client_Unmapped : Event_Client_Mapped,
- self, 0, 0);
}
/* iconify all transients */
focus_order_to_top(self);
else
focus_order_to_bottom(self);
-
- dispatch_client(Event_Client_Desktop, self, target, old);
}
/* move all transients */
+++ /dev/null
-#include "dispatch.h"
-#include "extensions.h"
-#include "client.h"
-
-#include <glib.h>
-
-typedef struct {
- EventHandler h;
- void *data;
-} Func;
-
-/* an array of GSList*s of Func*s */
-static GSList **funcs;
-
-void dispatch_startup()
-{
- guint i;
- EventType j;
-
- i = 0;
- j = EVENT_RANGE;
- while (j > 1) {
- j >>= 1;
- ++i;
- }
- funcs = g_new0(GSList*, i);
-}
-
-void dispatch_shutdown()
-{
- guint i;
- EventType j;
- GSList *it;
-
- for (i = 0, j = 1; j < EVENT_RANGE; ++i, j <<= 1) {
- for (it = funcs[i]; it != NULL; it = it->next)
- g_free(it->data);
- g_slist_free(funcs[i]);
- funcs[i] = NULL;
- }
-
- g_free(funcs);
-}
-
-void dispatch_register(EventMask mask, EventHandler h, void *data)
-{
- guint i;
- EventType j;
- GSList *it, *next;
- EventMask m;
- Func *f;
-
- /* add to masks it needs to be registered for */
- m = mask;
- while (m) {
- for (i = 0, j = 1; j < EVENT_RANGE; ++i, j <<= 1)
- if (m & j) {
- for (it = funcs[i]; it != NULL; it = it->next) {
- f = it->data;
- if (f->h == h && f->data == data)
- break;
- }
- if (it == NULL) { /* wasn't already regged */
- f = g_new(Func, 1);
- f->h = h;
- f->data = data;
- funcs[i] = g_slist_append(funcs[i], f);
- }
- m ^= j; /* remove from the mask */
- }
- g_assert(j >= EVENT_RANGE); /* an invalid event is in the mask */
- }
-
- /* remove from masks its not registered for anymore */
- for (i = 0, j = 1; j < EVENT_RANGE; ++i, j <<= 1) {
- if (!(j & mask))
- for (it = funcs[i]; it != NULL; it = next) {
- next = it->next;
- f = it->data;
- if (f->h == h && f->data == data) {
- g_free(f);
- funcs[i] = g_slist_delete_link(funcs[i], it);
- }
- }
- }
-}
-
-void dispatch_x(XEvent *xe, ObClient *c)
-{
- EventType e;
- guint i;
- GSList *it;
- ObEvent obe;
-
- switch (xe->type) {
- case EnterNotify:
- e = Event_X_EnterNotify;
- break;
- case LeaveNotify:
- e = Event_X_LeaveNotify;
- break;
- case KeyPress:
- e = Event_X_KeyPress;
- break;
- case KeyRelease:
- e = Event_X_KeyRelease;
- break;
- case ButtonPress:
- e = Event_X_ButtonPress;
- break;
- case ButtonRelease:
- e = Event_X_ButtonRelease;
- break;
- case MotionNotify:
- e = Event_X_MotionNotify;
- break;
- default:
- /* XKB events */
- if (xe->type == extensions_xkb_event_basep) {
- switch (((XkbAnyEvent*)&e)->xkb_type) {
- case XkbBellNotify:
- e = Event_X_Bell;
- break;
- }
- }
- return;
- }
-
- obe.type = e;
- obe.data.x.e = xe;
- obe.data.x.client = c;
-
- i = 0;
- while (e > 1) {
- e >>= 1;
- ++i;
- }
-
- for (it = funcs[i]; it != NULL; it = it->next) {
- Func *f = it->data;
- f->h(&obe, f->data);
- }
-}
-
-void dispatch_client(EventType e, ObClient *c, int num0, int num1)
-{
- guint i;
- GSList *it;
- ObEvent obe;
-
- g_assert(c != NULL);
-
- obe.type = e;
- obe.data.c.client = c;
- obe.data.c.num[0] = num0;
- obe.data.c.num[1] = num1;
- obe.data.c.num[2] = 0;
-
- i = 0;
- while (e > 1) {
- e >>= 1;
- ++i;
- }
-
- for (it = funcs[i]; it != NULL; it = it->next) {
- Func *f = it->data;
- f->h(&obe, f->data);
- }
-}
-
-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) {
- e >>= 1;
- ++i;
- }
-
- for (it = funcs[i]; it != NULL; it = it->next) {
- Func *f = it->data;
- f->h(&obe, f->data);
- }
-}
-
-void dispatch_signal(int signal)
-{
- guint i;
- EventType e = Event_Signal;
- GSList *it;
- ObEvent obe;
-
- obe.type = e;
- obe.data.s.signal = signal;
-
- i = 0;
- while (e > 1) {
- e >>= 1;
- ++i;
- }
-
- for (it = funcs[i]; it != NULL; it = it->next) {
- Func *f = it->data;
- f->h(&obe, f->data);
- }
-}
-
-void dispatch_move(ObClient *c, int *x, int *y)
-{
- guint i;
- GSList *it;
- EventType e = Event_Client_Moving;
- ObEvent obe;
-
- obe.type = e;
- obe.data.c.client = c;
- obe.data.c.num[0] = *x;
- obe.data.c.num[1] = *y;
-
- i = 0;
- while (e > 1) {
- e >>= 1;
- ++i;
- }
-
- for (it = funcs[i]; it != NULL; it = it->next) {
- Func *f = it->data;
- f->h(&obe, f->data);
- }
-
- *x = obe.data.c.num[0];
- *y = obe.data.c.num[1];
-}
-
-void dispatch_resize(ObClient *c, int *w, int *h, ObCorner corner)
-{
- guint i;
- GSList *it;
- EventType e = Event_Client_Resizing;
- ObEvent obe;
-
- obe.type = e;
- obe.data.c.client = c;
- obe.data.c.num[0] = *w;
- obe.data.c.num[1] = *h;
- obe.data.c.num[2] = corner;
-
- i = 0;
- while (e > 1) {
- e >>= 1;
- ++i;
- }
-
- for (it = funcs[i]; it != NULL; it = it->next) {
- Func *f = it->data;
- f->h(&obe, f->data);
- }
-
- *w = obe.data.c.num[0];
- *h = obe.data.c.num[1];
-}
+++ /dev/null
-#ifndef __dispatch_h
-#define __dispatch_h
-
-#include "misc.h"
-
-#include <X11/Xlib.h>
-
-struct _ObClient;
-
-void dispatch_startup();
-void dispatch_shutdown();
-
-typedef enum {
- Event_X_EnterNotify = 1 << 0, /* pointer entered a window */
- Event_X_LeaveNotify = 1 << 1, /* pointer left a window */
- Event_X_KeyPress = 1 << 2, /* key pressed */
- Event_X_KeyRelease = 1 << 3, /* key released */
- Event_X_ButtonPress = 1 << 4, /* mouse button pressed */
- Event_X_ButtonRelease = 1 << 5, /* mouse button released */
- Event_X_MotionNotify = 1 << 6, /* mouse motion */
- Event_X_Bell = 1 << 7, /* an XKB bell event */
-
- Event_Client_New = 1 << 8, /* new window, before mapping */
- Event_Client_Mapped = 1 << 9, /* new window, after mapping
- or uniconified */
- Event_Client_Destroy = 1 << 10, /* unmanaged */
- Event_Client_Unmapped = 1 << 11, /* unmanaged, after unmapping
- or iconified */
- Event_Client_Focus = 1 << 12, /* focused */
- Event_Client_Unfocus = 1 << 13, /* unfocused */
- Event_Client_Urgent = 1 << 14, /* entered/left urgent state */
- Event_Client_Desktop = 1 << 15, /* moved to a new desktop */
- Event_Client_Moving = 1 << 16, /* being interactively moved */
- Event_Client_Resizing = 1 << 17, /* being interactively resized */
-
- Event_Ob_Desktop = 1 << 18, /* changed desktops */
- Event_Ob_NumDesktops = 1 << 19, /* changed the number of desktops */
- Event_Ob_ShowDesktop = 1 << 20, /* entered/left show-the-desktop mode */
-
- Event_Signal = 1 << 21, /* a signal from the OS */
-
- EVENT_RANGE = 1 << 22
-} EventType;
-
-typedef struct {
- XEvent *e;
- struct _ObClient *client;
-} EventData_X;
-
-typedef struct {
- struct _ObClient *client;
- int num[3];
- /* Event_Client_Desktop: num[0] = new number, num[1] = old number
- Event_Client_Urgent: num[0] = urgent state
- Event_Client_Moving: num[0] = dest x coord, num[1] = dest y coord --
- change these in the handler to adjust where the
- window will be placed
- Event_Client_Resizing: num[0] = dest width, num[1] = dest height --
- change these in the handler to adjust where the
- window will be placed
- num[2] = the anchored corner
- */
-} 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_ObClient_* event types */
- EventData_Ob o; /* for Event_Ob_* event types */
- EventData_Signal s; /* for Event_Signal */
-} EventData;
-
-typedef struct {
- EventType type;
- EventData data;
-} ObEvent;
-
-typedef void (*EventHandler)(const ObEvent *e, void *data);
-
-typedef unsigned int EventMask;
-
-void dispatch_register(EventMask mask, EventHandler h, void *data);
-
-void dispatch_x(XEvent *e, struct _ObClient *c);
-void dispatch_client(EventType e, struct _ObClient *c, int num0, int num1);
-void dispatch_ob(EventType e, int num0, int num1);
-void dispatch_signal(int signal);
-/* *x and *y should be set with the destination of the window, they may be
- changed by the event handlers */
-void dispatch_move(struct _ObClient *c, int *x, int *y);
-/* *w and *h should be set with the destination of the window, they may be
- changed by the event handlers */
-void dispatch_resize(struct _ObClient *c, int *w, int *h, ObCorner corner);
-
-#endif
#include "stacking.h"
#include "extensions.h"
#include "timer.h"
-#include "dispatch.h"
#include "event.h"
#include <X11/Xlib.h>
xerror_set_ignore(FALSE);
}
- if (menu_frame_visible)
- if (e->type == MotionNotify || e->type == ButtonRelease ||
- e->type == ButtonPress ||
- e->type == KeyPress || e->type == KeyRelease) {
- event_handle_menu(e);
-
- return; /* no dispatch! */
- }
-
- if (moveresize_in_progress)
- if (e->type == MotionNotify || e->type == ButtonRelease ||
- e->type == ButtonPress ||
- e->type == KeyPress || e->type == KeyRelease) {
- moveresize_event(e);
-
- return; /* no dispatch! */
- }
-
/* user input (action-bound) events */
if (e->type == ButtonPress || e->type == ButtonRelease ||
e->type == MotionNotify || e->type == KeyPress ||
e->type == KeyRelease)
{
- ObFrameContext context;
-
- context = frame_context(client, e->xany.window);
+ if (menu_frame_visible)
+ event_handle_menu(e);
+ else if (moveresize_in_progress)
+ moveresize_event(e);
+ else {
+ ObFrameContext context;
- if (!keyboard_process_interactive_grab(e, &client, &context)) {
+ context = frame_context(client, e->xany.window);
- if (e->type == ButtonPress || e->type == ButtonRelease ||
- e->type == MotionNotify)
- mouse_event(client, context, e);
- else if (e->type == KeyPress)
- keyboard_event(client, e);
+ if (!keyboard_process_interactive_grab(e, &client, &context)) {
+ if (e->type == ButtonPress || e->type == ButtonRelease ||
+ e->type == MotionNotify)
+ mouse_event(client, context, e);
+ else if (e->type == KeyPress)
+ keyboard_event(client, e);
+ }
}
}
-
- /* dispatch the event to registered handlers */
- dispatch_x(e, client);
}
static void event_handle_root(XEvent *e)
#include "screen.h"
#include "group.h"
#include "prop.h"
-#include "dispatch.h"
#include "focus.h"
#include "stacking.h"
#include "popup.h"
PROP_SET32(RootWindow(ob_display, ob_screen),
net_active_window, window, active);
}
-
- if (focus_client != NULL)
- dispatch_client(Event_Client_Focus, focus_client, 0, 0);
- if (old != NULL)
- dispatch_client(Event_Client_Unfocus, old, 0, 0);
}
static gboolean focus_under_pointer()
#include "prop.h"
#include "client.h"
#include "frame.h"
-#include "dispatch.h"
#include "openbox.h"
#include "resist.h"
#include "popup.h"
if (resist)
resist_move(moveresize_client, &cur_x, &cur_y);
- dispatch_move(moveresize_client, &cur_x, &cur_y);
-
/* get where the client should be */
frame_frame_gravity(moveresize_client->frame, &cur_x, &cur_y);
client_configure(moveresize_client, OB_CORNER_TOPLEFT, cur_x, cur_y,
static void do_resize(gboolean resist)
{
- /* dispatch_resize needs the frame size */
- cur_x += moveresize_client->frame->size.left +
- moveresize_client->frame->size.right;
- cur_y += moveresize_client->frame->size.top +
- moveresize_client->frame->size.bottom;
+ if (resist) {
+ /* resist_size needs the frame size */
+ cur_x += moveresize_client->frame->size.left +
+ moveresize_client->frame->size.right;
+ cur_y += moveresize_client->frame->size.top +
+ moveresize_client->frame->size.bottom;
- if (resist)
resist_size(moveresize_client, &cur_x, &cur_y, lockcorner);
- dispatch_resize(moveresize_client, &cur_x, &cur_y, lockcorner);
-
- cur_x -= moveresize_client->frame->size.left +
- moveresize_client->frame->size.right;
- cur_y -= moveresize_client->frame->size.top +
- moveresize_client->frame->size.bottom;
+ cur_x -= moveresize_client->frame->size.left +
+ moveresize_client->frame->size.right;
+ cur_y -= moveresize_client->frame->size.top +
+ moveresize_client->frame->size.bottom;
+ }
client_configure(moveresize_client, lockcorner,
moveresize_client->area.x, moveresize_client->area.y,
#include "event.h"
#include "menu.h"
#include "client.h"
-#include "dispatch.h"
#include "xerror.h"
#include "prop.h"
#include "startup.h"
static KeyCode keys[OB_NUM_KEYS];
static gchar *sm_save_file;
-static void signal_handler(const ObEvent *e, void *data);
+static void signal_handler(int signal);
static void parse_args(int argc, char **argv);
int main(int argc, char **argv)
bind_textdomain_codeset(PACKAGE_NAME, "UTF-8");
textdomain(PACKAGE_NAME);
- /* start our event dispatcher and register for signals */
- dispatch_startup();
- dispatch_register(Event_Signal, signal_handler, NULL);
-
/* set up signal handler */
sigemptyset(&sigset);
- action.sa_handler = dispatch_signal;
+ action.sa_handler = signal_handler;
action.sa_mask = sigset;
action.sa_flags = SA_NOCLDSTOP | SA_NODEFER;
sigaction(SIGUSR1, &action, (struct sigaction *) NULL);
config_shutdown();
}
- dispatch_shutdown();
-
RrThemeFree(ob_rr_theme);
RrInstanceFree(ob_rr_inst);
return 0;
}
-static void signal_handler(const ObEvent *e, void *data)
+static void signal_handler(int sig)
{
- int s;
-
- s = e->data.s.signal;
- switch (s) {
+ switch (sig) {
case SIGUSR1:
fprintf(stderr, "Caught SIGUSR1 signal. Restarting.");
ob_restart();
case SIGINT:
case SIGTERM:
case SIGPIPE:
- fprintf(stderr, "Caught signal %d. Exiting.", s);
+ fprintf(stderr, "Caught signal %d. Exiting.", sig);
ob_exit();
break;
case SIGFPE:
case SIGSEGV:
- fprintf(stderr, "Caught signal %d. Aborting and dumping core.", s);
+ fprintf(stderr, "Caught signal %d. Aborting and dumping core.", sig);
abort();
}
}
#include "frame.h"
#include "focus.h"
#include "popup.h"
-#include "dispatch.h"
#include "extensions.h"
#include "render/render.h"
/* change our struts/area to match (after moving windows) */
screen_update_areas();
- 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)
screen_set_desktop(num - 1);
#ifdef DEBUG_FOCUS
ob_debug("/switch fallback\n");
#endif
-
- dispatch_ob(Event_Ob_Desktop, num, old);
}
static void get_row_col(guint d, guint *r, guint *c)
show = !!show; /* make it boolean */
PROP_SET32(RootWindow(ob_display, ob_screen),
net_showing_desktop, cardinal, show);
-
- dispatch_ob(Event_Ob_ShowDesktop, show, 0);
}
void screen_install_colormap(ObClient *client, gboolean install)