Make event handler setup private to the event module.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
This commit is contained in:
parent
cde80ab49a
commit
585496b66a
21
awesome.c
21
awesome.c
|
@ -277,7 +277,6 @@ main(int argc, char **argv)
|
|||
const char *confpath = NULL;
|
||||
int xfd, i, screen_nbr, opt;
|
||||
ssize_t cmdlen = 1;
|
||||
const xcb_query_extension_reply_t *randr_query;
|
||||
client_t *c;
|
||||
static struct option long_options[] =
|
||||
{
|
||||
|
@ -437,26 +436,6 @@ main(int argc, char **argv)
|
|||
/* process all errors in the queue if any */
|
||||
xcb_poll_for_event_loop(globalconf.evenths);
|
||||
|
||||
set_button_press_event_handler(globalconf.evenths, event_handle_buttonpress, NULL);
|
||||
set_configure_request_event_handler(globalconf.evenths, event_handle_configurerequest, NULL);
|
||||
set_configure_notify_event_handler(globalconf.evenths, event_handle_configurenotify, NULL);
|
||||
set_destroy_notify_event_handler(globalconf.evenths, event_handle_destroynotify, NULL);
|
||||
set_enter_notify_event_handler(globalconf.evenths, event_handle_enternotify, NULL);
|
||||
set_expose_event_handler(globalconf.evenths, event_handle_expose, NULL);
|
||||
set_key_press_event_handler(globalconf.evenths, event_handle_keypress, NULL);
|
||||
set_map_request_event_handler(globalconf.evenths, event_handle_maprequest, NULL);
|
||||
set_property_notify_event_handler(globalconf.evenths, event_handle_propertynotify, NULL);
|
||||
set_unmap_notify_event_handler(globalconf.evenths, event_handle_unmapnotify, NULL);
|
||||
set_client_message_event_handler(globalconf.evenths, event_handle_clientmessage, NULL);
|
||||
|
||||
/* check for randr extension */
|
||||
randr_query = xcb_get_extension_data(globalconf.connection, &xcb_randr_id);
|
||||
if((globalconf.have_randr = randr_query->present))
|
||||
xcb_set_event_handler(globalconf.evenths,
|
||||
(randr_query->first_event + XCB_RANDR_SCREEN_CHANGE_NOTIFY),
|
||||
(xcb_generic_event_handler_t) event_handle_randr_screen_change_notify,
|
||||
NULL);
|
||||
|
||||
/* do this only for real screen */
|
||||
for(screen_nbr = 0;
|
||||
screen_nbr < xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
|
||||
|
|
51
event.c
51
event.c
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xcb_atom.h>
|
||||
#include <xcb/randr.h>
|
||||
|
||||
#include "event.h"
|
||||
#include "window.h"
|
||||
|
@ -68,7 +69,7 @@ event_handle_mouse_button_press(client_t *c,
|
|||
* \param connection The connection to the X server.
|
||||
* \param ev The event.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
event_handle_buttonpress(void *data __attribute__ ((unused)),
|
||||
xcb_connection_t *connection, xcb_button_press_event_t *ev)
|
||||
{
|
||||
|
@ -172,7 +173,7 @@ event_handle_buttonpress(void *data __attribute__ ((unused)),
|
|||
* \param connection The connection to the X server.
|
||||
* \param ev The event.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
event_handle_configurerequest(void *data __attribute__ ((unused)),
|
||||
xcb_connection_t *connection, xcb_configure_request_event_t *ev)
|
||||
{
|
||||
|
@ -265,7 +266,7 @@ event_handle_configurerequest(void *data __attribute__ ((unused)),
|
|||
* \param connection The connection to the X server.
|
||||
* \param ev The event.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
event_handle_configurenotify(void *data __attribute__ ((unused)),
|
||||
xcb_connection_t *connection, xcb_configure_notify_event_t *ev)
|
||||
{
|
||||
|
@ -288,7 +289,7 @@ event_handle_configurenotify(void *data __attribute__ ((unused)),
|
|||
* \param connection The connection to the X server.
|
||||
* \param ev The event.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
event_handle_destroynotify(void *data __attribute__ ((unused)),
|
||||
xcb_connection_t *connection __attribute__ ((unused)),
|
||||
xcb_destroy_notify_event_t *ev)
|
||||
|
@ -306,7 +307,7 @@ event_handle_destroynotify(void *data __attribute__ ((unused)),
|
|||
* \param connection The connection to the X server.
|
||||
* \param ev The event.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
event_handle_enternotify(void *data __attribute__ ((unused)),
|
||||
xcb_connection_t *connection,
|
||||
xcb_enter_notify_event_t *ev)
|
||||
|
@ -347,7 +348,7 @@ event_handle_enternotify(void *data __attribute__ ((unused)),
|
|||
* \param connection The connection to the X server.
|
||||
* \param ev The event.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
event_handle_expose(void *data __attribute__ ((unused)),
|
||||
xcb_connection_t *connection __attribute__ ((unused)),
|
||||
xcb_expose_event_t *ev)
|
||||
|
@ -379,7 +380,7 @@ event_handle_expose(void *data __attribute__ ((unused)),
|
|||
* \param connection The connection to the X server.
|
||||
* \param ev The event.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
event_handle_keypress(void *data __attribute__ ((unused)),
|
||||
xcb_connection_t *connection __attribute__ ((unused)),
|
||||
xcb_key_press_event_t *ev)
|
||||
|
@ -414,7 +415,7 @@ event_handle_keypress(void *data __attribute__ ((unused)),
|
|||
* \param connection The connection to the X server.
|
||||
* \param ev The event.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
event_handle_maprequest(void *data __attribute__ ((unused)),
|
||||
xcb_connection_t *connection, xcb_map_request_event_t *ev)
|
||||
{
|
||||
|
@ -484,7 +485,7 @@ bailout:
|
|||
* \param connection The connection to the X server.
|
||||
* \param ev The event.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
event_handle_propertynotify(void *data __attribute__ ((unused)),
|
||||
xcb_connection_t *connection, xcb_property_notify_event_t *ev)
|
||||
{
|
||||
|
@ -526,7 +527,7 @@ event_handle_propertynotify(void *data __attribute__ ((unused)),
|
|||
* \param connection The connection to the X server.
|
||||
* \param ev The event.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
event_handle_unmapnotify(void *data __attribute__ ((unused)),
|
||||
xcb_connection_t *connection, xcb_unmap_notify_event_t *ev)
|
||||
{
|
||||
|
@ -560,7 +561,7 @@ event_handle_unmapnotify(void *data __attribute__ ((unused)),
|
|||
* \param connection The connection to the X server.
|
||||
* \param ev The event.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
event_handle_randr_screen_change_notify(void *data __attribute__ ((unused)),
|
||||
xcb_connection_t *connection __attribute__ ((unused)),
|
||||
xcb_randr_screen_change_notify_event_t *ev)
|
||||
|
@ -594,7 +595,7 @@ event_handle_randr_screen_change_notify(void *data __attribute__ ((unused)),
|
|||
* \param connection The connection to the X server.
|
||||
* \param ev The event.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
event_handle_clientmessage(void *data __attribute__ ((unused)),
|
||||
xcb_connection_t *connection,
|
||||
xcb_client_message_event_t *ev)
|
||||
|
@ -615,4 +616,30 @@ event_handle_clientmessage(void *data __attribute__ ((unused)),
|
|||
return ewmh_process_client_message(ev);
|
||||
}
|
||||
|
||||
void a_xcb_set_event_handlers(void)
|
||||
{
|
||||
const xcb_query_extension_reply_t *randr_query;
|
||||
|
||||
set_button_press_event_handler(globalconf.evenths, event_handle_buttonpress, NULL);
|
||||
set_configure_request_event_handler(globalconf.evenths, event_handle_configurerequest, NULL);
|
||||
set_configure_notify_event_handler(globalconf.evenths, event_handle_configurenotify, NULL);
|
||||
set_destroy_notify_event_handler(globalconf.evenths, event_handle_destroynotify, NULL);
|
||||
set_enter_notify_event_handler(globalconf.evenths, event_handle_enternotify, NULL);
|
||||
set_expose_event_handler(globalconf.evenths, event_handle_expose, NULL);
|
||||
set_key_press_event_handler(globalconf.evenths, event_handle_keypress, NULL);
|
||||
set_map_request_event_handler(globalconf.evenths, event_handle_maprequest, NULL);
|
||||
set_property_notify_event_handler(globalconf.evenths, event_handle_propertynotify, NULL);
|
||||
set_unmap_notify_event_handler(globalconf.evenths, event_handle_unmapnotify, NULL);
|
||||
set_client_message_event_handler(globalconf.evenths, event_handle_clientmessage, NULL);
|
||||
|
||||
/* check for randr extension */
|
||||
randr_query = xcb_get_extension_data(globalconf.connection, &xcb_randr_id);
|
||||
if((globalconf.have_randr = randr_query->present))
|
||||
xcb_set_event_handler(globalconf.evenths,
|
||||
(randr_query->first_event + XCB_RANDR_SCREEN_CHANGE_NOTIFY),
|
||||
(xcb_generic_event_handler_t) event_handle_randr_screen_change_notify,
|
||||
NULL);
|
||||
|
||||
}
|
||||
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||
|
|
16
event.h
16
event.h
|
@ -22,21 +22,7 @@
|
|||
#ifndef AWESOME_EVENT_H
|
||||
#define AWESOME_EVENT_H
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/randr.h>
|
||||
|
||||
int event_handle_buttonpress(void *, xcb_connection_t *, xcb_button_press_event_t *);
|
||||
int event_handle_configurerequest(void *, xcb_connection_t *, xcb_configure_request_event_t *);
|
||||
int event_handle_configurenotify(void *, xcb_connection_t *, xcb_configure_notify_event_t *);
|
||||
int event_handle_destroynotify(void *, xcb_connection_t *, xcb_destroy_notify_event_t *);
|
||||
int event_handle_enternotify(void *, xcb_connection_t *, xcb_enter_notify_event_t *);
|
||||
int event_handle_expose(void *, xcb_connection_t *, xcb_expose_event_t *);
|
||||
int event_handle_keypress(void *, xcb_connection_t *, xcb_key_press_event_t *);
|
||||
int event_handle_maprequest(void *, xcb_connection_t *, xcb_map_request_event_t *);
|
||||
int event_handle_propertynotify(void *, xcb_connection_t *, xcb_property_notify_event_t *);
|
||||
int event_handle_unmapnotify(void *, xcb_connection_t *, xcb_unmap_notify_event_t *);
|
||||
int event_handle_randr_screen_change_notify(void *, xcb_connection_t *, xcb_randr_screen_change_notify_event_t *);
|
||||
int event_handle_clientmessage(void *, xcb_connection_t *, xcb_client_message_event_t *);
|
||||
void a_xcb_set_event_handlers(void);
|
||||
|
||||
#endif
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||
|
|
Loading…
Reference in New Issue