]> icculus.org git repositories - dana/openbox.git/blob - openbox/mainloop.h
provide a callback for when there are no more X events to process
[dana/openbox.git] / openbox / mainloop.h
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    mainloop.h for the Openbox window manager
4    Copyright (c) 2003        Ben Jansens
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    See the COPYING file for a copy of the GNU General Public License.
17 */
18
19 #ifndef __ob__mainloop_h
20 #define __ob__mainloop_h
21
22 #include <X11/Xlib.h>
23 #include <glib.h>
24
25 typedef struct _ObMainLoop ObMainLoop;
26
27 ObMainLoop *ob_main_loop_new(Display *display);
28 void        ob_main_loop_destroy(ObMainLoop *loop);
29
30 typedef void (*ObMainLoopXHandler) (const XEvent *e, gpointer data);
31 typedef void (*ObMainLoopXDoneHandler) (gpointer data);
32
33 void ob_main_loop_x_add(ObMainLoop *loop,
34                         ObMainLoopXHandler handler,
35                         ObMainLoopXDoneHandler done_handler,
36                         gpointer data,
37                         GDestroyNotify notify);
38 void ob_main_loop_x_remove(ObMainLoop *loop,
39                            ObMainLoopXHandler handler);
40
41 typedef void (*ObMainLoopFdHandler) (gint fd, gpointer data);
42
43 void ob_main_loop_fd_add(ObMainLoop *loop,
44                          gint fd,
45                          ObMainLoopFdHandler handler,
46                          gpointer data,
47                          GDestroyNotify notify);
48 void ob_main_loop_fd_remove(ObMainLoop *loop,
49                             gint fd);
50
51 typedef void (*ObMainLoopSignalHandler) (gint signal, gpointer data);
52
53 void ob_main_loop_signal_add(ObMainLoop *loop,
54                              gint signal,
55                              ObMainLoopSignalHandler handler,
56                              gpointer data,
57                              GDestroyNotify notify);
58 void ob_main_loop_signal_remove(ObMainLoop *loop,
59                                 ObMainLoopSignalHandler handler);
60
61 void ob_main_loop_timeout_add(ObMainLoop *loop,
62                               gulong microseconds,
63                               GSourceFunc handler,
64                               gpointer data,
65                               GDestroyNotify notify);
66 void ob_main_loop_timeout_remove(ObMainLoop *loop,
67                                  GSourceFunc handler);
68 void ob_main_loop_timeout_remove_data(ObMainLoop *loop,
69                                       GSourceFunc handler,
70                                       gpointer data);
71
72 struct _ObAction;
73
74 /*! Queues an action, which will be run when there are no more X events
75   to process */
76 void ob_main_loop_queue_action(ObMainLoop *loop, struct _ObAction *act);
77
78 void ob_main_loop_run(ObMainLoop *loop);
79 void ob_main_loop_exit(ObMainLoop *loop);
80
81 #endif