Move xcb_event_handler code to xutil
This commit is contained in:
parent
71e9100927
commit
70dafae396
|
@ -145,7 +145,6 @@ awesome_SOURCES = \
|
||||||
rules.c rules.h \
|
rules.c rules.h \
|
||||||
mouse.c mouse.h \
|
mouse.c mouse.h \
|
||||||
widget.c widget.h \
|
widget.c widget.h \
|
||||||
xcb_event_handler.c xcb_event_handler.h \
|
|
||||||
ewmh.c ewmh.h
|
ewmh.c ewmh.h
|
||||||
awesome_SOURCES += $(LAYOUTS)
|
awesome_SOURCES += $(LAYOUTS)
|
||||||
awesome_SOURCES += $(WIDGETS)
|
awesome_SOURCES += $(WIDGETS)
|
||||||
|
@ -172,7 +171,7 @@ awesome_message_SOURCES = \
|
||||||
common/xutil.h common/xutil.c \
|
common/xutil.h common/xutil.c \
|
||||||
awesome-message.c
|
awesome-message.c
|
||||||
awesome_message_LDADD = $(xcb_LIBS) $(xcb_atom_LIBS) $(xcb_keysyms_LIBS) $(xcb_aux_LIBS) \
|
awesome_message_LDADD = $(xcb_LIBS) $(xcb_atom_LIBS) $(xcb_keysyms_LIBS) $(xcb_aux_LIBS) \
|
||||||
$(pangocairo_LIBS) $(confuse_LIBS) $(xcb_xinerama_LIBS) $(imlib2_LIBS) $(GTK_LIBS)
|
$(pangocairo_LIBS) $(confuse_LIBS) $(xcb_xinerama_LIBS) $(xcb_event_LIBS) $(imlib2_LIBS) $(GTK_LIBS)
|
||||||
|
|
||||||
bin_PROGRAMS += awesome-menu
|
bin_PROGRAMS += awesome-menu
|
||||||
awesome_menu_SOURCES = \
|
awesome_menu_SOURCES = \
|
||||||
|
@ -184,7 +183,7 @@ awesome_menu_SOURCES = \
|
||||||
common/xutil.h common/xutil.c \
|
common/xutil.h common/xutil.c \
|
||||||
awesome-menu.c
|
awesome-menu.c
|
||||||
awesome_menu_LDADD = $(xcb_LIBS) $(xcb_atom_LIBS) $(xcb_keysyms_LIBS) $(xcb_aux_LIBS) \
|
awesome_menu_LDADD = $(xcb_LIBS) $(xcb_atom_LIBS) $(xcb_keysyms_LIBS) $(xcb_aux_LIBS) \
|
||||||
$(pangocairo_LIBS) $(confuse_LIBS) $(xcb_xinerama_LIBS) $(imlib2_LIBS) $(GTK_LIBS)
|
$(pangocairo_LIBS) $(confuse_LIBS) $(xcb_xinerama_LIBS) $(xcb_event_LIBS) $(imlib2_LIBS) $(GTK_LIBS)
|
||||||
|
|
||||||
if HAVE_XMLTO
|
if HAVE_XMLTO
|
||||||
if HAVE_ASCIIDOC
|
if HAVE_ASCIIDOC
|
||||||
|
|
27
awesome.c
27
awesome.c
|
@ -53,7 +53,6 @@
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "focus.h"
|
#include "focus.h"
|
||||||
#include "ewmh.h"
|
#include "ewmh.h"
|
||||||
#include "xcb_event_handler.h"
|
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
#include "common/socket.h"
|
#include "common/socket.h"
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
|
@ -220,21 +219,19 @@ xerror(void *data __attribute__ ((unused)),
|
||||||
xcb_connection_t *c __attribute__ ((unused)),
|
xcb_connection_t *c __attribute__ ((unused)),
|
||||||
xcb_generic_error_t *e)
|
xcb_generic_error_t *e)
|
||||||
{
|
{
|
||||||
/*
|
xutil_error_t *err = xutil_get_error(e);
|
||||||
* Get the request code, taken from 'xcb-util/wm'. I can't figure
|
|
||||||
* out how it works BTW, seems to get a byte in 'pad' member
|
|
||||||
* (second byte in second element of the array)
|
|
||||||
*/
|
|
||||||
uint8_t request_code = (e->response_type == 0 ? *((uint8_t *) e + 10) : e->response_type);
|
|
||||||
|
|
||||||
if(e->error_code == BadWindow
|
if(e->error_code == BadWindow
|
||||||
|| (e->error_code == BadMatch && request_code == XCB_SET_INPUT_FOCUS)
|
|| (e->error_code == BadMatch && err->request_code == XCB_SET_INPUT_FOCUS)
|
||||||
|| (e->error_code == BadValue && request_code == XCB_KILL_CLIENT)
|
|| (e->error_code == BadValue && err->request_code == XCB_KILL_CLIENT)
|
||||||
|| (request_code == XCB_CONFIGURE_WINDOW && e->error_code == BadMatch))
|
|| (err->request_code == XCB_CONFIGURE_WINDOW && e->error_code == BadMatch))
|
||||||
|
{
|
||||||
|
xutil_delete_error(err);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
warn("fatal error: request=%s, error=%s\n",
|
|
||||||
x_label_request[request_code], x_label_error[e->error_code]);
|
warn("fatal error: request=%s, error=%s\n", err->request_label, err->error_label);
|
||||||
|
xutil_delete_error(err);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Xlib code was using default X error handler, namely
|
* Xlib code was using default X error handler, namely
|
||||||
|
@ -347,7 +344,7 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
/* 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(conn);
|
globalconf.evenths = xcb_alloc_event_handlers(conn);
|
||||||
xcb_set_error_handler_catch_all(globalconf.evenths, xerrorstart, NULL);
|
xutil_set_error_handler_catch_all(globalconf.evenths, xerrorstart, NULL);
|
||||||
|
|
||||||
const uint32_t select_input_val = XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT;
|
const uint32_t select_input_val = XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT;
|
||||||
|
|
||||||
|
@ -366,7 +363,7 @@ main(int argc, char *argv[])
|
||||||
xcb_poll_for_event_loop(globalconf.evenths);
|
xcb_poll_for_event_loop(globalconf.evenths);
|
||||||
|
|
||||||
/* set the default xerror handler */
|
/* set the default xerror handler */
|
||||||
xcb_set_error_handler_catch_all(globalconf.evenths, xerror, NULL);
|
xutil_set_error_handler_catch_all(globalconf.evenths, xerror, NULL);
|
||||||
|
|
||||||
/* TODO
|
/* TODO
|
||||||
if(xsync)
|
if(xsync)
|
||||||
|
|
197
common/xutil.c
197
common/xutil.c
|
@ -200,4 +200,201 @@ xutil_map_raised(xcb_connection_t *conn, xcb_window_t win)
|
||||||
xcb_map_window(conn, win);
|
xcb_map_window(conn, win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Number of different errors */
|
||||||
|
#define ERRORS_NBR 256
|
||||||
|
|
||||||
|
/* Number of different events */
|
||||||
|
#define EVENTS_NBR 126
|
||||||
|
|
||||||
|
void
|
||||||
|
xutil_set_error_handler_catch_all(xcb_event_handlers_t *evenths,
|
||||||
|
xcb_generic_error_handler_t handler,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
int err_num;
|
||||||
|
for(err_num = 0; err_num < ERRORS_NBR; err_num++)
|
||||||
|
xcb_set_error_handler(evenths, err_num, handler, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
xutil_error_label[] =
|
||||||
|
{
|
||||||
|
"Success",
|
||||||
|
"BadRequest",
|
||||||
|
"BadValue",
|
||||||
|
"BadWindow",
|
||||||
|
"BadPixmap",
|
||||||
|
"BadAtom",
|
||||||
|
"BadCursor",
|
||||||
|
"BadFont",
|
||||||
|
"BadMatch",
|
||||||
|
"BadDrawable",
|
||||||
|
"BadAccess",
|
||||||
|
"BadAlloc",
|
||||||
|
"BadColor",
|
||||||
|
"BadGC",
|
||||||
|
"BadIDChoice",
|
||||||
|
"BadName",
|
||||||
|
"BadLength",
|
||||||
|
"BadImplementation",
|
||||||
|
};
|
||||||
|
|
||||||
|
const char *
|
||||||
|
xutil_request_label[] =
|
||||||
|
{
|
||||||
|
"XCB_NONE",
|
||||||
|
"CreateWindow",
|
||||||
|
"ChangeWindowAttributes",
|
||||||
|
"GetWindowAttributes",
|
||||||
|
"DestroyWindow",
|
||||||
|
"DestroySubwindows",
|
||||||
|
"ChangeSaveSet",
|
||||||
|
"ReparentWindow",
|
||||||
|
"MapWindow",
|
||||||
|
"MapSubwindows",
|
||||||
|
"UnmapWindow",
|
||||||
|
"UnmapSubwindows",
|
||||||
|
"ConfigureWindow",
|
||||||
|
"CirculateWindow",
|
||||||
|
"GetGeometry",
|
||||||
|
"QueryTree",
|
||||||
|
"InternAtom",
|
||||||
|
"GetAtomName",
|
||||||
|
"ChangeProperty",
|
||||||
|
"DeleteProperty",
|
||||||
|
"GetProperty",
|
||||||
|
"ListProperties",
|
||||||
|
"SetSelectionOwner",
|
||||||
|
"GetSelectionOwner",
|
||||||
|
"ConvertSelection",
|
||||||
|
"SendEvent",
|
||||||
|
"GrabPointer",
|
||||||
|
"UngrabPointer",
|
||||||
|
"GrabButton",
|
||||||
|
"UngrabButton",
|
||||||
|
"ChangeActivePointerGrab",
|
||||||
|
"GrabKeyboard",
|
||||||
|
"UngrabKeyboard",
|
||||||
|
"GrabKey",
|
||||||
|
"UngrabKey",
|
||||||
|
"AllowEvents",
|
||||||
|
"GrabServer",
|
||||||
|
"UngrabServer",
|
||||||
|
"QueryPointer",
|
||||||
|
"GetMotionEvents",
|
||||||
|
"TranslateCoords",
|
||||||
|
"WarpPointer",
|
||||||
|
"SetInputFocus",
|
||||||
|
"GetInputFocus",
|
||||||
|
"QueryKeymap",
|
||||||
|
"OpenFont",
|
||||||
|
"CloseFont",
|
||||||
|
"QueryFont",
|
||||||
|
"QueryTextExtents",
|
||||||
|
"ListFonts",
|
||||||
|
"ListFontsWithInfo",
|
||||||
|
"SetFontPath",
|
||||||
|
"GetFontPath",
|
||||||
|
"CreatePixmap",
|
||||||
|
"FreePixmap",
|
||||||
|
"CreateGC",
|
||||||
|
"ChangeGC",
|
||||||
|
"CopyGC",
|
||||||
|
"SetDashes",
|
||||||
|
"SetClipRectangles",
|
||||||
|
"FreeGC",
|
||||||
|
"ClearArea",
|
||||||
|
"CopyArea",
|
||||||
|
"CopyPlane",
|
||||||
|
"PolyPoint",
|
||||||
|
"PolyLine",
|
||||||
|
"PolySegment",
|
||||||
|
"PolyRectangle",
|
||||||
|
"PolyArc",
|
||||||
|
"FillPoly",
|
||||||
|
"PolyFillRectangle",
|
||||||
|
"PolyFillArc",
|
||||||
|
"PutImage",
|
||||||
|
"GetImage",
|
||||||
|
"PolyText",
|
||||||
|
"PolyText",
|
||||||
|
"ImageText",
|
||||||
|
"ImageText",
|
||||||
|
"CreateColormap",
|
||||||
|
"FreeColormap",
|
||||||
|
"CopyColormapAndFree",
|
||||||
|
"InstallColormap",
|
||||||
|
"UninstallColormap",
|
||||||
|
"ListInstalledColormaps",
|
||||||
|
"AllocColor",
|
||||||
|
"AllocNamedColor",
|
||||||
|
"AllocColorCells",
|
||||||
|
"AllocColorPlanes",
|
||||||
|
"FreeColors",
|
||||||
|
"StoreColors",
|
||||||
|
"StoreNamedColor",
|
||||||
|
"QueryColors",
|
||||||
|
"LookupColor",
|
||||||
|
"CreateCursor",
|
||||||
|
"CreateGlyphCursor",
|
||||||
|
"FreeCursor",
|
||||||
|
"RecolorCursor",
|
||||||
|
"QueryBestSize",
|
||||||
|
"QueryExtension",
|
||||||
|
"ListExtensions",
|
||||||
|
"ChangeKeyboardMapping",
|
||||||
|
"GetKeyboardMapping",
|
||||||
|
"ChangeKeyboardControl",
|
||||||
|
"GetKeyboardControl",
|
||||||
|
"Bell",
|
||||||
|
"ChangePointerControl",
|
||||||
|
"GetPointerControl",
|
||||||
|
"SetScreenSaver",
|
||||||
|
"GetScreenSaver",
|
||||||
|
"ChangeHosts",
|
||||||
|
"ListHosts",
|
||||||
|
"SetAccessControl",
|
||||||
|
"SetCloseDownMode",
|
||||||
|
"KillClient",
|
||||||
|
"RotateProperties",
|
||||||
|
"ForceScreenSaver",
|
||||||
|
"SetPointerMapping",
|
||||||
|
"GetPointerMapping",
|
||||||
|
"SetModifierMapping",
|
||||||
|
"GetModifierMapping",
|
||||||
|
"major 120",
|
||||||
|
"major 121",
|
||||||
|
"major 122",
|
||||||
|
"major 123",
|
||||||
|
"major 124",
|
||||||
|
"major 125",
|
||||||
|
"major 126",
|
||||||
|
"NoOperation",
|
||||||
|
};
|
||||||
|
|
||||||
|
xutil_error_t *
|
||||||
|
xutil_get_error(const xcb_generic_error_t *e)
|
||||||
|
{
|
||||||
|
xutil_error_t *err = p_new(xutil_error_t, 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the request code, taken from 'xcb-util/wm'. I can't figure
|
||||||
|
* out how it works BTW, seems to get a byte in 'pad' member
|
||||||
|
* (second byte in second element of the array)
|
||||||
|
*/
|
||||||
|
err->request_code = (e->response_type == 0 ? *((uint8_t *) e + 10) : e->response_type);
|
||||||
|
err->request_label = a_strdup(xutil_request_label[err->request_code]);
|
||||||
|
err->error_label = a_strdup(xutil_error_label[e->error_code]);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xutil_delete_error(xutil_error_t *err)
|
||||||
|
{
|
||||||
|
p_delete(&err->error_label);
|
||||||
|
p_delete(&err->request_label);
|
||||||
|
p_delete(&err);
|
||||||
|
}
|
||||||
|
|
||||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
#include <xcb/xcb_keysyms.h>
|
#include <xcb/xcb_keysyms.h>
|
||||||
|
#include <xcb/xcb_event.h>
|
||||||
|
|
||||||
/* XCB doesn't provide keysyms definition */
|
/* XCB doesn't provide keysyms definition */
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
|
@ -107,5 +108,19 @@ xcb_atom_t xutil_intern_atom(xcb_connection_t *, const char *);
|
||||||
specified window to the top of the stack and maps it */
|
specified window to the top of the stack and maps it */
|
||||||
void xutil_map_raised(xcb_connection_t *, xcb_window_t);
|
void xutil_map_raised(xcb_connection_t *, xcb_window_t);
|
||||||
|
|
||||||
|
/** Set the same handler for all errors */
|
||||||
|
void xutil_set_error_handler_catch_all(xcb_event_handlers_t *,
|
||||||
|
xcb_generic_error_handler_t, void *);
|
||||||
|
|
||||||
|
typedef struct xutil_error_t
|
||||||
|
{
|
||||||
|
uint8_t request_code;
|
||||||
|
char *request_label;
|
||||||
|
char *error_label;
|
||||||
|
} xutil_error_t;
|
||||||
|
|
||||||
|
xutil_error_t *xutil_get_error(const xcb_generic_error_t *);
|
||||||
|
void xutil_delete_error(xutil_error_t *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
/*
|
|
||||||
* xcb_event_handler.c - xcb event handler header
|
|
||||||
*
|
|
||||||
* Copyright © 2007-2008 Arnaud Fontaine <arnaud@andesi.org>
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef XCB_EVENT_HANDLER_H
|
|
||||||
#define XCB_EVENT_HANDLER_H
|
|
||||||
|
|
||||||
#include <xcb/xcb.h>
|
|
||||||
#include <xcb/xcb_event.h>
|
|
||||||
|
|
||||||
/* Set the same handler for all errors */
|
|
||||||
void xcb_set_error_handler_catch_all(xcb_event_handlers_t *,
|
|
||||||
xcb_generic_error_handler_t,
|
|
||||||
void *);
|
|
||||||
|
|
||||||
/* Number of different errors */
|
|
||||||
#define ERRORS_NBR 256
|
|
||||||
|
|
||||||
/* Number of different events */
|
|
||||||
#define EVENTS_NBR 126
|
|
||||||
|
|
||||||
/* Get the error name from its code */
|
|
||||||
extern const char *x_label_error[];
|
|
||||||
|
|
||||||
/* Get a request name from its code */
|
|
||||||
extern const char *x_label_request[];
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue