This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 561ab88b80e943a571fa0aa84b3ed0816e6812eb (commit) from 378721e46cdafc7ba99e30f51b8b8395fb254de0 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/561ab88b80e943a571fa0aa84b3ed0816e681...
commit 561ab88b80e943a571fa0aa84b3ed0816e6812eb Author: Cyril Hrubis metan@ucw.cz Date: Tue Nov 12 19:55:46 2013 +0100
backends: X11: Cleanup + Fullscreen fixes
* Cleanup the source
* Add NetWM Window Manager detection code
* Fix event mask for while sending fullscreen request (Fixes fullscreen in OpenBox)
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/build/syms/Backend_symbols.txt b/build/syms/Backend_symbols.txt index d2945d1..4c830bf 100644 --- a/build/syms/Backend_symbols.txt +++ b/build/syms/Backend_symbols.txt @@ -24,6 +24,4 @@ GP_BackendPollEvent GP_BackendAddTimer GP_BackendRemTimer
-GP_InputDriverX11EventPut -GP_InputDriverX11Init GP_InputDriverSDLEventPut diff --git a/libs/backends/GP_InputDriverX11.h b/libs/backends/GP_InputDriverX11.h deleted file mode 100644 index 95c3b08..0000000 --- a/libs/backends/GP_InputDriverX11.h +++ /dev/null @@ -1,42 +0,0 @@ -/***************************************************************************** - * This file is part of gfxprim library. * - * * - * Gfxprim is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * Gfxprim 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 * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with gfxprim; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02110-1301 USA * - * * - * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * - * * - *****************************************************************************/ - -#ifndef GP_INPUT_DRIVER_X11_H -#define GP_INPUT_DRIVER_X11_H - -#include <stdint.h> -#include <X11/Xlib.h> - -struct GP_EventQueue; - -/* - * Loads X11 KeyCode translation table. - */ -void GP_InputDriverX11Init(Display *dpy); - -/* - * Converts X11 event to GFXprim event and puts it into the queue. - */ -void GP_InputDriverX11EventPut(struct GP_EventQueue *event_queue, - XEvent *ev, int w, int h); - -#endif /* GP_INPUT_DRIVER_X11_H */ diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c index 3379dd0..5b64b49 100644 --- a/libs/backends/GP_X11.c +++ b/libs/backends/GP_X11.c @@ -41,12 +41,11 @@ #include <X11/extensions/XShm.h> #endif /* HAVE_X_SHM */
-#include "GP_InputDriverX11.h" - #include "backends/GP_X11.h"
#include "GP_X11_Conn.h" #include "GP_X11_Win.h" +#include "GP_X11_Input.h"
static int resize_ximage(GP_Backend *self, int w, int h); static int resize_shm_ximage(GP_Backend *self, int w, int h); @@ -166,8 +165,8 @@ static void x11_ev(XEvent *ev) win->resized_flag = 1; default: //TODO: More accurate window w and h? - GP_InputDriverX11EventPut(&self->event_queue, ev, - self->context->w, self->context->h); + x11_input_event_put(&self->event_queue, ev, + self->context->w, self->context->h); break; } } diff --git a/libs/backends/GP_X11_Conn.h b/libs/backends/GP_X11_Conn.h index 87a188c..3bbd683 100644 --- a/libs/backends/GP_X11_Conn.h +++ b/libs/backends/GP_X11_Conn.h @@ -26,7 +26,18 @@ struct x11_conn { Display *dpy;
- /* window reference counter */ + /* X Atoms */ + Atom A_WM_DELETE_WINDOW; + + /* NetWM Atoms */ + Atom A__NET_WM_STATE; + Atom A__NET_WM_STATE_FULLSCREEN; + + /* Bitflags for supported Atoms */ + int S__NET_WM_STATE:1; + int S__NET_WM_STATE_FULLSCREEN:1; + + /* reference counter, incremented on window creation */ unsigned int ref_cnt; };
@@ -35,6 +46,54 @@ static struct x11_conn x11_conn = { .ref_cnt = 0, };
+static int x11_get_property(Atom type, Atom **args, unsigned long *count) +{ + int ret, format; + unsigned long bytesafter; + + ret = XGetWindowProperty(x11_conn.dpy, XDefaultRootWindow(x11_conn.dpy), + type, 0, 16384, False, AnyPropertyType, &type, + &format, count, &bytesafter, (void*)args); + + return ret == Success && *count > 0; +} + +#define ATOM_SUPPORTED(name, type, atom) do { + if (x11_conn.A_##name == atom) { + GP_DEBUG(2, type " Atom '" #name "' is supported."); + x11_conn.S_##name = 1; + } +} while (0) + +static void x11_check_atoms(Atom at) +{ + ATOM_SUPPORTED(_NET_WM_STATE, "NetWM", at); + ATOM_SUPPORTED(_NET_WM_STATE_FULLSCREEN, "NetWM", at); +} + +#define INIT_ATOM(name) x11_conn.A_##name = XInternAtom(x11_conn.dpy, #name, False) + +static void x11_detect_wm_features(void) +{ + Atom *args = NULL, at; + unsigned long count, i; + + INIT_ATOM(WM_DELETE_WINDOW); + INIT_ATOM(_NET_WM_STATE); + INIT_ATOM(_NET_WM_STATE_FULLSCREEN); + + at = XInternAtom(x11_conn.dpy, "_NET_SUPPORTED", True); + + if (x11_get_property(at, &args, &count)) { + GP_DEBUG(1, "Window manager supports NetWM"); + + for (i = 0; i < count; i++) + x11_check_atoms(args[i]); + } +} + +static void x11_input_init(void); + static unsigned int x11_open(const char *display) { if (x11_conn.ref_cnt != 0) @@ -55,7 +114,8 @@ static unsigned int x11_open(const char *display) }
/* Initialized key translation table */ - GP_InputDriverX11Init(x11_conn.dpy); + x11_input_init(); + x11_detect_wm_features();
return ++x11_conn.ref_cnt; } diff --git a/libs/backends/GP_InputDriverX11.c b/libs/backends/GP_X11_Input.h similarity index 92% rename from libs/backends/GP_InputDriverX11.c rename to libs/backends/GP_X11_Input.h index a271360..c4364b4 100644 --- a/libs/backends/GP_InputDriverX11.c +++ b/libs/backends/GP_X11_Input.h @@ -20,19 +20,9 @@ * * *****************************************************************************/
-#include "../../config.h" - -#include "core/GP_Debug.h" -#include "core/GP_Common.h" -#include "input/GP_EventQueue.h" - -#ifdef HAVE_LIBX11 - #include <X11/keysym.h> #include <X11/XF86keysym.h>
-#include "GP_InputDriverX11.h" - /* X11 keycodes */ static uint16_t keycode_table[] = { 0, GP_KEY_1, GP_KEY_2, GP_KEY_3, @@ -149,7 +139,7 @@ static const struct keytable sym_to_key[] = { {XF86XK_AudioPlay, GP_KEY_PLAYPAUSE}, };
-static void init_table(Display *dpy) +static void x11_input_init(void) { GP_DEBUG(1, "Initializing X11 KeyCode table");
@@ -158,7 +148,8 @@ static void init_table(Display *dpy) for (i = 0; i < GP_ARRAY_SIZE(sym_to_key); i++) { unsigned int keycode;
- keycode = XKeysymToKeycode(dpy, sym_to_key[i].x_keysym); + keycode = XKeysymToKeycode(x11_conn.dpy, + sym_to_key[i].x_keysym);
if (keycode == 0) { GP_DEBUG(1, "KeySym '%s' (%u) not defined", @@ -203,13 +194,8 @@ static unsigned int get_key(unsigned int xkey) return key; }
-void GP_InputDriverX11Init(Display *dpy) -{ - init_table(dpy); -} - -void GP_InputDriverX11EventPut(struct GP_EventQueue *event_queue, - XEvent *ev, int w, int h) +static void x11_input_event_put(struct GP_EventQueue *event_queue, + XEvent *ev, int w, int h) { int key = 0, press = 0;
@@ -274,17 +260,12 @@ void GP_InputDriverX11EventPut(struct GP_EventQueue *event_queue, break; /* events from WM */ case ClientMessage: - //TODO: We know we get WM_DELETE_WINDOW because it's the only - // event we requested to get but we must check anyway - GP_EventQueuePush(event_queue, GP_EV_SYS, - GP_EV_SYS_QUIT, 0, NULL); -#if 0 - switch (ev->xclient.message_type) { - default: - GP_WARN("Unknown X11 ClientMessage Atom %i", - ev->xclient.message_type); + if ((Atom)ev->xclient.data.l[0] == x11_conn.A_WM_DELETE_WINDOW) { + GP_EventQueuePush(event_queue, GP_EV_SYS, + GP_EV_SYS_QUIT, 0, NULL); + return; } -#endif + GP_WARN("Unknown X Client Message"); break; case MapNotify: GP_DEBUG(1, "MapNotify event received"); @@ -299,5 +280,3 @@ void GP_InputDriverX11EventPut(struct GP_EventQueue *event_queue, GP_WARN("Unhandled X11 event type %u", ev->type); } } - -#endif /* HAVE_LIBX11 */ diff --git a/libs/backends/GP_X11_Win.h b/libs/backends/GP_X11_Win.h index b2dfec3..8466961 100644 --- a/libs/backends/GP_X11_Win.h +++ b/libs/backends/GP_X11_Win.h @@ -90,17 +90,11 @@ static struct x11_win *win_list_lookup(Window win) return NULL; }
-#ifndef _NET_WM_STATE_ADD -# define _NET_WM_STATE_ADD 1 -#endif /* _NET_WM_STATE_ADD */ - -#ifndef _NET_WM_STATE_REMOVE -# define _NET_WM_STATE_REMOVE 0 -#endif /* _NET_WM_STATE_REMOVE */ - /* Send NETWM message, most modern Window Managers should understand */ static void x11_win_fullscreen(struct x11_win *win, int mode) { + XEvent ev; + if (mode < 0 || mode > 2) { GP_WARN("Invalid fullscreen mode = %u", mode); return; @@ -108,31 +102,19 @@ static void x11_win_fullscreen(struct x11_win *win, int mode)
GP_DEBUG(2, "Requesting fullscreen mode = %u", mode);
- Atom wm_state, fullscreen; - - wm_state = XInternAtom(win->dpy, "_NET_WM_STATE", True); - fullscreen = XInternAtom(win->dpy, "_NET_WM_STATE_FULLSCREEN", True); - - if (wm_state == None || fullscreen == None) { - GP_WARN("Failed to create _NET_WM_* atoms"); - return; - } - - XEvent ev; - memset(&ev, 0, sizeof(ev));
ev.type = ClientMessage; ev.xclient.window = win->win; - ev.xclient.message_type = wm_state; + ev.xclient.message_type = x11_conn.A__NET_WM_STATE; ev.xclient.format = 32; ev.xclient.data.l[0] = mode; - ev.xclient.data.l[1] = fullscreen; + ev.xclient.data.l[1] = x11_conn.A__NET_WM_STATE_FULLSCREEN; ev.xclient.data.l[2] = 0; ev.xclient.data.l[3] = 1;
if (!XSendEvent(win->dpy, XDefaultRootWindow(win->dpy), - False, SubstructureNotifyMask, &ev)) { + False, SubstructureNotifyMask|SubstructureRedirectMask, &ev)) { GP_WARN("Failed to send _NET_WM_STATE_FULLSCREEN event"); return; } @@ -364,15 +346,7 @@ static int x11_win_open(struct x11_wreq *wreq) NULL, 0, NULL, NULL, NULL);
/* Make the window close button send event */ - Atom xa = XInternAtom(win->dpy, "WM_DELETE_WINDOW", True); - - if (xa != None) { - GP_DEBUG(2, "Setting WM_DELETE_WINDOW Atom to True"); - - XSetWMProtocols(win->dpy, win->win, &xa, 1); - } else { - GP_DEBUG(2, "Failed to set WM_DELETE_WINDOW Atom to True"); - } + XSetWMProtocols(win->dpy, win->win, &x11_conn.A_WM_DELETE_WINDOW, 1);
win_list_add(win);
-----------------------------------------------------------------------
Summary of changes: build/syms/Backend_symbols.txt | 2 - libs/backends/GP_InputDriverX11.h | 42 ------------- libs/backends/GP_X11.c | 7 +- libs/backends/GP_X11_Conn.h | 64 +++++++++++++++++++- .../{GP_InputDriverX11.c => GP_X11_Input.h} | 41 +++---------- libs/backends/GP_X11_Win.h | 38 ++---------- 6 files changed, 81 insertions(+), 113 deletions(-) delete mode 100644 libs/backends/GP_InputDriverX11.h rename libs/backends/{GP_InputDriverX11.c => GP_X11_Input.h} (92%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.