Move the main loop out into the libobt
This commit is contained in:
parent
fe57b2f2f0
commit
452627a51c
17 changed files with 293 additions and 323 deletions
11
Makefile.am
11
Makefile.am
|
@ -126,8 +126,10 @@ obt_libobt_la_LIBADD = \
|
||||||
$(XML_LIBS)
|
$(XML_LIBS)
|
||||||
obt_libobt_la_SOURCES = \
|
obt_libobt_la_SOURCES = \
|
||||||
obt/obt.h \
|
obt/obt.h \
|
||||||
obt/instance.h \
|
obt/display.h \
|
||||||
obt/instance.c \
|
obt/display.c \
|
||||||
|
obt/mainloop.h \
|
||||||
|
obt/mainloop.c \
|
||||||
obt/util.h
|
obt/util.h
|
||||||
|
|
||||||
## openbox ##
|
## openbox ##
|
||||||
|
@ -249,8 +251,6 @@ openbox_openbox_SOURCES = \
|
||||||
openbox/keyboard.h \
|
openbox/keyboard.h \
|
||||||
openbox/keytree.c \
|
openbox/keytree.c \
|
||||||
openbox/keytree.h \
|
openbox/keytree.h \
|
||||||
openbox/mainloop.c \
|
|
||||||
openbox/mainloop.h \
|
|
||||||
openbox/menuframe.c \
|
openbox/menuframe.c \
|
||||||
openbox/menuframe.h \
|
openbox/menuframe.h \
|
||||||
openbox/menu.c \
|
openbox/menu.c \
|
||||||
|
@ -403,7 +403,8 @@ pubinclude_HEADERS = \
|
||||||
render/theme.h \
|
render/theme.h \
|
||||||
parser/parse.h \
|
parser/parse.h \
|
||||||
obt/obt.h \
|
obt/obt.h \
|
||||||
obt/instance.h \
|
obt/display.h \
|
||||||
|
obt/mainloop.h \
|
||||||
obt/util.h
|
obt/util.h
|
||||||
|
|
||||||
nodist_pubinclude_HEADERS = \
|
nodist_pubinclude_HEADERS = \
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
|
/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
|
||||||
|
|
||||||
obt/instance.c for the Openbox window manager
|
obt/display.c for the Openbox window manager
|
||||||
Copyright (c) 2007 Dana Jansens
|
Copyright (c) 2007 Dana Jansens
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
See the COPYING file for a copy of the GNU General Public License.
|
See the COPYING file for a copy of the GNU General Public License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "obt/instance.h"
|
#include "obt/display.h"
|
||||||
#include "obt/util.h"
|
#include "obt/util.h"
|
||||||
|
|
||||||
#ifdef HAVE_STRING_H
|
#ifdef HAVE_STRING_H
|
||||||
|
@ -29,47 +29,23 @@
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct _ObtInstance
|
Display* obt_display_open(const char *display_name)
|
||||||
{
|
|
||||||
gint ref;
|
|
||||||
Display *d;
|
|
||||||
};
|
|
||||||
|
|
||||||
ObtInstance* obt_instance_new(const char *display_name)
|
|
||||||
{
|
{
|
||||||
gchar *n;
|
gchar *n;
|
||||||
Display *d;
|
Display *d = NULL;
|
||||||
ObtInstance *inst = NULL;
|
|
||||||
|
|
||||||
n = display_name ? g_strdup(display_name) : NULL;
|
n = display_name ? g_strdup(display_name) : NULL;
|
||||||
d = XOpenDisplay(n);
|
d = XOpenDisplay(n);
|
||||||
if (d) {
|
if (d) {
|
||||||
if (fcntl(ConnectionNumber(d), F_SETFD, 1) == -1)
|
if (fcntl(ConnectionNumber(d), F_SETFD, 1) == -1)
|
||||||
g_message("Failed to set display as close-on-exec");
|
g_message("Failed to set display as close-on-exec");
|
||||||
|
|
||||||
inst = g_new(ObtInstance, 1);
|
|
||||||
inst->ref = 1;
|
|
||||||
inst->d = d;
|
|
||||||
}
|
}
|
||||||
g_free(n);
|
g_free(n);
|
||||||
|
|
||||||
return inst;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void obt_instance_ref(ObtInstance *inst)
|
void obt_display_close(Display *d)
|
||||||
{
|
{
|
||||||
++inst->ref;
|
if (d) XCloseDisplay(d);
|
||||||
}
|
|
||||||
|
|
||||||
void obt_instance_unref(ObtInstance *inst)
|
|
||||||
{
|
|
||||||
if (inst && --inst->ref == 0) {
|
|
||||||
XCloseDisplay(inst->d);
|
|
||||||
obt_free0(inst, ObtInstance, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Display* obt_display(const ObtInstance *inst)
|
|
||||||
{
|
|
||||||
return inst->d;
|
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
|
/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
|
||||||
|
|
||||||
obt/instance.h for the Openbox window manager
|
obt/display.h for the Openbox window manager
|
||||||
Copyright (c) 2007 Dana Jansens
|
Copyright (c) 2007 Dana Jansens
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -24,14 +24,8 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
typedef struct _ObtInstance ObtInstance;
|
Display* obt_display_open(const char *display_name);
|
||||||
|
void obt_display_close(Display *d);
|
||||||
/* Instance funcs */
|
|
||||||
ObtInstance* obt_instance_new (const char *display_name);
|
|
||||||
void obt_instance_ref (ObtInstance *inst);
|
|
||||||
void obt_instance_unref (ObtInstance *inst);
|
|
||||||
|
|
||||||
Display* obt_display (const ObtInstance *inst);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
|
/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
|
||||||
|
|
||||||
mainloop.c for the Openbox window manager
|
obt/mainloop.c for the Openbox window manager
|
||||||
Copyright (c) 2006 Mikael Magnusson
|
Copyright (c) 2006 Mikael Magnusson
|
||||||
Copyright (c) 2003-2007 Dana Jansens
|
Copyright (c) 2003-2007 Dana Jansens
|
||||||
|
|
||||||
|
@ -17,25 +17,26 @@
|
||||||
See the COPYING file for a copy of the GNU General Public License.
|
See the COPYING file for a copy of the GNU General Public License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mainloop.h"
|
#include "obt/mainloop.h"
|
||||||
#include "event.h"
|
#include "obt/util.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
typedef struct _ObMainLoopTimer ObMainLoopTimer;
|
typedef struct _ObtMainLoopTimer ObtMainLoopTimer;
|
||||||
typedef struct _ObMainLoopSignal ObMainLoopSignal;
|
typedef struct _ObtMainLoopSignal ObtMainLoopSignal;
|
||||||
typedef struct _ObMainLoopSignalHandlerType ObMainLoopSignalHandlerType;
|
typedef struct _ObtMainLoopSignalHandlerType ObtMainLoopSignalHandlerType;
|
||||||
typedef struct _ObMainLoopXHandlerType ObMainLoopXHandlerType;
|
typedef struct _ObtMainLoopXHandlerType ObtMainLoopXHandlerType;
|
||||||
typedef struct _ObMainLoopFdHandlerType ObMainLoopFdHandlerType;
|
typedef struct _ObtMainLoopFdHandlerType ObtMainLoopFdHandlerType;
|
||||||
|
|
||||||
/* this should be more than the number of possible signals on any
|
/* this should be more than the number of possible signals on any
|
||||||
architecture... */
|
architecture... */
|
||||||
#define NUM_SIGNALS 99
|
#define NUM_SIGNALS 99
|
||||||
|
|
||||||
/* all created ObMainLoops. Used by the signal handler to pass along signals */
|
/* all created ObtMainLoops. Used by the signal handler to pass along
|
||||||
|
signals */
|
||||||
static GSList *all_loops;
|
static GSList *all_loops;
|
||||||
|
|
||||||
/* signals are global to all loops */
|
/* signals are global to all loops */
|
||||||
|
@ -64,11 +65,12 @@ static gint core_signals[] =
|
||||||
#define NUM_CORE_SIGNALS (sizeof(core_signals) / sizeof(core_signals[0]))
|
#define NUM_CORE_SIGNALS (sizeof(core_signals) / sizeof(core_signals[0]))
|
||||||
|
|
||||||
static void sighandler(gint sig);
|
static void sighandler(gint sig);
|
||||||
static void timer_dispatch(ObMainLoop *loop, GTimeVal **wait);
|
static void timer_dispatch(ObtMainLoop *loop, GTimeVal **wait);
|
||||||
static void fd_handler_destroy(gpointer data);
|
static void fd_handler_destroy(gpointer data);
|
||||||
|
|
||||||
struct _ObMainLoop
|
struct _ObtMainLoop
|
||||||
{
|
{
|
||||||
|
gint ref;
|
||||||
Display *display;
|
Display *display;
|
||||||
|
|
||||||
gboolean run; /* do keep running */
|
gboolean run; /* do keep running */
|
||||||
|
@ -90,7 +92,7 @@ struct _ObMainLoop
|
||||||
GSList *signal_handlers[NUM_SIGNALS];
|
GSList *signal_handlers[NUM_SIGNALS];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _ObMainLoopTimer
|
struct _ObtMainLoopTimer
|
||||||
{
|
{
|
||||||
gulong delay;
|
gulong delay;
|
||||||
GSourceFunc func;
|
GSourceFunc func;
|
||||||
|
@ -110,37 +112,38 @@ struct _ObMainLoopTimer
|
||||||
gboolean fired;
|
gboolean fired;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _ObMainLoopSignalHandlerType
|
struct _ObtMainLoopSignalHandlerType
|
||||||
{
|
{
|
||||||
ObMainLoop *loop;
|
ObtMainLoop *loop;
|
||||||
gint signal;
|
gint signal;
|
||||||
gpointer data;
|
gpointer data;
|
||||||
ObMainLoopSignalHandler func;
|
ObtMainLoopSignalHandler func;
|
||||||
GDestroyNotify destroy;
|
GDestroyNotify destroy;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _ObMainLoopXHandlerType
|
struct _ObtMainLoopXHandlerType
|
||||||
{
|
{
|
||||||
ObMainLoop *loop;
|
ObtMainLoop *loop;
|
||||||
gpointer data;
|
gpointer data;
|
||||||
ObMainLoopXHandler func;
|
ObtMainLoopXHandler func;
|
||||||
GDestroyNotify destroy;
|
GDestroyNotify destroy;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _ObMainLoopFdHandlerType
|
struct _ObtMainLoopFdHandlerType
|
||||||
{
|
{
|
||||||
ObMainLoop *loop;
|
ObtMainLoop *loop;
|
||||||
gint fd;
|
gint fd;
|
||||||
gpointer data;
|
gpointer data;
|
||||||
ObMainLoopFdHandler func;
|
ObtMainLoopFdHandler func;
|
||||||
GDestroyNotify destroy;
|
GDestroyNotify destroy;
|
||||||
};
|
};
|
||||||
|
|
||||||
ObMainLoop *ob_main_loop_new(Display *display)
|
ObtMainLoop *obt_main_loop_new(Display *display)
|
||||||
{
|
{
|
||||||
ObMainLoop *loop;
|
ObtMainLoop *loop;
|
||||||
|
|
||||||
loop = g_new0(ObMainLoop, 1);
|
loop = g_new0(ObtMainLoop, 1);
|
||||||
|
loop->ref = 1;
|
||||||
loop->display = display;
|
loop->display = display;
|
||||||
loop->fd_x = ConnectionNumber(display);
|
loop->fd_x = ConnectionNumber(display);
|
||||||
FD_ZERO(&loop->fd_set);
|
FD_ZERO(&loop->fd_set);
|
||||||
|
@ -185,24 +188,29 @@ ObMainLoop *ob_main_loop_new(Display *display)
|
||||||
return loop;
|
return loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ob_main_loop_destroy(ObMainLoop *loop)
|
void obt_main_loop_ref(ObtMainLoop *loop)
|
||||||
|
{
|
||||||
|
++loop->ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
void obt_main_loop_unref(ObtMainLoop *loop)
|
||||||
{
|
{
|
||||||
guint i;
|
guint i;
|
||||||
GSList *it, *next;
|
GSList *it, *next;
|
||||||
|
|
||||||
if (loop) {
|
if (loop && --loop->ref == 0) {
|
||||||
g_assert(loop->running == FALSE);
|
g_assert(loop->running == FALSE);
|
||||||
|
|
||||||
for (it = loop->x_handlers; it; it = next) {
|
for (it = loop->x_handlers; it; it = next) {
|
||||||
ObMainLoopXHandlerType *h = it->data;
|
ObtMainLoopXHandlerType *h = it->data;
|
||||||
next = g_slist_next(it);
|
next = g_slist_next(it);
|
||||||
ob_main_loop_x_remove(loop, h->func);
|
obt_main_loop_x_remove(loop, h->func);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_hash_table_destroy(loop->fd_handlers);
|
g_hash_table_destroy(loop->fd_handlers);
|
||||||
|
|
||||||
for (it = loop->timers; it; it = g_slist_next(it)) {
|
for (it = loop->timers; it; it = g_slist_next(it)) {
|
||||||
ObMainLoopTimer *t = it->data;
|
ObtMainLoopTimer *t = it->data;
|
||||||
if (t->destroy) t->destroy(t->data);
|
if (t->destroy) t->destroy(t->data);
|
||||||
g_free(t);
|
g_free(t);
|
||||||
}
|
}
|
||||||
|
@ -211,9 +219,9 @@ void ob_main_loop_destroy(ObMainLoop *loop)
|
||||||
|
|
||||||
for (i = 0; i < NUM_SIGNALS; ++i)
|
for (i = 0; i < NUM_SIGNALS; ++i)
|
||||||
for (it = loop->signal_handlers[i]; it; it = next) {
|
for (it = loop->signal_handlers[i]; it; it = next) {
|
||||||
ObMainLoopSignalHandlerType *h = it->data;
|
ObtMainLoopSignalHandlerType *h = it->data;
|
||||||
next = g_slist_next(it);
|
next = g_slist_next(it);
|
||||||
ob_main_loop_signal_remove(loop, h->func);
|
obt_main_loop_signal_remove(loop, h->func);
|
||||||
}
|
}
|
||||||
|
|
||||||
all_loops = g_slist_remove(all_loops, loop);
|
all_loops = g_slist_remove(all_loops, loop);
|
||||||
|
@ -230,7 +238,7 @@ void ob_main_loop_destroy(ObMainLoop *loop)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(loop);
|
obt_free0(loop, ObtMainLoop, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,14 +246,14 @@ static void fd_handle_foreach(gpointer key,
|
||||||
gpointer value,
|
gpointer value,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
ObMainLoopFdHandlerType *h = value;
|
ObtMainLoopFdHandlerType *h = value;
|
||||||
fd_set *set = data;
|
fd_set *set = data;
|
||||||
|
|
||||||
if (FD_ISSET(h->fd, set))
|
if (FD_ISSET(h->fd, set))
|
||||||
h->func(h->fd, h->data);
|
h->func(h->fd, h->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ob_main_loop_run(ObMainLoop *loop)
|
void obt_main_loop_run(ObtMainLoop *loop)
|
||||||
{
|
{
|
||||||
XEvent e;
|
XEvent e;
|
||||||
struct timeval *wait;
|
struct timeval *wait;
|
||||||
|
@ -268,7 +276,7 @@ void ob_main_loop_run(ObMainLoop *loop)
|
||||||
while (loop->signals_fired[i]) {
|
while (loop->signals_fired[i]) {
|
||||||
for (it = loop->signal_handlers[i];
|
for (it = loop->signal_handlers[i];
|
||||||
it; it = g_slist_next(it)) {
|
it; it = g_slist_next(it)) {
|
||||||
ObMainLoopSignalHandlerType *h = it->data;
|
ObtMainLoopSignalHandlerType *h = it->data;
|
||||||
h->func(i, h->data);
|
h->func(i, h->data);
|
||||||
}
|
}
|
||||||
loop->signals_fired[i]--;
|
loop->signals_fired[i]--;
|
||||||
|
@ -277,12 +285,12 @@ void ob_main_loop_run(ObMainLoop *loop)
|
||||||
loop->signal_fired = FALSE;
|
loop->signal_fired = FALSE;
|
||||||
|
|
||||||
sigprocmask(SIG_SETMASK, &oldset, NULL);
|
sigprocmask(SIG_SETMASK, &oldset, NULL);
|
||||||
} else if (XPending(loop->display)) {
|
} else if (loop->display && XPending(loop->display)) {
|
||||||
do {
|
do {
|
||||||
XNextEvent(loop->display, &e);
|
XNextEvent(loop->display, &e);
|
||||||
|
|
||||||
for (it = loop->x_handlers; it; it = g_slist_next(it)) {
|
for (it = loop->x_handlers; it; it = g_slist_next(it)) {
|
||||||
ObMainLoopXHandlerType *h = it->data;
|
ObtMainLoopXHandlerType *h = it->data;
|
||||||
h->func(&e, h->data);
|
h->func(&e, h->data);
|
||||||
}
|
}
|
||||||
} while (XPending(loop->display) && loop->run);
|
} while (XPending(loop->display) && loop->run);
|
||||||
|
@ -312,21 +320,21 @@ void ob_main_loop_run(ObMainLoop *loop)
|
||||||
loop->running = FALSE;
|
loop->running = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ob_main_loop_exit(ObMainLoop *loop)
|
void obt_main_loop_exit(ObtMainLoop *loop)
|
||||||
{
|
{
|
||||||
loop->run = FALSE;
|
loop->run = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** XEVENT WATCHERS ***/
|
/*** XEVENT WATCHERS ***/
|
||||||
|
|
||||||
void ob_main_loop_x_add(ObMainLoop *loop,
|
void obt_main_loop_x_add(ObtMainLoop *loop,
|
||||||
ObMainLoopXHandler handler,
|
ObtMainLoopXHandler handler,
|
||||||
gpointer data,
|
gpointer data,
|
||||||
GDestroyNotify notify)
|
GDestroyNotify notify)
|
||||||
{
|
{
|
||||||
ObMainLoopXHandlerType *h;
|
ObtMainLoopXHandlerType *h;
|
||||||
|
|
||||||
h = g_new(ObMainLoopXHandlerType, 1);
|
h = g_new(ObtMainLoopXHandlerType, 1);
|
||||||
h->loop = loop;
|
h->loop = loop;
|
||||||
h->func = handler;
|
h->func = handler;
|
||||||
h->data = data;
|
h->data = data;
|
||||||
|
@ -334,13 +342,13 @@ void ob_main_loop_x_add(ObMainLoop *loop,
|
||||||
loop->x_handlers = g_slist_prepend(loop->x_handlers, h);
|
loop->x_handlers = g_slist_prepend(loop->x_handlers, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ob_main_loop_x_remove(ObMainLoop *loop,
|
void obt_main_loop_x_remove(ObtMainLoop *loop,
|
||||||
ObMainLoopXHandler handler)
|
ObtMainLoopXHandler handler)
|
||||||
{
|
{
|
||||||
GSList *it, *next;
|
GSList *it, *next;
|
||||||
|
|
||||||
for (it = loop->x_handlers; it; it = next) {
|
for (it = loop->x_handlers; it; it = next) {
|
||||||
ObMainLoopXHandlerType *h = it->data;
|
ObtMainLoopXHandlerType *h = it->data;
|
||||||
next = g_slist_next(it);
|
next = g_slist_next(it);
|
||||||
if (h->func == handler) {
|
if (h->func == handler) {
|
||||||
loop->x_handlers = g_slist_delete_link(loop->x_handlers, it);
|
loop->x_handlers = g_slist_delete_link(loop->x_handlers, it);
|
||||||
|
@ -372,23 +380,23 @@ static void sighandler(gint sig)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (it = all_loops; it; it = g_slist_next(it)) {
|
for (it = all_loops; it; it = g_slist_next(it)) {
|
||||||
ObMainLoop *loop = it->data;
|
ObtMainLoop *loop = it->data;
|
||||||
loop->signal_fired = TRUE;
|
loop->signal_fired = TRUE;
|
||||||
loop->signals_fired[sig]++;
|
loop->signals_fired[sig]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ob_main_loop_signal_add(ObMainLoop *loop,
|
void obt_main_loop_signal_add(ObtMainLoop *loop,
|
||||||
gint signal,
|
gint signal,
|
||||||
ObMainLoopSignalHandler handler,
|
ObtMainLoopSignalHandler handler,
|
||||||
gpointer data,
|
gpointer data,
|
||||||
GDestroyNotify notify)
|
GDestroyNotify notify)
|
||||||
{
|
{
|
||||||
ObMainLoopSignalHandlerType *h;
|
ObtMainLoopSignalHandlerType *h;
|
||||||
|
|
||||||
g_return_if_fail(signal < NUM_SIGNALS);
|
g_return_if_fail(signal < NUM_SIGNALS);
|
||||||
|
|
||||||
h = g_new(ObMainLoopSignalHandlerType, 1);
|
h = g_new(ObtMainLoopSignalHandlerType, 1);
|
||||||
h->loop = loop;
|
h->loop = loop;
|
||||||
h->signal = signal;
|
h->signal = signal;
|
||||||
h->func = handler;
|
h->func = handler;
|
||||||
|
@ -412,15 +420,15 @@ void ob_main_loop_signal_add(ObMainLoop *loop,
|
||||||
all_signals[signal].installed++;
|
all_signals[signal].installed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ob_main_loop_signal_remove(ObMainLoop *loop,
|
void obt_main_loop_signal_remove(ObtMainLoop *loop,
|
||||||
ObMainLoopSignalHandler handler)
|
ObtMainLoopSignalHandler handler)
|
||||||
{
|
{
|
||||||
guint i;
|
guint i;
|
||||||
GSList *it, *next;
|
GSList *it, *next;
|
||||||
|
|
||||||
for (i = 0; i < NUM_SIGNALS; ++i) {
|
for (i = 0; i < NUM_SIGNALS; ++i) {
|
||||||
for (it = loop->signal_handlers[i]; it; it = next) {
|
for (it = loop->signal_handlers[i]; it; it = next) {
|
||||||
ObMainLoopSignalHandlerType *h = it->data;
|
ObtMainLoopSignalHandlerType *h = it->data;
|
||||||
|
|
||||||
next = g_slist_next(it);
|
next = g_slist_next(it);
|
||||||
|
|
||||||
|
@ -447,28 +455,28 @@ void ob_main_loop_signal_remove(ObMainLoop *loop,
|
||||||
|
|
||||||
static void max_fd_func(gpointer key, gpointer value, gpointer data)
|
static void max_fd_func(gpointer key, gpointer value, gpointer data)
|
||||||
{
|
{
|
||||||
ObMainLoop *loop = data;
|
ObtMainLoop *loop = data;
|
||||||
|
|
||||||
/* key is the fd */
|
/* key is the fd */
|
||||||
loop->fd_max = MAX(loop->fd_max, *(gint*)key);
|
loop->fd_max = MAX(loop->fd_max, *(gint*)key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void calc_max_fd(ObMainLoop *loop)
|
static void calc_max_fd(ObtMainLoop *loop)
|
||||||
{
|
{
|
||||||
loop->fd_max = loop->fd_x;
|
loop->fd_max = loop->fd_x;
|
||||||
|
|
||||||
g_hash_table_foreach(loop->fd_handlers, max_fd_func, loop);
|
g_hash_table_foreach(loop->fd_handlers, max_fd_func, loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ob_main_loop_fd_add(ObMainLoop *loop,
|
void obt_main_loop_fd_add(ObtMainLoop *loop,
|
||||||
gint fd,
|
gint fd,
|
||||||
ObMainLoopFdHandler handler,
|
ObtMainLoopFdHandler handler,
|
||||||
gpointer data,
|
gpointer data,
|
||||||
GDestroyNotify notify)
|
GDestroyNotify notify)
|
||||||
{
|
{
|
||||||
ObMainLoopFdHandlerType *h;
|
ObtMainLoopFdHandlerType *h;
|
||||||
|
|
||||||
h = g_new(ObMainLoopFdHandlerType, 1);
|
h = g_new(ObtMainLoopFdHandlerType, 1);
|
||||||
h->loop = loop;
|
h->loop = loop;
|
||||||
h->fd = fd;
|
h->fd = fd;
|
||||||
h->func = handler;
|
h->func = handler;
|
||||||
|
@ -482,7 +490,7 @@ void ob_main_loop_fd_add(ObMainLoop *loop,
|
||||||
|
|
||||||
static void fd_handler_destroy(gpointer data)
|
static void fd_handler_destroy(gpointer data)
|
||||||
{
|
{
|
||||||
ObMainLoopFdHandlerType *h = data;
|
ObtMainLoopFdHandlerType *h = data;
|
||||||
|
|
||||||
FD_CLR(h->fd, &h->loop->fd_set);
|
FD_CLR(h->fd, &h->loop->fd_set);
|
||||||
|
|
||||||
|
@ -490,8 +498,8 @@ static void fd_handler_destroy(gpointer data)
|
||||||
h->destroy(h->data);
|
h->destroy(h->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ob_main_loop_fd_remove(ObMainLoop *loop,
|
void obt_main_loop_fd_remove(ObtMainLoop *loop,
|
||||||
gint fd)
|
gint fd)
|
||||||
{
|
{
|
||||||
g_hash_table_remove(loop->fd_handlers, &fd);
|
g_hash_table_remove(loop->fd_handlers, &fd);
|
||||||
}
|
}
|
||||||
|
@ -499,7 +507,7 @@ void ob_main_loop_fd_remove(ObMainLoop *loop,
|
||||||
/*** TIMEOUTS ***/
|
/*** TIMEOUTS ***/
|
||||||
|
|
||||||
#define NEAREST_TIMEOUT(loop) \
|
#define NEAREST_TIMEOUT(loop) \
|
||||||
(((ObMainLoopTimer*)(loop)->timers->data)->timeout)
|
(((ObtMainLoopTimer*)(loop)->timers->data)->timeout)
|
||||||
|
|
||||||
static glong timecompare(GTimeVal *a, GTimeVal *b)
|
static glong timecompare(GTimeVal *a, GTimeVal *b)
|
||||||
{
|
{
|
||||||
|
@ -508,7 +516,7 @@ static glong timecompare(GTimeVal *a, GTimeVal *b)
|
||||||
return a->tv_usec - b->tv_usec;
|
return a->tv_usec - b->tv_usec;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void insert_timer(ObMainLoop *loop, ObMainLoopTimer *ins)
|
static void insert_timer(ObtMainLoop *loop, ObtMainLoopTimer *ins)
|
||||||
{
|
{
|
||||||
GSList *it;
|
GSList *it;
|
||||||
for (it = loop->timers; it; it = g_slist_next(it)) {
|
for (it = loop->timers; it; it = g_slist_next(it)) {
|
||||||
|
@ -522,12 +530,12 @@ static void insert_timer(ObMainLoop *loop, ObMainLoopTimer *ins)
|
||||||
loop->timers = g_slist_append(loop->timers, ins);
|
loop->timers = g_slist_append(loop->timers, ins);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ob_main_loop_timeout_add(ObMainLoop *loop,
|
void obt_main_loop_timeout_add(ObtMainLoop *loop,
|
||||||
gulong microseconds,
|
gulong microseconds,
|
||||||
GSourceFunc handler,
|
GSourceFunc handler,
|
||||||
gpointer data,
|
gpointer data,
|
||||||
GEqualFunc cmp,
|
GEqualFunc cmp,
|
||||||
GDestroyNotify notify)
|
GDestroyNotify notify)
|
||||||
{
|
{
|
||||||
ObMainLoopTimer *t = g_new(ObMainLoopTimer, 1);
|
ObMainLoopTimer *t = g_new(ObMainLoopTimer, 1);
|
||||||
|
|
||||||
|
@ -546,25 +554,25 @@ void ob_main_loop_timeout_add(ObMainLoop *loop,
|
||||||
insert_timer(loop, t);
|
insert_timer(loop, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ob_main_loop_timeout_remove(ObMainLoop *loop,
|
void obt_main_loop_timeout_remove(ObtMainLoop *loop,
|
||||||
GSourceFunc handler)
|
GSourceFunc handler)
|
||||||
{
|
{
|
||||||
GSList *it;
|
GSList *it;
|
||||||
|
|
||||||
for (it = loop->timers; it; it = g_slist_next(it)) {
|
for (it = loop->timers; it; it = g_slist_next(it)) {
|
||||||
ObMainLoopTimer *t = it->data;
|
ObtMainLoopTimer *t = it->data;
|
||||||
if (t->func == handler)
|
if (t->func == handler)
|
||||||
t->del_me = TRUE;
|
t->del_me = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ob_main_loop_timeout_remove_data(ObMainLoop *loop, GSourceFunc handler,
|
void obt_main_loop_timeout_remove_data(ObtMainLoop *loop, GSourceFunc handler,
|
||||||
gpointer data, gboolean cancel_dest)
|
gpointer data, gboolean cancel_dest)
|
||||||
{
|
{
|
||||||
GSList *it;
|
GSList *it;
|
||||||
|
|
||||||
for (it = loop->timers; it; it = g_slist_next(it)) {
|
for (it = loop->timers; it; it = g_slist_next(it)) {
|
||||||
ObMainLoopTimer *t = it->data;
|
ObtMainLoopTimer *t = it->data;
|
||||||
if (t->func == handler && t->equal(t->data, data)) {
|
if (t->func == handler && t->equal(t->data, data)) {
|
||||||
t->del_me = TRUE;
|
t->del_me = TRUE;
|
||||||
if (cancel_dest)
|
if (cancel_dest)
|
||||||
|
@ -574,7 +582,7 @@ void ob_main_loop_timeout_remove_data(ObMainLoop *loop, GSourceFunc handler,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* find the time to wait for the nearest timeout */
|
/* find the time to wait for the nearest timeout */
|
||||||
static gboolean nearest_timeout_wait(ObMainLoop *loop, GTimeVal *tm)
|
static gboolean nearest_timeout_wait(ObtMainLoop *loop, GTimeVal *tm)
|
||||||
{
|
{
|
||||||
if (loop->timers == NULL)
|
if (loop->timers == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -594,7 +602,7 @@ static gboolean nearest_timeout_wait(ObMainLoop *loop, GTimeVal *tm)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void timer_dispatch(ObMainLoop *loop, GTimeVal **wait)
|
static void timer_dispatch(ObtMainLoop *loop, GTimeVal **wait)
|
||||||
{
|
{
|
||||||
GSList *it, *next;
|
GSList *it, *next;
|
||||||
|
|
||||||
|
@ -603,7 +611,7 @@ static void timer_dispatch(ObMainLoop *loop, GTimeVal **wait)
|
||||||
g_get_current_time(&loop->now);
|
g_get_current_time(&loop->now);
|
||||||
|
|
||||||
for (it = loop->timers; it; it = next) {
|
for (it = loop->timers; it; it = next) {
|
||||||
ObMainLoopTimer *curr;
|
ObtMainLoopTimer *curr;
|
||||||
|
|
||||||
next = g_slist_next(it);
|
next = g_slist_next(it);
|
||||||
|
|
77
obt/mainloop.h
Normal file
77
obt/mainloop.h
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
|
||||||
|
|
||||||
|
obt/mainloop.h for the Openbox window manager
|
||||||
|
Copyright (c) 2006 Mikael Magnusson
|
||||||
|
Copyright (c) 2003-2007 Dana Jansens
|
||||||
|
|
||||||
|
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 of the License, 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.
|
||||||
|
|
||||||
|
See the COPYING file for a copy of the GNU General Public License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __obt_mainloop_h
|
||||||
|
#define __obt_mainloop_h
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
typedef struct _ObtMainLoop ObtMainLoop;
|
||||||
|
|
||||||
|
ObtMainLoop *obt_main_loop_new(Display *display);
|
||||||
|
void obt_main_loop_ref(ObtMainLoop *loop);
|
||||||
|
void obt_main_loop_unref(ObtMainLoop *loop);
|
||||||
|
|
||||||
|
typedef void (*ObtMainLoopXHandler) (const XEvent *e, gpointer data);
|
||||||
|
|
||||||
|
void obt_main_loop_x_add(ObtMainLoop *loop,
|
||||||
|
ObtMainLoopXHandler handler,
|
||||||
|
gpointer data,
|
||||||
|
GDestroyNotify notify);
|
||||||
|
void obt_main_loop_x_remove(ObtMainLoop *loop,
|
||||||
|
ObtMainLoopXHandler handler);
|
||||||
|
|
||||||
|
typedef void (*ObtMainLoopFdHandler) (gint fd, gpointer data);
|
||||||
|
|
||||||
|
void obt_main_loop_fd_add(ObtMainLoop *loop,
|
||||||
|
gint fd,
|
||||||
|
ObtMainLoopFdHandler handler,
|
||||||
|
gpointer data,
|
||||||
|
GDestroyNotify notify);
|
||||||
|
void obt_main_loop_fd_remove(ObtMainLoop *loop,
|
||||||
|
gint fd);
|
||||||
|
|
||||||
|
typedef void (*ObtMainLoopSignalHandler) (gint signal, gpointer data);
|
||||||
|
|
||||||
|
void obt_main_loop_signal_add(ObtMainLoop *loop,
|
||||||
|
gint signal,
|
||||||
|
ObtMainLoopSignalHandler handler,
|
||||||
|
gpointer data,
|
||||||
|
GDestroyNotify notify);
|
||||||
|
void obt_main_loop_signal_remove(ObtMainLoop *loop,
|
||||||
|
ObtMainLoopSignalHandler handler);
|
||||||
|
|
||||||
|
void obt_main_loop_timeout_add(ObtMainLoop *loop,
|
||||||
|
gulong microseconds,
|
||||||
|
GSourceFunc handler,
|
||||||
|
gpointer data,
|
||||||
|
GEqualFunc cmp,
|
||||||
|
GDestroyNotify notify);
|
||||||
|
void obt_main_loop_timeout_remove(ObtMainLoop *loop,
|
||||||
|
GSourceFunc handler);
|
||||||
|
void obt_main_loop_timeout_remove_data(ObtMainLoop *loop,
|
||||||
|
GSourceFunc handler,
|
||||||
|
gpointer data,
|
||||||
|
gboolean cancel_dest);
|
||||||
|
|
||||||
|
void obt_main_loop_run(ObtMainLoop *loop);
|
||||||
|
void obt_main_loop_exit(ObtMainLoop *loop);
|
||||||
|
|
||||||
|
#endif
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "dock.h"
|
#include "dock.h"
|
||||||
#include "mainloop.h"
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "prop.h"
|
#include "prop.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -630,19 +629,21 @@ void dock_hide(gboolean hide)
|
||||||
{
|
{
|
||||||
if (!hide) {
|
if (!hide) {
|
||||||
if (dock->hidden && config_dock_hide) {
|
if (dock->hidden && config_dock_hide) {
|
||||||
ob_main_loop_timeout_add(ob_main_loop,
|
obt_main_loop_timeout_add(ob_main_loop,
|
||||||
config_dock_show_delay * 1000,
|
config_dock_show_delay * 1000,
|
||||||
show_timeout, NULL, g_direct_equal, NULL);
|
show_timeout, NULL,
|
||||||
|
g_direct_equal, NULL);
|
||||||
} else if (!dock->hidden && config_dock_hide) {
|
} else if (!dock->hidden && config_dock_hide) {
|
||||||
ob_main_loop_timeout_remove(ob_main_loop, hide_timeout);
|
obt_main_loop_timeout_remove(ob_main_loop, hide_timeout);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!dock->hidden && config_dock_hide) {
|
if (!dock->hidden && config_dock_hide) {
|
||||||
ob_main_loop_timeout_add(ob_main_loop,
|
obt_main_loop_timeout_add(ob_main_loop,
|
||||||
config_dock_hide_delay * 1000,
|
config_dock_hide_delay * 1000,
|
||||||
hide_timeout, NULL, g_direct_equal, NULL);
|
hide_timeout, NULL,
|
||||||
|
g_direct_equal, NULL);
|
||||||
} else if (dock->hidden && config_dock_hide) {
|
} else if (dock->hidden && config_dock_hide) {
|
||||||
ob_main_loop_timeout_remove(ob_main_loop, show_timeout);
|
obt_main_loop_timeout_remove(ob_main_loop, show_timeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
#include "modkeys.h"
|
#include "modkeys.h"
|
||||||
#include "mouse.h"
|
#include "mouse.h"
|
||||||
#include "mainloop.h"
|
|
||||||
#include "focus.h"
|
#include "focus.h"
|
||||||
#include "focus_cycle.h"
|
#include "focus_cycle.h"
|
||||||
#include "moveresize.h"
|
#include "moveresize.h"
|
||||||
|
@ -123,9 +122,9 @@ static void ice_watch(IceConn conn, IcePointer data, Bool opening,
|
||||||
|
|
||||||
if (opening) {
|
if (opening) {
|
||||||
fd = IceConnectionNumber(conn);
|
fd = IceConnectionNumber(conn);
|
||||||
ob_main_loop_fd_add(ob_main_loop, fd, ice_handler, conn, NULL);
|
obt_main_loop_fd_add(ob_main_loop, fd, ice_handler, conn, NULL);
|
||||||
} else {
|
} else {
|
||||||
ob_main_loop_fd_remove(ob_main_loop, fd);
|
obt_main_loop_fd_remove(ob_main_loop, fd);
|
||||||
fd = -1;
|
fd = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +134,7 @@ void event_startup(gboolean reconfig)
|
||||||
{
|
{
|
||||||
if (reconfig) return;
|
if (reconfig) return;
|
||||||
|
|
||||||
ob_main_loop_x_add(ob_main_loop, event_process, NULL, NULL);
|
obt_main_loop_x_add(ob_main_loop, event_process, NULL, NULL);
|
||||||
|
|
||||||
#ifdef USE_SM
|
#ifdef USE_SM
|
||||||
IceAddConnectionWatch(ice_watch, NULL);
|
IceAddConnectionWatch(ice_watch, NULL);
|
||||||
|
@ -800,17 +799,17 @@ void event_enter_client(ObClient *client)
|
||||||
if (config_focus_delay) {
|
if (config_focus_delay) {
|
||||||
ObFocusDelayData *data;
|
ObFocusDelayData *data;
|
||||||
|
|
||||||
ob_main_loop_timeout_remove(ob_main_loop, focus_delay_func);
|
obt_main_loop_timeout_remove(ob_main_loop, focus_delay_func);
|
||||||
|
|
||||||
data = g_new(ObFocusDelayData, 1);
|
data = g_new(ObFocusDelayData, 1);
|
||||||
data->client = client;
|
data->client = client;
|
||||||
data->time = event_curtime;
|
data->time = event_curtime;
|
||||||
data->serial = event_curserial;
|
data->serial = event_curserial;
|
||||||
|
|
||||||
ob_main_loop_timeout_add(ob_main_loop,
|
obt_main_loop_timeout_add(ob_main_loop,
|
||||||
config_focus_delay * 1000,
|
config_focus_delay * 1000,
|
||||||
focus_delay_func,
|
focus_delay_func,
|
||||||
data, focus_delay_cmp, focus_delay_dest);
|
data, focus_delay_cmp, focus_delay_dest);
|
||||||
} else {
|
} else {
|
||||||
ObFocusDelayData data;
|
ObFocusDelayData data;
|
||||||
data.client = client;
|
data.client = client;
|
||||||
|
@ -1000,9 +999,9 @@ static void event_handle_client(ObClient *client, XEvent *e)
|
||||||
delay is up */
|
delay is up */
|
||||||
e->xcrossing.detail != NotifyInferior)
|
e->xcrossing.detail != NotifyInferior)
|
||||||
{
|
{
|
||||||
ob_main_loop_timeout_remove_data(ob_main_loop,
|
obt_main_loop_timeout_remove_data(ob_main_loop,
|
||||||
focus_delay_func,
|
focus_delay_func,
|
||||||
client, FALSE);
|
client, FALSE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1914,15 +1913,15 @@ static gboolean focus_delay_func(gpointer data)
|
||||||
|
|
||||||
static void focus_delay_client_dest(ObClient *client, gpointer data)
|
static void focus_delay_client_dest(ObClient *client, gpointer data)
|
||||||
{
|
{
|
||||||
ob_main_loop_timeout_remove_data(ob_main_loop, focus_delay_func,
|
obt_main_loop_timeout_remove_data(ob_main_loop, focus_delay_func,
|
||||||
client, FALSE);
|
client, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void event_halt_focus_delay(void)
|
void event_halt_focus_delay(void)
|
||||||
{
|
{
|
||||||
/* ignore all enter events up till the event which caused this to occur */
|
/* ignore all enter events up till the event which caused this to occur */
|
||||||
if (event_curserial) event_ignore_enter_range(1, event_curserial);
|
if (event_curserial) event_ignore_enter_range(1, event_curserial);
|
||||||
ob_main_loop_timeout_remove(ob_main_loop, focus_delay_func);
|
obt_main_loop_timeout_remove(ob_main_loop, focus_delay_func);
|
||||||
}
|
}
|
||||||
|
|
||||||
gulong event_start_ignore_all_enters(void)
|
gulong event_start_ignore_all_enters(void)
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include "grab.h"
|
#include "grab.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "framerender.h"
|
#include "framerender.h"
|
||||||
#include "mainloop.h"
|
|
||||||
#include "focus_cycle.h"
|
#include "focus_cycle.h"
|
||||||
#include "focus_cycle_indicator.h"
|
#include "focus_cycle_indicator.h"
|
||||||
#include "moveresize.h"
|
#include "moveresize.h"
|
||||||
|
@ -1053,8 +1052,8 @@ void frame_release_client(ObFrame *self)
|
||||||
gboolean reparent = TRUE;
|
gboolean reparent = TRUE;
|
||||||
|
|
||||||
/* if there was any animation going on, kill it */
|
/* if there was any animation going on, kill it */
|
||||||
ob_main_loop_timeout_remove_data(ob_main_loop, frame_animate_iconify,
|
obt_main_loop_timeout_remove_data(ob_main_loop, frame_animate_iconify,
|
||||||
self, FALSE);
|
self, FALSE);
|
||||||
|
|
||||||
/* check if the app has already reparented its window away */
|
/* check if the app has already reparented its window away */
|
||||||
while (XCheckTypedWindowEvent(ob_display, self->client->window,
|
while (XCheckTypedWindowEvent(ob_display, self->client->window,
|
||||||
|
@ -1130,7 +1129,7 @@ void frame_release_client(ObFrame *self)
|
||||||
g_hash_table_remove(window_map, &self->rgriptop);
|
g_hash_table_remove(window_map, &self->rgriptop);
|
||||||
g_hash_table_remove(window_map, &self->rgripbottom);
|
g_hash_table_remove(window_map, &self->rgripbottom);
|
||||||
|
|
||||||
ob_main_loop_timeout_remove_data(ob_main_loop, flash_timeout, self, TRUE);
|
obt_main_loop_timeout_remove_data(ob_main_loop, flash_timeout, self, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* is there anything present between us and the label? */
|
/* is there anything present between us and the label? */
|
||||||
|
@ -1651,12 +1650,12 @@ void frame_flash_start(ObFrame *self)
|
||||||
self->flash_on = self->focused;
|
self->flash_on = self->focused;
|
||||||
|
|
||||||
if (!self->flashing)
|
if (!self->flashing)
|
||||||
ob_main_loop_timeout_add(ob_main_loop,
|
obt_main_loop_timeout_add(ob_main_loop,
|
||||||
G_USEC_PER_SEC * 0.6,
|
G_USEC_PER_SEC * 0.6,
|
||||||
flash_timeout,
|
flash_timeout,
|
||||||
self,
|
self,
|
||||||
g_direct_equal,
|
g_direct_equal,
|
||||||
flash_done);
|
flash_done);
|
||||||
g_get_current_time(&self->flash_end);
|
g_get_current_time(&self->flash_end);
|
||||||
g_time_val_add(&self->flash_end, G_USEC_PER_SEC * 5);
|
g_time_val_add(&self->flash_end, G_USEC_PER_SEC * 5);
|
||||||
|
|
||||||
|
@ -1815,12 +1814,12 @@ void frame_begin_iconify_animation(ObFrame *self, gboolean iconifying)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_anim) {
|
if (new_anim) {
|
||||||
ob_main_loop_timeout_remove_data(ob_main_loop, frame_animate_iconify,
|
obt_main_loop_timeout_remove_data(ob_main_loop, frame_animate_iconify,
|
||||||
self, FALSE);
|
self, FALSE);
|
||||||
ob_main_loop_timeout_add(ob_main_loop,
|
obt_main_loop_timeout_add(ob_main_loop,
|
||||||
FRAME_ANIMATE_ICONIFY_STEP_TIME,
|
FRAME_ANIMATE_ICONIFY_STEP_TIME,
|
||||||
frame_animate_iconify, self,
|
frame_animate_iconify, self,
|
||||||
g_direct_equal, NULL);
|
g_direct_equal, NULL);
|
||||||
|
|
||||||
/* do the first step */
|
/* do the first step */
|
||||||
frame_animate_iconify(self);
|
frame_animate_iconify(self);
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
See the COPYING file for a copy of the GNU General Public License.
|
See the COPYING file for a copy of the GNU General Public License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mainloop.h"
|
|
||||||
#include "focus.h"
|
#include "focus.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "frame.h"
|
#include "frame.h"
|
||||||
|
@ -221,7 +220,7 @@ void keyboard_event(ObClient *client, const XEvent *e)
|
||||||
if (e->xkey.keycode == config_keyboard_reset_keycode &&
|
if (e->xkey.keycode == config_keyboard_reset_keycode &&
|
||||||
e->xkey.state == config_keyboard_reset_state)
|
e->xkey.state == config_keyboard_reset_state)
|
||||||
{
|
{
|
||||||
ob_main_loop_timeout_remove(ob_main_loop, chain_timeout);
|
obt_main_loop_timeout_remove(ob_main_loop, chain_timeout);
|
||||||
keyboard_reset_chains(-1);
|
keyboard_reset_chains(-1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -239,11 +238,11 @@ void keyboard_event(ObClient *client, const XEvent *e)
|
||||||
menu_frame_hide_all();
|
menu_frame_hide_all();
|
||||||
|
|
||||||
if (p->first_child != NULL) { /* part of a chain */
|
if (p->first_child != NULL) { /* part of a chain */
|
||||||
ob_main_loop_timeout_remove(ob_main_loop, chain_timeout);
|
obt_main_loop_timeout_remove(ob_main_loop, chain_timeout);
|
||||||
/* 3 second timeout for chains */
|
/* 3 second timeout for chains */
|
||||||
ob_main_loop_timeout_add(ob_main_loop, 3 * G_USEC_PER_SEC,
|
obt_main_loop_timeout_add(ob_main_loop, 3 * G_USEC_PER_SEC,
|
||||||
chain_timeout, NULL,
|
chain_timeout, NULL,
|
||||||
g_direct_equal, NULL);
|
g_direct_equal, NULL);
|
||||||
set_curpos(p);
|
set_curpos(p);
|
||||||
} else if (p->chroot) /* an empty chroot */
|
} else if (p->chroot) /* an empty chroot */
|
||||||
set_curpos(p);
|
set_curpos(p);
|
||||||
|
@ -280,7 +279,7 @@ void keyboard_startup(gboolean reconfig)
|
||||||
|
|
||||||
void keyboard_shutdown(gboolean reconfig)
|
void keyboard_shutdown(gboolean reconfig)
|
||||||
{
|
{
|
||||||
ob_main_loop_timeout_remove(ob_main_loop, chain_timeout);
|
obt_main_loop_timeout_remove(ob_main_loop, chain_timeout);
|
||||||
|
|
||||||
keyboard_unbind_all();
|
keyboard_unbind_all();
|
||||||
set_curpos(NULL);
|
set_curpos(NULL);
|
||||||
|
|
|
@ -1,76 +0,0 @@
|
||||||
/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
|
|
||||||
|
|
||||||
mainloop.h for the Openbox window manager
|
|
||||||
Copyright (c) 2006 Mikael Magnusson
|
|
||||||
Copyright (c) 2003-2007 Dana Jansens
|
|
||||||
|
|
||||||
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 of the License, 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.
|
|
||||||
|
|
||||||
See the COPYING file for a copy of the GNU General Public License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __ob__mainloop_h
|
|
||||||
#define __ob__mainloop_h
|
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
typedef struct _ObMainLoop ObMainLoop;
|
|
||||||
|
|
||||||
ObMainLoop *ob_main_loop_new(Display *display);
|
|
||||||
void ob_main_loop_destroy(ObMainLoop *loop);
|
|
||||||
|
|
||||||
typedef void (*ObMainLoopXHandler) (const XEvent *e, gpointer data);
|
|
||||||
|
|
||||||
void ob_main_loop_x_add(ObMainLoop *loop,
|
|
||||||
ObMainLoopXHandler handler,
|
|
||||||
gpointer data,
|
|
||||||
GDestroyNotify notify);
|
|
||||||
void ob_main_loop_x_remove(ObMainLoop *loop,
|
|
||||||
ObMainLoopXHandler handler);
|
|
||||||
|
|
||||||
typedef void (*ObMainLoopFdHandler) (gint fd, gpointer data);
|
|
||||||
|
|
||||||
void ob_main_loop_fd_add(ObMainLoop *loop,
|
|
||||||
gint fd,
|
|
||||||
ObMainLoopFdHandler handler,
|
|
||||||
gpointer data,
|
|
||||||
GDestroyNotify notify);
|
|
||||||
void ob_main_loop_fd_remove(ObMainLoop *loop,
|
|
||||||
gint fd);
|
|
||||||
|
|
||||||
typedef void (*ObMainLoopSignalHandler) (gint signal, gpointer data);
|
|
||||||
|
|
||||||
void ob_main_loop_signal_add(ObMainLoop *loop,
|
|
||||||
gint signal,
|
|
||||||
ObMainLoopSignalHandler handler,
|
|
||||||
gpointer data,
|
|
||||||
GDestroyNotify notify);
|
|
||||||
void ob_main_loop_signal_remove(ObMainLoop *loop,
|
|
||||||
ObMainLoopSignalHandler handler);
|
|
||||||
|
|
||||||
void ob_main_loop_timeout_add(ObMainLoop *loop,
|
|
||||||
gulong microseconds,
|
|
||||||
GSourceFunc handler,
|
|
||||||
gpointer data,
|
|
||||||
GEqualFunc cmp,
|
|
||||||
GDestroyNotify notify);
|
|
||||||
void ob_main_loop_timeout_remove(ObMainLoop *loop,
|
|
||||||
GSourceFunc handler);
|
|
||||||
void ob_main_loop_timeout_remove_data(ObMainLoop *loop,
|
|
||||||
GSourceFunc handler,
|
|
||||||
gpointer data,
|
|
||||||
gboolean cancel_dest);
|
|
||||||
|
|
||||||
void ob_main_loop_run(ObMainLoop *loop);
|
|
||||||
void ob_main_loop_exit(ObMainLoop *loop);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -20,7 +20,6 @@
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "openbox.h"
|
#include "openbox.h"
|
||||||
#include "mainloop.h"
|
|
||||||
#include "stacking.h"
|
#include "stacking.h"
|
||||||
#include "grab.h"
|
#include "grab.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
@ -457,10 +456,10 @@ void menu_show(gchar *name, gint x, gint y, gboolean mouse, ObClient *client)
|
||||||
menu_can_hide = TRUE;
|
menu_can_hide = TRUE;
|
||||||
else {
|
else {
|
||||||
menu_can_hide = FALSE;
|
menu_can_hide = FALSE;
|
||||||
ob_main_loop_timeout_add(ob_main_loop,
|
obt_main_loop_timeout_add(ob_main_loop,
|
||||||
config_menu_hide_delay * 1000,
|
config_menu_hide_delay * 1000,
|
||||||
menu_hide_delay_func,
|
menu_hide_delay_func,
|
||||||
NULL, g_direct_equal, NULL);
|
NULL, g_direct_equal, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include "actions.h"
|
#include "actions.h"
|
||||||
#include "grab.h"
|
#include "grab.h"
|
||||||
#include "openbox.h"
|
#include "openbox.h"
|
||||||
#include "mainloop.h"
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "render/theme.h"
|
#include "render/theme.h"
|
||||||
|
|
||||||
|
@ -1063,8 +1062,8 @@ void menu_frame_hide_all(void)
|
||||||
|
|
||||||
if (config_submenu_show_delay) {
|
if (config_submenu_show_delay) {
|
||||||
/* remove any submenu open requests */
|
/* remove any submenu open requests */
|
||||||
ob_main_loop_timeout_remove(ob_main_loop,
|
obt_main_loop_timeout_remove(ob_main_loop,
|
||||||
menu_entry_frame_submenu_timeout);
|
menu_entry_frame_submenu_timeout);
|
||||||
}
|
}
|
||||||
if ((it = g_list_last(menu_frame_visible)))
|
if ((it = g_list_last(menu_frame_visible)))
|
||||||
menu_frame_hide(it->data);
|
menu_frame_hide(it->data);
|
||||||
|
@ -1078,8 +1077,8 @@ void menu_frame_hide_all_client(ObClient *client)
|
||||||
if (f->client == client) {
|
if (f->client == client) {
|
||||||
if (config_submenu_show_delay) {
|
if (config_submenu_show_delay) {
|
||||||
/* remove any submenu open requests */
|
/* remove any submenu open requests */
|
||||||
ob_main_loop_timeout_remove(ob_main_loop,
|
obt_main_loop_timeout_remove(ob_main_loop,
|
||||||
menu_entry_frame_submenu_timeout);
|
menu_entry_frame_submenu_timeout);
|
||||||
}
|
}
|
||||||
menu_frame_hide(f);
|
menu_frame_hide(f);
|
||||||
}
|
}
|
||||||
|
@ -1145,8 +1144,8 @@ void menu_frame_select(ObMenuFrame *self, ObMenuEntryFrame *entry,
|
||||||
|
|
||||||
if (config_submenu_show_delay) {
|
if (config_submenu_show_delay) {
|
||||||
/* remove any submenu open requests */
|
/* remove any submenu open requests */
|
||||||
ob_main_loop_timeout_remove(ob_main_loop,
|
obt_main_loop_timeout_remove(ob_main_loop,
|
||||||
menu_entry_frame_submenu_timeout);
|
menu_entry_frame_submenu_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
self->selected = entry;
|
self->selected = entry;
|
||||||
|
@ -1162,11 +1161,11 @@ void menu_frame_select(ObMenuFrame *self, ObMenuEntryFrame *entry,
|
||||||
if (self->selected->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU) {
|
if (self->selected->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU) {
|
||||||
if (config_submenu_show_delay && !immediate) {
|
if (config_submenu_show_delay && !immediate) {
|
||||||
/* initiate a new submenu open request */
|
/* initiate a new submenu open request */
|
||||||
ob_main_loop_timeout_add(ob_main_loop,
|
obt_main_loop_timeout_add(ob_main_loop,
|
||||||
config_submenu_show_delay * 1000,
|
config_submenu_show_delay * 1000,
|
||||||
menu_entry_frame_submenu_timeout,
|
menu_entry_frame_submenu_timeout,
|
||||||
self->selected, g_direct_equal,
|
self->selected, g_direct_equal,
|
||||||
NULL);
|
NULL);
|
||||||
} else {
|
} else {
|
||||||
menu_entry_frame_show_submenu(self->selected);
|
menu_entry_frame_show_submenu(self->selected);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include "frame.h"
|
#include "frame.h"
|
||||||
#include "openbox.h"
|
#include "openbox.h"
|
||||||
#include "resist.h"
|
#include "resist.h"
|
||||||
#include "mainloop.h"
|
|
||||||
#include "modkeys.h"
|
#include "modkeys.h"
|
||||||
#include "popup.h"
|
#include "popup.h"
|
||||||
#include "moveresize.h"
|
#include "moveresize.h"
|
||||||
|
@ -311,7 +310,7 @@ void moveresize_end(gboolean cancel)
|
||||||
moveresize_alarm = None;
|
moveresize_alarm = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
ob_main_loop_timeout_remove(ob_main_loop, sync_timeout_func);
|
obt_main_loop_timeout_remove(ob_main_loop, sync_timeout_func);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
client_configure(moveresize_client,
|
client_configure(moveresize_client,
|
||||||
|
@ -396,10 +395,10 @@ static void do_resize(void)
|
||||||
|
|
||||||
waiting_for_sync = TRUE;
|
waiting_for_sync = TRUE;
|
||||||
|
|
||||||
ob_main_loop_timeout_remove(ob_main_loop, sync_timeout_func);
|
obt_main_loop_timeout_remove(ob_main_loop, sync_timeout_func);
|
||||||
ob_main_loop_timeout_add(ob_main_loop, G_USEC_PER_SEC * 2,
|
obt_main_loop_timeout_add(ob_main_loop, G_USEC_PER_SEC * 2,
|
||||||
sync_timeout_func,
|
sync_timeout_func,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -578,10 +577,10 @@ static void do_edge_warp(gint x, gint y)
|
||||||
cancel_edge_warp();
|
cancel_edge_warp();
|
||||||
if (dir != (ObDirection)-1) {
|
if (dir != (ObDirection)-1) {
|
||||||
edge_warp_odd = TRUE; /* switch on the first timeout */
|
edge_warp_odd = TRUE; /* switch on the first timeout */
|
||||||
ob_main_loop_timeout_add(ob_main_loop,
|
obt_main_loop_timeout_add(ob_main_loop,
|
||||||
config_mouse_screenedgetime * 1000,
|
config_mouse_screenedgetime * 1000,
|
||||||
edge_warp_delay_func,
|
edge_warp_delay_func,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
edge_warp_dir = dir;
|
edge_warp_dir = dir;
|
||||||
}
|
}
|
||||||
|
@ -589,7 +588,7 @@ static void do_edge_warp(gint x, gint y)
|
||||||
|
|
||||||
static void cancel_edge_warp(void)
|
static void cancel_edge_warp(void)
|
||||||
{
|
{
|
||||||
ob_main_loop_timeout_remove(ob_main_loop, edge_warp_delay_func);
|
obt_main_loop_timeout_remove(ob_main_loop, edge_warp_delay_func);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void move_with_keys(gint keycode, gint state)
|
static void move_with_keys(gint keycode, gint state)
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
#include "parser/parse.h"
|
#include "parser/parse.h"
|
||||||
#include "render/render.h"
|
#include "render/render.h"
|
||||||
#include "render/theme.h"
|
#include "render/theme.h"
|
||||||
#include "obt/obt.h"
|
#include "obt/display.h"
|
||||||
|
|
||||||
#ifdef HAVE_FCNTL_H
|
#ifdef HAVE_FCNTL_H
|
||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
|
@ -84,10 +84,9 @@
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
|
|
||||||
ObtInstance *obt_inst;
|
|
||||||
RrInstance *ob_rr_inst;
|
RrInstance *ob_rr_inst;
|
||||||
RrTheme *ob_rr_theme;
|
RrTheme *ob_rr_theme;
|
||||||
ObMainLoop *ob_main_loop;
|
ObtMainLoop *ob_main_loop;
|
||||||
Display *ob_display;
|
Display *ob_display;
|
||||||
gint ob_screen;
|
gint ob_screen;
|
||||||
gboolean ob_replace_wm = FALSE;
|
gboolean ob_replace_wm = FALSE;
|
||||||
|
@ -145,10 +144,9 @@ gint main(gint argc, gchar **argv)
|
||||||
session_startup(argc, argv);
|
session_startup(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
obt_inst = obt_instance_new(NULL);
|
ob_display = obt_display_open(NULL);
|
||||||
if (obt_inst == NULL)
|
if (ob_display == NULL)
|
||||||
ob_exit_with_error(_("Failed to open the display from the DISPLAY environment variable."));
|
ob_exit_with_error(_("Failed to open the display from the DISPLAY environment variable."));
|
||||||
ob_display = obt_display(obt_inst);
|
|
||||||
|
|
||||||
if (remote_control) {
|
if (remote_control) {
|
||||||
prop_startup();
|
prop_startup();
|
||||||
|
@ -158,20 +156,20 @@ gint main(gint argc, gchar **argv)
|
||||||
* remote_control = 2 -> restart */
|
* remote_control = 2 -> restart */
|
||||||
PROP_MSG(RootWindow(ob_display, ob_screen),
|
PROP_MSG(RootWindow(ob_display, ob_screen),
|
||||||
ob_control, remote_control, 0, 0, 0);
|
ob_control, remote_control, 0, 0, 0);
|
||||||
obt_instance_unref(obt_inst);
|
obt_display_close(ob_display);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
ob_main_loop = ob_main_loop_new(ob_display);
|
ob_main_loop = obt_main_loop_new(ob_display);
|
||||||
|
|
||||||
/* set up signal handler */
|
/* set up signal handler */
|
||||||
ob_main_loop_signal_add(ob_main_loop, SIGUSR1, signal_handler, NULL, NULL);
|
obt_main_loop_signal_add(ob_main_loop, SIGUSR1, signal_handler, NULL,NULL);
|
||||||
ob_main_loop_signal_add(ob_main_loop, SIGUSR2, signal_handler, NULL, NULL);
|
obt_main_loop_signal_add(ob_main_loop, SIGUSR2, signal_handler, NULL,NULL);
|
||||||
ob_main_loop_signal_add(ob_main_loop, SIGTERM, signal_handler, NULL, NULL);
|
obt_main_loop_signal_add(ob_main_loop, SIGTERM, signal_handler, NULL,NULL);
|
||||||
ob_main_loop_signal_add(ob_main_loop, SIGINT, signal_handler, NULL, NULL);
|
obt_main_loop_signal_add(ob_main_loop, SIGINT, signal_handler, NULL,NULL);
|
||||||
ob_main_loop_signal_add(ob_main_loop, SIGHUP, signal_handler, NULL, NULL);
|
obt_main_loop_signal_add(ob_main_loop, SIGHUP, signal_handler, NULL,NULL);
|
||||||
ob_main_loop_signal_add(ob_main_loop, SIGPIPE, signal_handler, NULL, NULL);
|
obt_main_loop_signal_add(ob_main_loop, SIGPIPE, signal_handler, NULL,NULL);
|
||||||
ob_main_loop_signal_add(ob_main_loop, SIGCHLD, signal_handler, NULL, NULL);
|
obt_main_loop_signal_add(ob_main_loop, SIGCHLD, signal_handler, NULL,NULL);
|
||||||
|
|
||||||
ob_screen = DefaultScreen(ob_display);
|
ob_screen = DefaultScreen(ob_display);
|
||||||
|
|
||||||
|
@ -346,7 +344,7 @@ gint main(gint argc, gchar **argv)
|
||||||
reconfigure = FALSE;
|
reconfigure = FALSE;
|
||||||
|
|
||||||
state = OB_STATE_RUNNING;
|
state = OB_STATE_RUNNING;
|
||||||
ob_main_loop_run(ob_main_loop);
|
obt_main_loop_run(ob_main_loop);
|
||||||
state = OB_STATE_EXITING;
|
state = OB_STATE_EXITING;
|
||||||
|
|
||||||
if (!reconfigure) {
|
if (!reconfigure) {
|
||||||
|
@ -385,7 +383,7 @@ gint main(gint argc, gchar **argv)
|
||||||
|
|
||||||
session_shutdown(being_replaced);
|
session_shutdown(being_replaced);
|
||||||
|
|
||||||
obt_instance_unref(obt_inst);
|
obt_display_close(ob_display);
|
||||||
|
|
||||||
parse_paths_shutdown();
|
parse_paths_shutdown();
|
||||||
|
|
||||||
|
@ -646,14 +644,14 @@ void ob_reconfigure()
|
||||||
void ob_exit(gint code)
|
void ob_exit(gint code)
|
||||||
{
|
{
|
||||||
exitcode = code;
|
exitcode = code;
|
||||||
ob_main_loop_exit(ob_main_loop);
|
obt_main_loop_exit(ob_main_loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ob_exit_replace()
|
void ob_exit_replace()
|
||||||
{
|
{
|
||||||
exitcode = 0;
|
exitcode = 0;
|
||||||
being_replaced = TRUE;
|
being_replaced = TRUE;
|
||||||
ob_main_loop_exit(ob_main_loop);
|
obt_main_loop_exit(ob_main_loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
Cursor ob_cursor(ObCursor cursor)
|
Cursor ob_cursor(ObCursor cursor)
|
||||||
|
|
|
@ -23,16 +23,15 @@
|
||||||
|
|
||||||
#include "render/render.h"
|
#include "render/render.h"
|
||||||
#include "render/theme.h"
|
#include "render/theme.h"
|
||||||
|
#include "obt/mainloop.h"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
struct _ObMainLoop;
|
|
||||||
|
|
||||||
extern RrInstance *ob_rr_inst;
|
extern RrInstance *ob_rr_inst;
|
||||||
extern RrTheme *ob_rr_theme;
|
extern RrTheme *ob_rr_theme;
|
||||||
|
|
||||||
extern struct _ObMainLoop *ob_main_loop;
|
extern ObtMainLoop *ob_main_loop;
|
||||||
|
|
||||||
/*! The X display */
|
/*! The X display */
|
||||||
extern Display *ob_display;
|
extern Display *ob_display;
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include "stacking.h"
|
#include "stacking.h"
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "mainloop.h"
|
|
||||||
#include "render/render.h"
|
#include "render/render.h"
|
||||||
#include "render/theme.h"
|
#include "render/theme.h"
|
||||||
|
|
||||||
|
@ -292,9 +291,9 @@ void popup_delay_show(ObPopup *self, gulong usec, gchar *text)
|
||||||
if (usec) {
|
if (usec) {
|
||||||
/* don't kill previous show timers */
|
/* don't kill previous show timers */
|
||||||
if (!self->delay_mapped) {
|
if (!self->delay_mapped) {
|
||||||
ob_main_loop_timeout_add(ob_main_loop, usec,
|
obt_main_loop_timeout_add(ob_main_loop, usec,
|
||||||
popup_show_timeout, self,
|
popup_show_timeout, self,
|
||||||
g_direct_equal, NULL);
|
g_direct_equal, NULL);
|
||||||
self->delay_mapped = TRUE;
|
self->delay_mapped = TRUE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -318,7 +317,7 @@ void popup_hide(ObPopup *self)
|
||||||
|
|
||||||
event_end_ignore_all_enters(ignore_start);
|
event_end_ignore_all_enters(ignore_start);
|
||||||
} else if (self->delay_mapped) {
|
} else if (self->delay_mapped) {
|
||||||
ob_main_loop_timeout_remove(ob_main_loop, popup_show_timeout);
|
obt_main_loop_timeout_remove(ob_main_loop, popup_show_timeout);
|
||||||
self->delay_mapped = FALSE;
|
self->delay_mapped = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,6 @@ void sn_spawn_cancel() {}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include "openbox.h"
|
#include "openbox.h"
|
||||||
#include "mainloop.h"
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
#define SN_API_NOT_YET_FROZEN
|
#define SN_API_NOT_YET_FROZEN
|
||||||
|
@ -72,7 +71,7 @@ void sn_startup(gboolean reconfig)
|
||||||
sn_event_func, NULL, NULL);
|
sn_event_func, NULL, NULL);
|
||||||
sn_launcher = sn_launcher_context_new(sn_display, ob_screen);
|
sn_launcher = sn_launcher_context_new(sn_display, ob_screen);
|
||||||
|
|
||||||
ob_main_loop_x_add(ob_main_loop, sn_handler, NULL, NULL);
|
obt_main_loop_x_add(ob_main_loop, sn_handler, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sn_shutdown(gboolean reconfig)
|
void sn_shutdown(gboolean reconfig)
|
||||||
|
@ -81,7 +80,7 @@ void sn_shutdown(gboolean reconfig)
|
||||||
|
|
||||||
if (reconfig) return;
|
if (reconfig) return;
|
||||||
|
|
||||||
ob_main_loop_x_remove(ob_main_loop, sn_handler);
|
obt_main_loop_x_remove(ob_main_loop, sn_handler);
|
||||||
|
|
||||||
for (it = sn_waits; it; it = g_slist_next(it))
|
for (it = sn_waits; it; it = g_slist_next(it))
|
||||||
sn_startup_sequence_unref((SnStartupSequence*)it->data);
|
sn_startup_sequence_unref((SnStartupSequence*)it->data);
|
||||||
|
@ -144,10 +143,10 @@ static void sn_event_func(SnMonitorEvent *ev, gpointer data)
|
||||||
sn_waits = g_slist_prepend(sn_waits, seq);
|
sn_waits = g_slist_prepend(sn_waits, seq);
|
||||||
/* 20 second timeout for apps to start if the launcher doesn't
|
/* 20 second timeout for apps to start if the launcher doesn't
|
||||||
have a timeout */
|
have a timeout */
|
||||||
ob_main_loop_timeout_add(ob_main_loop, 20 * G_USEC_PER_SEC,
|
obt_main_loop_timeout_add(ob_main_loop, 20 * G_USEC_PER_SEC,
|
||||||
sn_wait_timeout, seq,
|
sn_wait_timeout, seq,
|
||||||
g_direct_equal,
|
g_direct_equal,
|
||||||
(GDestroyNotify)sn_startup_sequence_unref);
|
(GDestroyNotify)sn_startup_sequence_unref);
|
||||||
change = TRUE;
|
change = TRUE;
|
||||||
break;
|
break;
|
||||||
case SN_MONITOR_EVENT_CHANGED:
|
case SN_MONITOR_EVENT_CHANGED:
|
||||||
|
@ -158,8 +157,8 @@ static void sn_event_func(SnMonitorEvent *ev, gpointer data)
|
||||||
case SN_MONITOR_EVENT_CANCELED:
|
case SN_MONITOR_EVENT_CANCELED:
|
||||||
if ((seq = sequence_find(sn_startup_sequence_get_id(seq)))) {
|
if ((seq = sequence_find(sn_startup_sequence_get_id(seq)))) {
|
||||||
sn_waits = g_slist_remove(sn_waits, seq);
|
sn_waits = g_slist_remove(sn_waits, seq);
|
||||||
ob_main_loop_timeout_remove_data(ob_main_loop, sn_wait_timeout,
|
obt_main_loop_timeout_remove_data(ob_main_loop, sn_wait_timeout,
|
||||||
seq, FALSE);
|
seq, FALSE);
|
||||||
change = TRUE;
|
change = TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -258,10 +257,10 @@ void sn_setup_spawn_environment(gchar *program, gchar *name,
|
||||||
|
|
||||||
/* 20 second timeout for apps to start */
|
/* 20 second timeout for apps to start */
|
||||||
sn_launcher_context_ref(sn_launcher);
|
sn_launcher_context_ref(sn_launcher);
|
||||||
ob_main_loop_timeout_add(ob_main_loop, 20 * G_USEC_PER_SEC,
|
obt_main_loop_timeout_add(ob_main_loop, 20 * G_USEC_PER_SEC,
|
||||||
sn_launch_wait_timeout, sn_launcher,
|
sn_launch_wait_timeout, sn_launcher,
|
||||||
g_direct_equal,
|
g_direct_equal,
|
||||||
(GDestroyNotify)sn_launcher_context_unref);
|
(GDestroyNotify)sn_launcher_context_unref);
|
||||||
|
|
||||||
putenv(g_strdup_printf("DESKTOP_STARTUP_ID=%s", id));
|
putenv(g_strdup_printf("DESKTOP_STARTUP_ID=%s", id));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue