From 4c9a707f472e49bc3005354db265a0214071d46b Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 2 Apr 2009 12:13:35 +0200 Subject: wm: remove This has never worked, and is not maintained nor developed anymore. Signed-off-by: Julien Danjou --- Makefile.am | 2 +- README | 1 - configure.ac | 1 - wm/.gitignore | 1 - wm/Makefile.am | 46 ------- wm/manage.c | 146 ---------------------- wm/reply_formats.c | 353 ----------------------------------------------------- wm/reply_formats.h | 31 ----- wm/table.c | 89 -------------- wm/xcb-wm.pc.in | 11 -- wm/xcb_wm.h | 57 --------- wm/xcbwm-test.c | 260 --------------------------------------- 12 files changed, 1 insertion(+), 997 deletions(-) delete mode 100644 wm/.gitignore delete mode 100644 wm/Makefile.am delete mode 100644 wm/manage.c delete mode 100644 wm/reply_formats.c delete mode 100644 wm/reply_formats.h delete mode 100644 wm/table.c delete mode 100644 wm/xcb-wm.pc.in delete mode 100644 wm/xcb_wm.h delete mode 100644 wm/xcbwm-test.c diff --git a/Makefile.am b/Makefile.am index 250beca..80483ab 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ MAINTAINERCLEANFILES = Makefile.in -SUBDIRS = atom aux event property icccm image keysyms reply wm renderutil +SUBDIRS = atom aux event property icccm image keysyms reply renderutil diff --git a/README b/README index 5a31b5e..534a0be 100644 --- a/README +++ b/README @@ -18,7 +18,6 @@ icccm: Both client and window-manager helpers for ICCCM. keysyms: Standard X key constants and conversion to/from keycodes. event: Callback X event handling. image: Port of Xlib's XImage and XShmImage functions. -wm: Framework for window manager implementation. If you find any of these libraries useful, please let us know what you're using and why you aren't in a mental hospital yet. We'd welcome diff --git a/configure.ac b/configure.ac index e4d16f9..a67cbcc 100644 --- a/configure.ac +++ b/configure.ac @@ -66,7 +66,6 @@ AC_OUTPUT([Makefile keysyms/Makefile keysyms/xcb-keysyms.pc property/Makefile property/xcb-property.pc icccm/Makefile icccm/xcb-icccm.pc - wm/Makefile wm/xcb-wm.pc renderutil/Makefile renderutil/xcb-renderutil.pc xcb_util_intro ]) diff --git a/wm/.gitignore b/wm/.gitignore deleted file mode 100644 index a879c0f..0000000 --- a/wm/.gitignore +++ /dev/null @@ -1 +0,0 @@ -xcbwm-test diff --git a/wm/Makefile.am b/wm/Makefile.am deleted file mode 100644 index 03df8f9..0000000 --- a/wm/Makefile.am +++ /dev/null @@ -1,46 +0,0 @@ - -MAINTAINERCLEANFILES = Makefile.in - -lib_LTLIBRARIES = libxcb-wm.la - -xcbinclude_HEADERS = xcb_wm.h - -AM_CFLAGS = $(CWARNFLAGS) - -XCB_XCBWM_LIBS = libxcb-wm.la - -libxcb_wm_la_SOURCES = manage.c table.c -libxcb_wm_la_CPPFLAGS = $(XCB_CFLAGS) \ - $(XCB_AUX_CFLAGS) \ - $(XCB_ATOM_CFLAGS) \ - $(XCB_EVENT_CFLAGS) \ - $(XCB_PROPERTY_CFLAGS) \ - $(XCB_ICCCM_CFLAGS) -libxcb_wm_la_LIBADD = $(XCB_LIBS) \ - $(XCB_AUX_LIBS) \ - $(XCB_ATOM_LIBS) \ - $(XCB_EVENT_LIBS) \ - $(XCB_PROPERTY_LIBS) \ - $(XCB_ICCCM_LIBS) - -pkgconfig_DATA = xcb-wm.pc - -EXTRA_DIST = xcb-wm.pc.in - -noinst_PROGRAMS = xcbwm-test - -xcbwm_test_SOURCES = xcbwm-test.c reply_formats.c reply_formats.h -xcbwm_test_CPPFLAGS = $(XCB_CFLAGS) \ - $(XCB_AUX_CFLAGS) \ - $(XCB_ATOM_CFLAGS) \ - $(XCB_EVENT_CFLAGS) \ - $(XCB_PROPERTY_CFLAGS) \ - $(XCB_ICCCM_CFLAGS) -xcbwm_test_LDADD = $(XCB_LIBS) \ - $(XCB_ATOM_LIBS) \ - $(XCB_AUX_LIBS) \ - $(XCB_EVENT_LIBS) \ - $(XCB_PROPERTY_LIBS) \ - $(XCB_ICCCM_LIBS) \ - $(XCB_XCBWM_LIBS) \ - -lpthread diff --git a/wm/manage.c b/wm/manage.c deleted file mode 100644 index c4349f7..0000000 --- a/wm/manage.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright © 2008 Ian Osgood - * Copyright © 2008 Josh Triplett - * Copyright © 2008 Thomas Hunger - * Copyright © 2008 Torri Vincent - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the names of the authors or - * their institutions shall not be used in advertising or otherwise to - * promote the sale, use or other dealings in this Software without - * prior written authorization from the authors. - */ - -#include -#include -#include "xcb_wm.h" - -table_t *byChild = 0; -table_t *byParent = 0; - -void manage_window(xcb_property_handlers_t *prophs, xcb_connection_t *c, xcb_window_t window, window_attributes_t wa) -{ - xcb_drawable_t d = { window }; - xcb_get_geometry_cookie_t geomc; - xcb_get_geometry_reply_t *geom; - xcb_get_window_attributes_reply_t *attr = 0; - if(wa.tag == TAG_COOKIE) - { - attr = xcb_get_window_attributes_reply(c, wa.u.cookie, 0); - if(!attr) - return; - if(attr->map_state != XCB_MAP_STATE_VIEWABLE) - { - printf("Window 0x%08x is not mapped. Ignoring.\n", window); - free(attr); - return; - } - wa.tag = TAG_VALUE; - wa.u.override_redirect = attr->override_redirect; - } - if(!wa.u.override_redirect && table_get(byChild, window)) - { - printf("Window 0x%08x already managed. Ignoring.\n", window); - free(attr); - return; - } - if(wa.u.override_redirect) - { - printf("Window 0x%08x has override-redirect set. Ignoring.\n", window); - free(attr); - return; - } - geomc = xcb_get_geometry(c, d); - if(!attr) - { - wa.tag = TAG_COOKIE; - wa.u.cookie = xcb_get_window_attributes(c, window); - attr = xcb_get_window_attributes_reply(c, wa.u.cookie, 0); - } - geom = xcb_get_geometry_reply(c, geomc, 0); - if(attr && geom) - { - reparent_window(c, window, attr->visual, geom->root, geom->depth, geom->x, geom->y, geom->width, geom->height); - xcb_property_changed(prophs, XCB_PROPERTY_NEW_VALUE, window, WM_NAME); - } - free(attr); - free(geom); -} - -int handle_map_notify_event(void *prophs, xcb_connection_t *c, xcb_map_notify_event_t *e) -{ - window_attributes_t wa = { TAG_VALUE }; - wa.u.override_redirect = e->override_redirect; - printf("MapNotify for 0x%08x.\n", e->window); - manage_window(prophs, c, e->window, wa); - return 1; -} - -int handle_unmap_notify_event(void *data, xcb_connection_t *c, xcb_unmap_notify_event_t *e) -{ - client_window_t *client = table_remove(byChild, e->event); - xcb_window_t root; - printf("UnmapNotify for 0x%08x (received from 0x%08x): ", e->window, e->event); - if(!client) - { - printf("not a managed window. Ignoring.\n"); - return 0; - } - - root = xcb_setup_roots_iterator(xcb_get_setup(c)).data->root; - printf("child of 0x%08x.\n", client->parent); - xcb_reparent_window(c, client->child, root, 0, 0); - xcb_destroy_window(c, client->parent); - xcb_flush(c); - table_remove(byParent, client->parent); - free(client); - return 1; -} - -void manage_existing_windows(xcb_connection_t *c, xcb_property_handlers_t *prophs, xcb_window_t root) -{ - xcb_query_tree_cookie_t wintree; - xcb_query_tree_reply_t *rep; - int i, len; - xcb_window_t *children; - xcb_get_window_attributes_cookie_t *cookies; - - wintree = xcb_query_tree(c, root); - rep = xcb_query_tree_reply(c, wintree, 0); - if(!rep) - return; - len = xcb_query_tree_children_length(rep); - cookies = malloc(len * sizeof(*cookies)); - if(!cookies) - { - free(rep); - return; - } - children = xcb_query_tree_children(rep); - for(i = 0; i < len; ++i) - cookies[i] = xcb_get_window_attributes(c, children[i]); - for(i = 0; i < len; ++i) - { - window_attributes_t wa = { TAG_COOKIE, { cookies[i] } }; - manage_window(prophs, c, children[i], wa); - } - free(rep); -} diff --git a/wm/reply_formats.c b/wm/reply_formats.c deleted file mode 100644 index 3702648..0000000 --- a/wm/reply_formats.c +++ /dev/null @@ -1,353 +0,0 @@ -/* - * Copyright © 2008 Bart Massey - * Copyright © 2008 Jamey Sharp - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the names of the authors or - * their institutions shall not be used in advertising or otherwise to - * promote the sale, use or other dealings in this Software without - * prior written authorization from the authors. - */ -#include -#include "reply_formats.h" - -#define WINFMT "0x%08x" - -int format_get_window_attributes_reply(xcb_window_t wid, xcb_get_window_attributes_reply_t *reply) -{ - if(!reply) - { - fprintf(stderr, "Failed to get attributes for window " WINFMT ".\n", - (unsigned int) wid); - return 0; - } - - printf("Window " WINFMT " has attributes:\n" - " backingStore = %d\n" - " visualID = %#x\n" - " class = %d\n" - " bitGravity = %d\n" - " winGravity = %d\n" - " backingBitPlanes = 0x%08x\n" - " backingPixel = %d\n" - " saveUnder = %d\n" - " mapInstalled = %d\n" - " mapState = %d\n" - " override = %d\n" - " colormap = 0x%08x\n" - " allEventMasks = 0x%08x\n" - " yourEventMask = 0x%08x\n" - " doNotPropagateMask = 0x%08x\n", - (unsigned int) wid, - reply->backing_store, - (unsigned int) reply->visual, - reply->_class, - reply->bit_gravity, - reply->win_gravity, - reply->backing_planes, - reply->backing_pixel, - reply->save_under, - reply->map_is_installed, - reply->map_state, - reply->override_redirect, - (unsigned int) reply->colormap, - (unsigned int) reply->all_event_masks, - (unsigned int) reply->your_event_mask, - reply->do_not_propagate_mask); - - fflush(stdout); - return 1; -} - -int format_get_geometry_reply(xcb_window_t wid, xcb_get_geometry_reply_t *reply) -{ - if(!reply) - { - fprintf(stderr, "Failed to get geometry for window " WINFMT ".\n", - (unsigned int) wid); - return 0; - } - - printf("Geometry for window " WINFMT ": %dx%d%+d%+d\n", - (unsigned int) wid, - reply->width, - reply->height, - reply->x, - reply->y); - - fflush(stdout); - return 1; -} - -int format_query_tree_reply(xcb_window_t wid, xcb_query_tree_reply_t *reply) -{ - int i; - - if(!reply) - { - fprintf(stderr, "Failed to query tree for window " WINFMT ".\n", - (unsigned int) wid); - return 0; - } - - printf("Window " WINFMT " has parent " WINFMT ", root " WINFMT ", and %d children%c\n", - (unsigned int) wid, - (unsigned int) reply->parent, - (unsigned int) reply->root, - (unsigned int) reply->children_len, - reply->children_len ? ':' : '.'); - - for(i = 0; i < reply->children_len; ++i) - printf(" window " WINFMT "\n", - (unsigned int) xcb_query_tree_children(reply)[i]); - - fflush(stdout); - return 1; -} - -static const char *labelError[] = { - "Success", - "BadRequest", - "BadValue", - "BadWindow", - "BadPixmap", - "BadAtom", - "BadCursor", - "BadFont", - "BadMatch", - "BadDrawable", - "BadAccess", - "BadAlloc", - "BadColor", - "BadGC", - "BadIDChoice", - "BadName", - "BadLength", - "BadImplementation", -}; - -static const char *labelRequest[] = { - "no request", - "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", -}; - -static const char *labelEvent[] = { - "error", - "reply", - "KeyPress", - "KeyRelease", - "ButtonPress", - "ButtonRelease", - "MotionNotify", - "EnterNotify", - "LeaveNotify", - "FocusIn", - "FocusOut", - "KeymapNotify", - "Expose", - "GraphicsExpose", - "NoExpose", - "VisibilityNotify", - "CreateNotify", - "DestroyNotify", - "UnmapNotify", - "MapNotify", - "MapRequest", - "ReparentNotify", - "ConfigureNotify", - "ConfigureRequest", - "GravityNotify", - "ResizeRequest", - "CirculateNotify", - "CirculateRequest", - "PropertyNotify", - "SelectionClear", - "SelectionRequest", - "SelectionNotify", - "ColormapNotify", - "ClientMessage", - "MappingNotify", -}; - -static const char *labelSendEvent[] = { - "", - " (from SendEvent)", -}; - -int format_event(xcb_generic_event_t *e) -{ - uint8_t sendEvent; - uint16_t seqnum; - - sendEvent = (e->response_type & 0x80) ? 1 : 0; - e->response_type &= ~0x80; - seqnum = *((uint16_t *) e + 1); - - switch(e->response_type) - { - case 0: - printf("Error %s on seqnum %d (%s).\n", - labelError[*((uint8_t *) e + 1)], - seqnum, - labelRequest[*((uint8_t *) e + 10)]); - break; - default: - printf("Event %s following seqnum %d%s.\n", - labelEvent[e->response_type], - seqnum, - labelSendEvent[sendEvent]); - break; - case XCB_KEYMAP_NOTIFY: - printf("Event %s%s.\n", - labelEvent[e->response_type], - labelSendEvent[sendEvent]); - break; - } - - fflush(stdout); - return 1; -} diff --git a/wm/reply_formats.h b/wm/reply_formats.h deleted file mode 100644 index 38530bb..0000000 --- a/wm/reply_formats.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2001-2002 Bart Massey and Jamey Sharp. - * All Rights Reserved. See the file COPYING in this directory - * for licensing information. - */ - -#ifndef REPLY_FORMATS_H -#define REPLY_FORMATS_H - -#include - -int format_get_window_attributes_reply(xcb_window_t wid, xcb_get_window_attributes_reply_t *reply); -int format_get_geometry_reply(xcb_window_t wid, xcb_get_geometry_reply_t *reply); -int format_query_tree_reply(xcb_window_t wid, xcb_query_tree_reply_t *reply); -int format_event(xcb_generic_event_t *e); - -#if 0 /* not yet ready */ -int formatButtonReleaseEvent(void *data, xcb_connection_t *c, xcb_button_release_event_t *event); -int formatEnterNotifyEvent(void *data, xcb_connection_t *c, xcb_enter_notify_event_t *event); -int formatExposeEvent(void *data, xcb_connection_t *c, xcb_expose_event_t *event); -int formatDestroyNotifyEvent(void *data, xcb_connection_t *c, xcb_destroy_notify_event_t *event); -int formatUnmapNotifyEvent(void *data, xcb_connection_t *c, xcb_unmap_notify_event_t *event); -int formatMapNotifyEvent(void *data, xcb_connection_t *c, xcb_map_notify_event_t *event); -int formatReparentNotifyEvent(void *data, xcb_connection_t *c, xcb_reparent_notify_event_t *event); -int formatConfigureNotifyEvent(void *data, xcb_connection_t *c, xcb_configure_notify_event_t *event); -int formatGravityNotifyEvent(void *data, xcb_connection_t *c, xcb_gravity_notify_event_t *event); -int formatCirculateNotifyEvent(void *data, xcb_connection_t *c, xcb_circulate_notify_event_t *event); -int formatClientMessageEvent(void *data, xcb_connection_t *c, xcb_client_message_event_t *event); -#endif - -#endif /* REPLY_FORMATS_H */ diff --git a/wm/table.c b/wm/table.c deleted file mode 100644 index 945d401..0000000 --- a/wm/table.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright © 2008 Ian Osgood - * Copyright © 2008 Josh Triplett - * Copyright © 2008 Thomas Hunger - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the names of the authors or - * their institutions shall not be used in advertising or otherwise to - * promote the sale, use or other dealings in this Software without - * prior written authorization from the authors. - */ - -#include -#include "xcb_wm.h" - -typedef struct node node; -struct node { - node *next; - uint32_t key; - void *value; -}; - -struct table_t { - node *head; -}; - -table_t *alloc_table() -{ - return calloc(1, sizeof(table_t)); -} - -void free_table(table_t *table) -{ - free(table); -} - -int table_put(table_t *table, uint32_t key, void *value) -{ - node *record = malloc(sizeof(node)); - if(!record) - return 0; - record->next = table->head; - record->key = key; - record->value = value; - table->head = record; - return 1; -} - -void *table_get(table_t *table, uint32_t key) -{ - node *cur; - for(cur = table->head; cur; cur = cur->next) - if(cur->key == key) - return cur->value; - return 0; -} - -void *table_remove(table_t *table, uint32_t key) -{ - node **cur; - for(cur = &table->head; *cur; cur = &(*cur)->next) - if((*cur)->key == key) - { - node *tmp = *cur; - void *ret = tmp->value; - *cur = (*cur)->next; - free(tmp); - return ret; - } - return 0; -} diff --git a/wm/xcb-wm.pc.in b/wm/xcb-wm.pc.in deleted file mode 100644 index 0ed613a..0000000 --- a/wm/xcb-wm.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: XCB WM library -Description: XCB window manager convenience library -Version: @PACKAGE_VERSION@ -Requires: xcb xcb-atom xcb-event xcb-property xcb-icccm -Libs: -L${libdir} -lxcb-wm @LIBS@ -Cflags: -I${includedir} diff --git a/wm/xcb_wm.h b/wm/xcb_wm.h deleted file mode 100644 index 7581df7..0000000 --- a/wm/xcb_wm.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef __XCB_WM_H__ -#define __XCB_WM_H__ - -#include -#include "xcb_atom.h" -#include "xcb_property.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - -void reparent_window(xcb_connection_t *c, xcb_window_t child, - xcb_visualid_t v, xcb_window_t r, uint8_t d, - int16_t x, int16_t y, uint16_t width, uint16_t height); - -typedef struct { - xcb_window_t child; - xcb_window_t parent; - int name_len; - char *name; - xcb_gcontext_t titlegc; -} client_window_t; - -typedef struct { - enum xcb_atom_fast_tag_t tag; - union { - xcb_get_window_attributes_cookie_t cookie; - uint8_t override_redirect; - } u; -} window_attributes_t; - -void manage_window(xcb_property_handlers_t *prophs, xcb_connection_t *c, xcb_window_t window, window_attributes_t wa); -int handle_map_notify_event(void *prophs, xcb_connection_t *c, xcb_map_notify_event_t *e); -int handle_unmap_notify_event(void *data, xcb_connection_t *c, xcb_unmap_notify_event_t *e); -void manage_existing_windows(xcb_connection_t *c, xcb_property_handlers_t *prophs, xcb_window_t root); - -typedef struct table_t table_t; - -table_t *alloc_table(); -void free_table(table_t *table); - -int table_put(table_t *table, uint32_t key, void *value); -void *table_get(table_t *table, uint32_t key); -void *table_remove(table_t *table, uint32_t key); - -extern table_t *byChild; -extern table_t *byParent; - - -#ifdef __cplusplus -} -#endif - - -#endif /* __XCB_WM_H__ */ diff --git a/wm/xcbwm-test.c b/wm/xcbwm-test.c deleted file mode 100644 index a711790..0000000 --- a/wm/xcbwm-test.c +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright © 2008 Ian Osgood - * Copyright © 2008 Jamey Sharp - * Copyright © 2008 Josh Triplett - * Copyright © 2008 Julien Danjou - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the names of the authors or - * their institutions shall not be used in advertising or otherwise to - * promote the sale, use or other dealings in this Software without - * prior written authorization from the authors. - */ -#include -#include -#include -#include -#include - -#include -#include "reply_formats.h" -#include "xcb_aux.h" -#include "xcb_event.h" -#include "xcb_atom.h" -#include "xcb_icccm.h" -#include "xcb_wm.h" - -static const int TOP = 20; -static const int LEFT = 5; -static const int BOTTOM = 5; -static const int RIGHT = 5; - -static const int TEST_THREADS = 1; -static const int TEST_WATCH_ROOT = 1; - -static int16_t move_from_x = -1; -static int16_t move_from_y = -1; - -static int handleEvent(void *ignored, xcb_connection_t *c, xcb_generic_event_t *e) -{ - return format_event(e); -} - -static int handleButtonPressEvent(void *data, xcb_connection_t *c, xcb_button_press_event_t *e) -{ - if(move_from_x != -1 && move_from_y != -1) - { - printf("Weird. Got ButtonPress after ButtonPress.\n"); - return 0; - } - move_from_x = e->root_x; - move_from_y = e->root_y; - return 1; -} - -static int handleButtonReleaseEvent(void *data, xcb_connection_t *c, xcb_button_release_event_t *e) -{ - uint32_t values[2]; - if(move_from_x == -1 && move_from_y == -1) - { - printf("Weird. Got ButtonRelease without ButtonPress.\n"); - return 0; - } - values[0] = /* x */ e->root_x; - values[1] = /* y */ e->root_y; - xcb_configure_window(c, e->event, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, values); - xcb_flush(c); - move_from_x = -1; - move_from_y = -1; - return 1; -} - -static int addClientWindow(xcb_window_t child, xcb_window_t parent, xcb_gcontext_t titlegc) -{ - int success; - client_window_t *record = malloc(sizeof(client_window_t)); - assert(record); - record->child = child; - record->parent = parent; - record->name_len = 0; - record->name = 0; - record->titlegc = titlegc; - success = table_put(byParent, parent, record) && - table_put(byChild, child, record); - assert(success); - return 1; -} - -void reparent_window(xcb_connection_t *c, xcb_window_t child, - xcb_visualid_t v, xcb_window_t r, uint8_t d, - int16_t x, int16_t y, uint16_t width, uint16_t height) -{ - xcb_window_t w; - xcb_drawable_t drawable; - uint32_t mask = 0; - uint32_t values[3]; - xcb_screen_t *root = xcb_setup_roots_iterator(xcb_get_setup(c)).data; - xcb_gcontext_t titlegc; - - w = xcb_generate_id(c); - - mask |= XCB_CW_BACK_PIXEL; - values[0] = root->white_pixel; - - mask |= XCB_CW_OVERRIDE_REDIRECT; - values[1] = 1; - - mask |= XCB_CW_EVENT_MASK; - values[2] = XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE - | XCB_EVENT_MASK_EXPOSURE /* | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW */; - - printf("Reparenting 0x%08x under 0x%08x.\n", child, w); - xcb_create_window(c, d, w, r, x, y, - width + LEFT + RIGHT, height + TOP + BOTTOM, - /* border_width */ 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, v, mask, values); - xcb_change_save_set(c, XCB_SET_MODE_INSERT, child); - xcb_map_window(c, w); - - titlegc = xcb_generate_id(c); - - mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND; - values[0] = root->black_pixel; - values[1] = root->white_pixel; - drawable = w; - xcb_create_gc(c, titlegc, drawable, mask, values); - addClientWindow(child, w, titlegc); - - xcb_reparent_window(c, child, w, LEFT - 1, TOP - 1); - - mask = XCB_CW_EVENT_MASK; - values[0] = XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY; - xcb_change_window_attributes(c, child, mask, values); - - xcb_flush(c); -} - -static void redrawWindow(xcb_connection_t *c, client_window_t *client) -{ - xcb_drawable_t d = { client->parent }; - if(!client->name_len) - return; - xcb_clear_area(c, 0, d, 0, 0, 0, 0); - xcb_image_text_8(c, client->name_len, d, client->titlegc, - LEFT - 1, TOP - 4, client->name); - xcb_flush(c); -} - -static int handleExposeEvent(void *data, xcb_connection_t *c, xcb_expose_event_t *e) -{ - client_window_t *client = table_get(byParent, e->window); - if(!client || e->count != 0) - return 1; - redrawWindow(c, client); - return 1; -} - -static int handleWMNameChange(void *data, xcb_connection_t *c, uint8_t state, xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop) -{ - client_window_t *client = table_get(byChild, window); - printf("WM_NAME change: Window 0x%08x ", window); - if(!client) - { - printf("is not being managed.\n"); - return 0; - } - if(client->name) - { - printf("was named \"%.*s\"; now ", client->name_len, client->name); - free(client->name); - } - if(!prop) - { - client->name_len = 0; - client->name = 0; - printf("has no name.\n"); - return 1; - } - - client->name_len = xcb_get_property_value_length(prop); - client->name = malloc(client->name_len); - assert(client->name); - strncpy(client->name, xcb_get_property_value(prop), client->name_len); - printf("is named \"%.*s\".\n", client->name_len, client->name); - - redrawWindow(c, client); - return 1; -} - -int main(int argc, char **argv) -{ - xcb_connection_t *c; - xcb_event_handlers_t evenths; - xcb_property_handlers_t prophs; - xcb_window_t root; - pthread_t event_thread; - int screen_nbr; - int i; - - byChild = alloc_table(); - byParent = alloc_table(); - - c = xcb_connect(NULL, &screen_nbr); - - xcb_event_handlers_init(c, &evenths); - - for(i = 2; i < 128; ++i) - xcb_event_set_handler(&evenths, i, handleEvent, 0); - for(i = 0; i < 256; ++i) - xcb_event_set_error_handler(&evenths, i, (xcb_generic_error_handler_t) handleEvent, 0); - xcb_event_set_button_press_handler(&evenths, handleButtonPressEvent, 0); - xcb_event_set_button_release_handler(&evenths, handleButtonReleaseEvent, 0); - xcb_event_set_unmap_notify_handler(&evenths, handle_unmap_notify_event, 0); - xcb_event_set_expose_handler(&evenths, handleExposeEvent, 0); - - xcb_property_handlers_init(&prophs, &evenths); - xcb_event_set_map_notify_handler(&evenths, handle_map_notify_event, &prophs); - xcb_watch_wm_name(&prophs, 40, handleWMNameChange, 0); - - if(TEST_THREADS) - { - pthread_create(&event_thread, 0, (void *(*)(void *))xcb_event_wait_for_event_loop, &evenths); - } - - root = xcb_aux_get_screen(c, screen_nbr)->root; - - { - uint32_t mask = XCB_CW_EVENT_MASK; - uint32_t values[] = { XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE }; - xcb_change_window_attributes(c, root, mask, values); - } - xcb_flush(c); - - manage_existing_windows(c, &prophs, root); - - /* Terminate only when the event loop terminates */ - if(TEST_THREADS) - pthread_join(event_thread, 0); - else - xcb_event_wait_for_event_loop(&evenths); - - exit(0); - /*NOTREACHED*/ -} -- cgit v1.2.3