Move the main loop out into the libobt
[dana/openbox.git] / obt / mainloop.h
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    obt/mainloop.h for the Openbox window manager
4    Copyright (c) 2006        Mikael Magnusson
5    Copyright (c) 2003-2007   Dana Jansens
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    See the COPYING file for a copy of the GNU General Public License.
18 */
19
20 #ifndef __obt_mainloop_h
21 #define __obt_mainloop_h
22
23 #include <X11/Xlib.h>
24 #include <glib.h>
25
26 typedef struct _ObtMainLoop ObtMainLoop;
27
28 ObtMainLoop *obt_main_loop_new(Display *display);
29 void        obt_main_loop_ref(ObtMainLoop *loop);
30 void        obt_main_loop_unref(ObtMainLoop *loop);
31
32 typedef void (*ObtMainLoopXHandler) (const XEvent *e, gpointer data);
33
34 void obt_main_loop_x_add(ObtMainLoop *loop,
35                          ObtMainLoopXHandler handler,
36                          gpointer data,
37                          GDestroyNotify notify);
38 void obt_main_loop_x_remove(ObtMainLoop *loop,
39                             ObtMainLoopXHandler handler);
40
41 typedef void (*ObtMainLoopFdHandler) (gint fd, gpointer data);
42
43 void obt_main_loop_fd_add(ObtMainLoop *loop,
44                           gint fd,
45                           ObtMainLoopFdHandler handler,
46                           gpointer data,
47                           GDestroyNotify notify);
48 void obt_main_loop_fd_remove(ObtMainLoop *loop,
49                              gint fd);
50
51 typedef void (*ObtMainLoopSignalHandler) (gint signal, gpointer data);
52
53 void obt_main_loop_signal_add(ObtMainLoop *loop,
54                               gint signal,
55                               ObtMainLoopSignalHandler handler,
56                               gpointer data,
57                               GDestroyNotify notify);
58 void obt_main_loop_signal_remove(ObtMainLoop *loop,
59                                  ObtMainLoopSignalHandler handler);
60
61 void obt_main_loop_timeout_add(ObtMainLoop *loop,
62                                gulong microseconds,
63                                GSourceFunc handler,
64                                gpointer data,
65                                GEqualFunc cmp,
66                                GDestroyNotify notify);
67 void obt_main_loop_timeout_remove(ObtMainLoop *loop,
68                                   GSourceFunc handler);
69 void obt_main_loop_timeout_remove_data(ObtMainLoop *loop,
70                                        GSourceFunc handler,
71                                        gpointer data,
72                                        gboolean cancel_dest);
73
74 void obt_main_loop_run(ObtMainLoop *loop);
75 void obt_main_loop_exit(ObtMainLoop *loop);
76
77 #endif