summaryrefslogtreecommitdiff
path: root/openbox/dispatch.h
blob: 9561e7e6088a1775b538ef993f8ab838e0842bf1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef __dispatch_h
#define __dispatch_h

#include "client.h"
#include <X11/Xlib.h>

void dispatch_startup();
void dispatch_shutdown();

typedef enum {
    Event_X_EnterNotify   = 1 << 0,
    Event_X_LeaveNotify   = 1 << 1,
    Event_X_KeyPress      = 1 << 2,
    Event_X_KeyRelease    = 1 << 3,
    Event_X_ButtonPress   = 1 << 4,
    Event_X_ButtonRelease = 1 << 5,
    Event_X_MotionNotify  = 1 << 6,
    Event_X_Bell          = 1 << 7,

    Event_Client_New      = 1 << 8, /* new window, before mapping */
    Event_Client_Mapped   = 1 << 9, /* new window, after mapping */
    Event_Client_Destroy  = 1 << 10, /* unmanaged */
    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_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_Startup      = 1 << 18, /* startup complete */
    Event_Ob_Shutdown     = 1 << 19, /* shutdown about to start */

    Event_Signal          = 1 << 20,

    EVENT_RANGE           = 1 << 21
} EventType;

typedef struct {
    XEvent *e;
    Client *client;
} EventData_X;

typedef union {
    EventData_X x; /* for Event_X_* event types */
    Client *client; /* for Event_Client_* event types */
    int signal;
} EventData;

typedef struct {
    EventType type;
    EventData data;
} ObEvent;

typedef void (*EventHandler)(const ObEvent *e);

typedef unsigned int EventMask;

void dispatch_register(EventHandler h, EventMask mask);

void dispatch_x(XEvent *e, Client *c);
void dispatch_client(EventType e, Client *c);
void dispatch_ob(EventType e);
void dispatch_signal(int signal);

#endif