update to new xcb-event

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-09-16 15:36:44 +02:00
parent d1f8bff99d
commit be52f5b047
5 changed files with 28 additions and 38 deletions

View File

@ -29,9 +29,10 @@
#include <ev.h> #include <ev.h>
#include <xcb/xcb_event.h>
#include "awesome.h" #include "awesome.h"
#include "client.h" #include "client.h"
#include "event.h"
#include "window.h" #include "window.h"
#include "ewmh.h" #include "ewmh.h"
#include "dbus.h" #include "dbus.h"
@ -184,14 +185,7 @@ scan(void)
static void static void
a_xcb_check_cb(EV_P_ ev_check *w, int revents) a_xcb_check_cb(EV_P_ ev_check *w, int revents)
{ {
xcb_generic_event_t *ev; xcb_event_poll_for_event_loop(&globalconf.evenths);
while((ev = xcb_poll_for_event(globalconf.connection)))
{
xcb_handle_event(globalconf.evenths, ev);
p_delete(&ev);
}
awesome_refresh(globalconf.connection); awesome_refresh(globalconf.connection);
} }
@ -397,8 +391,8 @@ main(int argc, char **argv)
ev_unref(globalconf.loop); ev_unref(globalconf.loop);
/* Allocate a handler which will holds all errors and events */ /* Allocate a handler which will holds all errors and events */
globalconf.evenths = xcb_alloc_event_handlers(globalconf.connection); xcb_event_handlers_init(globalconf.connection, &globalconf.evenths);
xutil_error_handler_catch_all_set(globalconf.evenths, xerrorstart, NULL); xutil_error_handler_catch_all_set(&globalconf.evenths, xerrorstart, NULL);
for(screen_nbr = 0; for(screen_nbr = 0;
screen_nbr < xcb_setup_roots_length(xcb_get_setup(globalconf.connection)); screen_nbr < xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
@ -416,10 +410,10 @@ main(int argc, char **argv)
xcb_aux_sync(globalconf.connection); xcb_aux_sync(globalconf.connection);
/* Process all errors in the queue if any */ /* Process all errors in the queue if any */
xcb_poll_for_event_loop(globalconf.evenths); xcb_event_poll_for_event_loop(&globalconf.evenths);
/* Set the default xerror handler */ /* Set the default xerror handler */
xutil_error_handler_catch_all_set(globalconf.evenths, xerror, NULL); xutil_error_handler_catch_all_set(&globalconf.evenths, xerror, NULL);
/* Allocate the key symbols */ /* Allocate the key symbols */
globalconf.keysyms = xcb_key_symbols_alloc(globalconf.connection); globalconf.keysyms = xcb_key_symbols_alloc(globalconf.connection);
@ -480,7 +474,7 @@ main(int argc, char **argv)
scan(); scan();
/* process all errors in the queue if any */ /* process all errors in the queue if any */
xcb_poll_for_event_loop(globalconf.evenths); xcb_event_poll_for_event_loop(&globalconf.evenths);
a_xcb_set_event_handlers(); a_xcb_set_event_handlers();
/* do this only for real screen */ /* do this only for real screen */

View File

@ -140,7 +140,7 @@ xutil_error_handler_catch_all_set(xcb_event_handlers_t *evenths,
{ {
int err_num; int err_num;
for(err_num = 0; err_num < ERRORS_NBR; err_num++) for(err_num = 0; err_num < ERRORS_NBR; err_num++)
xcb_set_error_handler(evenths, err_num, handler, data); xcb_event_set_error_handler(evenths, err_num, handler, data);
} }
const char * const char *

38
event.c
View File

@ -20,9 +20,10 @@
*/ */
#include <xcb/xcb.h> #include <xcb/xcb.h>
#include <xcb/xcb_atom.h>
#include <xcb/randr.h> #include <xcb/randr.h>
#include <xcb/xcb_atom.h>
#include <xcb/xcb_icccm.h> #include <xcb/xcb_icccm.h>
#include <xcb/xcb_event.h>
#include "awesome.h" #include "awesome.h"
#include "event.h" #include "event.h"
@ -568,15 +569,10 @@ event_handle_unmapnotify(void *data __attribute__ ((unused)),
xembed_window_t *em; xembed_window_t *em;
int i; int i;
/* event->send_event (Xlib) is quivalent to (ev->response_type &
* 0x80) in XCB because the SendEvent bit is available in the
* response_type field */
bool send_event = ((ev->response_type & 0x80) >> 7);
if((c = client_getbywin(ev->window))) if((c = client_getbywin(ev->window)))
{ {
if(ev->event == xutil_screen_get(connection, c->phys_screen)->root if(ev->event == xutil_screen_get(connection, c->phys_screen)->root
&& send_event && XCB_EVENT_SENT(ev)
&& window_state_get_reply(window_state_get_unchecked(c->win)) == XCB_WM_STATE_NORMAL) && window_state_get_reply(window_state_get_unchecked(c->win)) == XCB_WM_STATE_NORMAL)
client_unmanage(c); client_unmanage(c);
} }
@ -690,24 +686,24 @@ void a_xcb_set_event_handlers(void)
{ {
const xcb_query_extension_reply_t *randr_query; const xcb_query_extension_reply_t *randr_query;
set_button_press_event_handler(globalconf.evenths, event_handle_buttonpress, NULL); xcb_event_set_button_press_handler(&globalconf.evenths, event_handle_buttonpress, NULL);
set_configure_request_event_handler(globalconf.evenths, event_handle_configurerequest, NULL); xcb_event_set_configure_request_handler(&globalconf.evenths, event_handle_configurerequest, NULL);
set_configure_notify_event_handler(globalconf.evenths, event_handle_configurenotify, NULL); xcb_event_set_configure_notify_handler(&globalconf.evenths, event_handle_configurenotify, NULL);
set_destroy_notify_event_handler(globalconf.evenths, event_handle_destroynotify, NULL); xcb_event_set_destroy_notify_handler(&globalconf.evenths, event_handle_destroynotify, NULL);
set_enter_notify_event_handler(globalconf.evenths, event_handle_enternotify, NULL); xcb_event_set_enter_notify_handler(&globalconf.evenths, event_handle_enternotify, NULL);
set_expose_event_handler(globalconf.evenths, event_handle_expose, NULL); xcb_event_set_expose_handler(&globalconf.evenths, event_handle_expose, NULL);
set_key_press_event_handler(globalconf.evenths, event_handle_keypress, NULL); xcb_event_set_key_press_handler(&globalconf.evenths, event_handle_keypress, NULL);
set_map_request_event_handler(globalconf.evenths, event_handle_maprequest, NULL); xcb_event_set_map_request_handler(&globalconf.evenths, event_handle_maprequest, NULL);
set_property_notify_event_handler(globalconf.evenths, event_handle_propertynotify, NULL); xcb_event_set_property_notify_handler(&globalconf.evenths, event_handle_propertynotify, NULL);
set_unmap_notify_event_handler(globalconf.evenths, event_handle_unmapnotify, NULL); xcb_event_set_unmap_notify_handler(&globalconf.evenths, event_handle_unmapnotify, NULL);
set_client_message_event_handler(globalconf.evenths, event_handle_clientmessage, NULL); xcb_event_set_client_message_handler(&globalconf.evenths, event_handle_clientmessage, NULL);
set_mapping_notify_event_handler(globalconf.evenths, event_handle_mappingnotify, NULL); xcb_event_set_mapping_notify_handler(&globalconf.evenths, event_handle_mappingnotify, NULL);
/* check for randr extension */ /* check for randr extension */
randr_query = xcb_get_extension_data(globalconf.connection, &xcb_randr_id); randr_query = xcb_get_extension_data(globalconf.connection, &xcb_randr_id);
if((globalconf.have_randr = randr_query->present)) if((globalconf.have_randr = randr_query->present))
xcb_set_event_handler(globalconf.evenths, xcb_event_set_handler(&globalconf.evenths,
(randr_query->first_event + XCB_RANDR_SCREEN_CHANGE_NOTIFY), randr_query->first_event + XCB_RANDR_SCREEN_CHANGE_NOTIFY,
(xcb_generic_event_handler_t) event_handle_randr_screen_change_notify, (xcb_generic_event_handler_t) event_handle_randr_screen_change_notify,
NULL); NULL);

View File

@ -445,7 +445,7 @@ mouse_track_mouse_drag(int *x, int *y)
return false; return false;
default: default:
xcb_handle_event(globalconf.evenths, ev); xcb_event_handle(&globalconf.evenths, ev);
p_delete(&ev); p_delete(&ev);
break; break;
} }

View File

@ -397,7 +397,7 @@ struct awesome_t
/** Connection ref */ /** Connection ref */
xcb_connection_t *connection; xcb_connection_t *connection;
/** Event and error handlers */ /** Event and error handlers */
xcb_event_handlers_t *evenths; xcb_event_handlers_t evenths;
/** Default screen number */ /** Default screen number */
int default_screen; int default_screen;
/** Keys symbol table */ /** Keys symbol table */