aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/mb-wm-main-context.h
blob: 3b92c38fbe9d88846dcb6753fe8efd05adf27112 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
 *  Matchbox Window Manager II - A lightweight window manager not for the
 *                               desktop.
 *
 *  Authored By Matthew Allum <mallum@o-hand.com>
 *
 *  Copyright (c) 2005 OpenedHand Ltd - http://o-hand.com
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 */

#ifndef _HAVE_MB_MAIN_CONTEXT_H
#define _HAVE_MB_MAIN_CONTEXT_H

#include "mb-wm.h"
#include <poll.h>

#define MB_WM_MAIN_CONTEXT(c) ((MBWMMainContext*)(c))
#define MB_WM_MAIN_CONTEXT_CLASS(c) ((MBWMMainContextClass*)(c))
#define MB_WM_TYPE_MAIN_CONTEXT (mb_wm_main_context_class_type ())
#define MB_WM_IS_MAIN_CONTEXT(c) (MB_WM_OBJECT_TYPE(c)==MB_WM_TYPE_MAIN_CONTEXT)

typedef Bool (*MBWMMainContextXEventFunc) (XEvent * xev, void * userdata);

typedef struct MBWMEventFuncs
{
  /* FIXME: figure our X wrap / unwrap mechanism */
  MBWMList *map_notify;
  MBWMList *unmap_notify;
  MBWMList *map_request;
  MBWMList *destroy_notify;
  MBWMList *configure_request;
  MBWMList *configure_notify;
  MBWMList *key_press;
  MBWMList *property_notify;
  MBWMList *button_press;
  MBWMList *button_release;
  MBWMList *motion_notify;

#ifndef USE_GLIB_MAINLOOP
  MBWMList *timeout;
  MBWMList *fd_watch;
#endif
}
MBWMEventFuncs;

struct MBWMMainContext
{
  MBWMObject       parent;

  MBWindowManager *wm;

  MBWMEventFuncs   event_funcs;
  struct pollfd   *poll_fds;
  int              n_poll_fds;
  Bool             poll_cache_dirty;
};

struct MBWMMainContextClass
{
  MBWMObjectClass parent;
};

int
mb_wm_main_context_class_type ();

MBWMMainContext*
mb_wm_main_context_new(MBWindowManager *wm);

unsigned long
mb_wm_main_context_x_event_handler_add (MBWMMainContext *ctx,
					Window           xwin,
					int              type,
					MBWMXEventFunc   func,
					void            *userdata);

void
mb_wm_main_context_x_event_handler_remove (MBWMMainContext *ctx,
					   int              type,
					   unsigned long    id);

unsigned long
mb_wm_main_context_timeout_handler_add (MBWMMainContext            *ctx,
					int                         ms,
					MBWindowManagerTimeOutFunc  func,
					void                       *userdata);

void
mb_wm_main_context_timeout_handler_remove (MBWMMainContext *ctx,
					   unsigned long    id);

MBWMIOChannel *
mb_wm_main_context_io_channel_new (int fd);

void
mb_wm_main_context_io_channel_destroy (MBWMIOChannel * channel);

int
mb_wm_main_context_io_channel_get_fd (MBWMIOChannel * channel);

unsigned long
mb_wm_main_context_fd_watch_add (MBWMMainContext           *ctx,
				 MBWMIOChannel             *channel,
				 MBWMIOCondition            events,
				 MBWindowManagerFdWatchFunc func,
				 void                      *userdata);

void
mb_wm_main_context_fd_watch_remove (MBWMMainContext *ctx,
				    unsigned long    id);

void
mb_wm_main_context_loop (MBWMMainContext *ctx);

#endif