From 0295df81c1aeb95ddd188da264a95188f5bc3189 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 6 Feb 2019 09:30:16 +0100 Subject: [PATCH] Prepare a selection watcher interface This commit adds the necessary method calls to setup the class and also so that xfixes selection notify events can be handled. Currently, these are empty functions, but later commits will fill them. Signed-off-by: Uli Schlachter --- CMakeLists.txt | 1 + event.c | 7 +++++++ globalconf.h | 1 + luaa.c | 4 ++++ objects/selection_watcher.c | 34 ++++++++++++++++++++++++++++++++++ objects/selection_watcher.h | 33 +++++++++++++++++++++++++++++++++ 6 files changed, 80 insertions(+) create mode 100644 objects/selection_watcher.c create mode 100644 objects/selection_watcher.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d3d3b4d..a2555f2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,6 +88,7 @@ set(AWE_SRCS ${BUILD_DIR}/objects/drawin.c ${BUILD_DIR}/objects/key.c ${BUILD_DIR}/objects/screen.c + ${BUILD_DIR}/objects/selection_watcher.c ${BUILD_DIR}/objects/tag.c ${BUILD_DIR}/objects/window.c) diff --git a/event.c b/event.c index ddda3a6d..6f23bd08 100644 --- a/event.c +++ b/event.c @@ -24,6 +24,7 @@ #include "property.h" #include "objects/tag.h" #include "objects/drawin.h" +#include "objects/selection_watcher.h" #include "xwindow.h" #include "ewmh.h" #include "objects/client.h" @@ -43,6 +44,7 @@ #include #include #include +#include #define DO_EVENT_HOOK_CALLBACK(type, xcbtype, xcbeventprefix, arraytype, match) \ static void \ @@ -1116,6 +1118,7 @@ void event_handle(xcb_generic_event_t *event) EXTENSION_EVENT(randr, XCB_RANDR_NOTIFY, event_handle_randr_output_change_notify); EXTENSION_EVENT(shape, XCB_SHAPE_NOTIFY, event_handle_shape_notify); EXTENSION_EVENT(xkb, 0, event_handle_xkb_notify); + EXTENSION_EVENT(xfixes, XCB_XFIXES_SELECTION_NOTIFY, event_handle_xfixes_selection_notify); #undef EXTENSION_EVENT } @@ -1134,6 +1137,10 @@ void event_init(void) reply = xcb_get_extension_data(globalconf.connection, &xcb_xkb_id); if (reply && reply->present) globalconf.event_base_xkb = reply->first_event; + + reply = xcb_get_extension_data(globalconf.connection, &xcb_xfixes_id); + if (reply && reply->present) + globalconf.event_base_xfixes = reply->first_event; } // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/globalconf.h b/globalconf.h index 9224bd37..1001f913 100644 --- a/globalconf.h +++ b/globalconf.h @@ -115,6 +115,7 @@ typedef struct uint8_t event_base_shape; uint8_t event_base_xkb; uint8_t event_base_randr; + uint8_t event_base_xfixes; /** Clients list */ client_array_t clients; /** Embedded windows */ diff --git a/luaa.c b/luaa.c index bfe8eee3..c26d3a31 100644 --- a/luaa.c +++ b/luaa.c @@ -49,6 +49,7 @@ #include "objects/drawable.h" #include "objects/drawin.h" #include "objects/screen.h" +#include "objects/selection_watcher.h" #include "objects/tag.h" #include "property.h" #include "selection.h" @@ -1035,6 +1036,9 @@ luaA_init(xdgHandle* xdg, string_array_t *searchpath) /* Export keys */ key_class_setup(L); + /* Export selection watcher */ + selection_watcher_class_setup(L); + /* add Lua search paths */ lua_getglobal(L, "package"); if (LUA_TTABLE != lua_type(L, 1)) diff --git a/objects/selection_watcher.c b/objects/selection_watcher.c new file mode 100644 index 00000000..360d5b9e --- /dev/null +++ b/objects/selection_watcher.c @@ -0,0 +1,34 @@ +/* + * selection_watcher.h - selection change watcher + * + * Copyright © 2019 Uli Schlachter + * + * 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. + * + */ + +#include "objects/selection_watcher.h" + +void +event_handle_xfixes_selection_notify(xcb_generic_event_t *ev) +{ +} + +void +selection_watcher_class_setup(lua_State *L) +{ +} + +// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/objects/selection_watcher.h b/objects/selection_watcher.h new file mode 100644 index 00000000..cb743076 --- /dev/null +++ b/objects/selection_watcher.h @@ -0,0 +1,33 @@ +/* + * selection_watcher.h - selection change watcher header + * + * Copyright © 2019 Uli Schlachter + * + * 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 AWESOME_OBJECTS_SELECTION_WATCHER_H +#define AWESOME_OBJECTS_SELECTION_WATCHER_H + +#include +#include + +void selection_watcher_class_setup(lua_State*); +void event_handle_xfixes_selection_notify(xcb_generic_event_t*); + +#endif + +// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80