事件适配器
This commit is contained in:
10
src/main.c
10
src/main.c
@@ -11,6 +11,7 @@
|
||||
#include <wordexp.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "event-adapter.h"
|
||||
#include "renderer.h"
|
||||
#include "types.h"
|
||||
#include "utils.h"
|
||||
@@ -38,6 +39,7 @@ static monitor_t *current_monitor = NULL;
|
||||
static wallpaper_config_t *wallpaper_config = NULL;
|
||||
static color_set_t *color_set = NULL;
|
||||
static GMainLoop *loop = NULL;
|
||||
static event_adapter_t *adapter = NULL;
|
||||
static char *font_family = NULL;
|
||||
static uint32_t font_size = default_font_size;
|
||||
static uint32_t dpi = dpi_fallback;
|
||||
@@ -353,6 +355,7 @@ void update_bars(void) {
|
||||
}
|
||||
|
||||
void init_xcb_event_loop(void) {
|
||||
adapter = create_event_adapter();
|
||||
GIOChannel *channel = g_io_channel_unix_new(get_xcb_connection_fd());
|
||||
g_io_channel_set_encoding(channel, NULL, NULL);
|
||||
GIOCondition cond = G_IO_IN | G_IO_HUP | G_IO_ERR;
|
||||
@@ -362,12 +365,12 @@ void init_xcb_event_loop(void) {
|
||||
|
||||
gboolean handle_xcb_event(GIOChannel *channel, GIOCondition condition,
|
||||
gpointer userdata) {
|
||||
if ((condition & G_IO_HUP) || (condition & G_IO_ERR)) {
|
||||
if (condition & (G_IO_HUP | G_IO_ERR)) {
|
||||
g_main_loop_quit(loop);
|
||||
return false;
|
||||
}
|
||||
|
||||
start_xcb_event_loop();
|
||||
event_adapter_poll(adapter);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -400,6 +403,9 @@ void cleanup(void) {
|
||||
}
|
||||
monitors = NULL;
|
||||
|
||||
destroy_event_adapter(adapter);
|
||||
adapter = NULL;
|
||||
|
||||
clean_xcb();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user