mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
xenv: allow to specify event filter
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@949 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
eef1557e17
commit
bd34c5a85c
2 changed files with 23 additions and 14 deletions
|
@ -25,6 +25,8 @@
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <linux/kd.h>
|
#include <linux/kd.h>
|
||||||
|
|
||||||
|
#include "xenv.h"
|
||||||
|
|
||||||
#define PFX "xenv: "
|
#define PFX "xenv: "
|
||||||
|
|
||||||
#define FPTR(f) typeof(f) * p##f
|
#define FPTR(f) typeof(f) * p##f
|
||||||
|
@ -81,13 +83,14 @@ static Cursor transparent_cursor(struct xstuff *xf, Display *display, Window win
|
||||||
return cursor;
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int x11h_init(const char *window_title)
|
static int x11h_init(int *xenv_flags, const char *window_title)
|
||||||
{
|
{
|
||||||
unsigned int display_width, display_height;
|
unsigned int display_width, display_height;
|
||||||
Display *display;
|
Display *display;
|
||||||
XSetWindowAttributes attributes;
|
XSetWindowAttributes attributes;
|
||||||
Window win;
|
Window win;
|
||||||
Visual *visual;
|
Visual *visual;
|
||||||
|
long evt_mask;
|
||||||
void *x11lib;
|
void *x11lib;
|
||||||
int screen;
|
int screen;
|
||||||
|
|
||||||
|
@ -153,10 +156,14 @@ static int x11h_init(const char *window_title)
|
||||||
attributes.cursor = transparent_cursor(&g_xstuff, display, win);
|
attributes.cursor = transparent_cursor(&g_xstuff, display, win);
|
||||||
g_xstuff.pXChangeWindowAttributes(display, win, CWOverrideRedirect | CWCursor, &attributes);
|
g_xstuff.pXChangeWindowAttributes(display, win, CWOverrideRedirect | CWCursor, &attributes);
|
||||||
|
|
||||||
g_xstuff.pXStoreName(display, win, window_title);
|
if (window_title != NULL)
|
||||||
g_xstuff.pXSelectInput(display, win, ExposureMask | FocusChangeMask
|
g_xstuff.pXStoreName(display, win, window_title);
|
||||||
| KeyPressMask | KeyReleaseMask | ButtonPressMask
|
evt_mask = ExposureMask | FocusChangeMask | PropertyChangeMask;
|
||||||
| ButtonReleaseMask | PointerMotionMask | PropertyChangeMask);
|
if (xenv_flags && (*xenv_flags & XENV_CAP_KEYS))
|
||||||
|
evt_mask |= KeyPressMask | KeyReleaseMask;
|
||||||
|
if (xenv_flags && (*xenv_flags & XENV_CAP_MOUSE))
|
||||||
|
evt_mask |= ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
|
||||||
|
g_xstuff.pXSelectInput(display, win, evt_mask);
|
||||||
g_xstuff.pXMapWindow(display, win);
|
g_xstuff.pXMapWindow(display, win);
|
||||||
g_xstuff.pXGrabKeyboard(display, win, False, GrabModeAsync, GrabModeAsync, CurrentTime);
|
g_xstuff.pXGrabKeyboard(display, win, False, GrabModeAsync, GrabModeAsync, CurrentTime);
|
||||||
g_xstuff.pXkbSetDetectableAutoRepeat(display, 1, NULL);
|
g_xstuff.pXkbSetDetectableAutoRepeat(display, 1, NULL);
|
||||||
|
@ -368,17 +375,16 @@ static void tty_end(void)
|
||||||
g_kbdfd = -1;
|
g_kbdfd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int xenv_init(int *have_mouse_events, const char *window_title)
|
int xenv_init(int *xenv_flags, const char *window_title)
|
||||||
{
|
{
|
||||||
int have_mouse = 0;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = x11h_init(window_title);
|
ret = x11h_init(xenv_flags, window_title);
|
||||||
if (ret == 0) {
|
if (ret == 0)
|
||||||
have_mouse = 1;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
|
if (xenv_flags != NULL)
|
||||||
|
*xenv_flags &= ~(XENV_CAP_KEYS | XENV_CAP_MOUSE); /* TODO? */
|
||||||
ret = tty_init();
|
ret = tty_init();
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -386,8 +392,6 @@ int xenv_init(int *have_mouse_events, const char *window_title)
|
||||||
fprintf(stderr, PFX "error: both x11h_init and tty_init failed\n");
|
fprintf(stderr, PFX "error: both x11h_init and tty_init failed\n");
|
||||||
ret = -1;
|
ret = -1;
|
||||||
out:
|
out:
|
||||||
if (have_mouse_events != NULL)
|
|
||||||
*have_mouse_events = have_mouse;
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
|
|
||||||
int xenv_init(int *have_mouse_events, const char *window_title);
|
#define XENV_CAP_KEYS (1<<0)
|
||||||
|
#define XENV_CAP_MOUSE (1<<1)
|
||||||
|
|
||||||
|
/* xenv_flags specify if we need keys and mouse,
|
||||||
|
* flag is removed if input is not available */
|
||||||
|
int xenv_init(int *xenv_flags, const char *window_title);
|
||||||
|
|
||||||
/* read events from X, calling key_cb for key, mouseb_cb for mouse button
|
/* read events from X, calling key_cb for key, mouseb_cb for mouse button
|
||||||
* and mousem_cb for mouse motion events */
|
* and mousem_cb for mouse motion events */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue