mirror of
https://repo.dec05eba.com/gpu-screen-recorder
synced 2026-03-31 09:07:13 +09:00
Remove xi2 code, it's not needed
This commit is contained in:
@@ -62,7 +62,7 @@ These are the dependencies needed to build GPU Screen Recorder:
|
|||||||
|
|
||||||
* libglvnd (which provides libgl, libglx and libegl)
|
* libglvnd (which provides libgl, libglx and libegl)
|
||||||
* ffmpeg (libavcodec, libavformat, libavutil, libswresample, libavfilter)
|
* ffmpeg (libavcodec, libavformat, libavutil, libswresample, libavfilter)
|
||||||
* x11 (libx11, libxcomposite, libxrandr, libxfixes, libxdamage, libxi)
|
* x11 (libx11, libxcomposite, libxrandr, libxfixes, libxdamage)
|
||||||
* libpulse
|
* libpulse
|
||||||
* libva (and libva-drm)
|
* libva (and libva-drm)
|
||||||
* libdrm
|
* libdrm
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ typedef struct {
|
|||||||
gsr_egl *egl;
|
gsr_egl *egl;
|
||||||
Display *display;
|
Display *display;
|
||||||
int x_fixes_event_base;
|
int x_fixes_event_base;
|
||||||
int xi_opcode;
|
|
||||||
|
|
||||||
unsigned int texture_id;
|
unsigned int texture_id;
|
||||||
vec2i size;
|
vec2i size;
|
||||||
@@ -17,7 +16,6 @@ typedef struct {
|
|||||||
|
|
||||||
bool cursor_image_set;
|
bool cursor_image_set;
|
||||||
bool visible;
|
bool visible;
|
||||||
bool cursor_moved;
|
|
||||||
} gsr_cursor;
|
} gsr_cursor;
|
||||||
|
|
||||||
int gsr_cursor_init(gsr_cursor *self, gsr_egl *egl, Display *display);
|
int gsr_cursor_init(gsr_cursor *self, gsr_egl *egl, Display *display);
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ dep = [
|
|||||||
dependency('xrandr'),
|
dependency('xrandr'),
|
||||||
dependency('xfixes'),
|
dependency('xfixes'),
|
||||||
dependency('xdamage'),
|
dependency('xdamage'),
|
||||||
dependency('xi'),
|
|
||||||
dependency('libpulse'),
|
dependency('libpulse'),
|
||||||
dependency('libswresample'),
|
dependency('libswresample'),
|
||||||
dependency('libavfilter'),
|
dependency('libavfilter'),
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ xcomposite = ">=0.2"
|
|||||||
xrandr = ">=1"
|
xrandr = ">=1"
|
||||||
xfixes = ">=2"
|
xfixes = ">=2"
|
||||||
xdamage = ">=1"
|
xdamage = ">=1"
|
||||||
xi = ">=1"
|
|
||||||
libpulse = ">=13"
|
libpulse = ">=13"
|
||||||
libswresample = ">=3"
|
libswresample = ">=3"
|
||||||
libavfilter = ">=5"
|
libavfilter = ">=5"
|
||||||
|
|||||||
59
src/cursor.c
59
src/cursor.c
@@ -6,8 +6,6 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include <X11/extensions/Xfixes.h>
|
#include <X11/extensions/Xfixes.h>
|
||||||
#include <X11/extensions/XI2.h>
|
|
||||||
#include <X11/extensions/XInput2.h>
|
|
||||||
|
|
||||||
// TODO: Test cursor visibility with XFixesHideCursor
|
// TODO: Test cursor visibility with XFixesHideCursor
|
||||||
|
|
||||||
@@ -72,26 +70,6 @@ static bool gsr_cursor_set_from_x11_cursor_image(gsr_cursor *self, XFixesCursorI
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool xinput_is_supported(Display *dpy, int *xi_opcode) {
|
|
||||||
*xi_opcode = 0;
|
|
||||||
int query_event = 0;
|
|
||||||
int query_error = 0;
|
|
||||||
if(!XQueryExtension(dpy, "XInputExtension", xi_opcode, &query_event, &query_error)) {
|
|
||||||
fprintf(stderr, "gsr error: gsr_cursor_init: X Input extension not available\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int major = 2;
|
|
||||||
int minor = 1;
|
|
||||||
int retval = XIQueryVersion(dpy, &major, &minor);
|
|
||||||
if (retval != Success) {
|
|
||||||
fprintf(stderr, "gsr error: gsr_cursor_init: XInput 2.1 is not supported\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int gsr_cursor_init(gsr_cursor *self, gsr_egl *egl, Display *display) {
|
int gsr_cursor_init(gsr_cursor *self, gsr_egl *egl, Display *display) {
|
||||||
int x_fixes_error_base = 0;
|
int x_fixes_error_base = 0;
|
||||||
|
|
||||||
@@ -108,31 +86,11 @@ int gsr_cursor_init(gsr_cursor *self, gsr_egl *egl, Display *display) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!xinput_is_supported(self->display, &self->xi_opcode)) {
|
|
||||||
gsr_cursor_deinit(self);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char mask[XIMaskLen(XI_LASTEVENT)];
|
|
||||||
memset(mask, 0, sizeof(mask));
|
|
||||||
XISetMask(mask, XI_RawMotion);
|
|
||||||
|
|
||||||
XIEventMask xi_masks;
|
|
||||||
xi_masks.deviceid = XIAllMasterDevices;
|
|
||||||
xi_masks.mask_len = sizeof(mask);
|
|
||||||
xi_masks.mask = mask;
|
|
||||||
if(XISelectEvents(self->display, DefaultRootWindow(self->display), &xi_masks, 1) != Success) {
|
|
||||||
fprintf(stderr, "gsr error: gsr_cursor_init: XISelectEvents failed\n");
|
|
||||||
gsr_cursor_deinit(self);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
self->egl->glGenTextures(1, &self->texture_id);
|
self->egl->glGenTextures(1, &self->texture_id);
|
||||||
|
|
||||||
XFixesSelectCursorInput(self->display, DefaultRootWindow(self->display), XFixesDisplayCursorNotifyMask);
|
XFixesSelectCursorInput(self->display, DefaultRootWindow(self->display), XFixesDisplayCursorNotifyMask);
|
||||||
gsr_cursor_set_from_x11_cursor_image(self, XFixesGetCursorImage(self->display), &self->visible);
|
gsr_cursor_set_from_x11_cursor_image(self, XFixesGetCursorImage(self->display), &self->visible);
|
||||||
self->cursor_image_set = true;
|
self->cursor_image_set = true;
|
||||||
self->cursor_moved = true;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -146,10 +104,8 @@ void gsr_cursor_deinit(gsr_cursor *self) {
|
|||||||
self->texture_id = 0;
|
self->texture_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self->display) {
|
if(self->display)
|
||||||
XISelectEvents(self->display, DefaultRootWindow(self->display), NULL, 0);
|
|
||||||
XFixesSelectCursorInput(self->display, DefaultRootWindow(self->display), 0);
|
XFixesSelectCursorInput(self->display, DefaultRootWindow(self->display), 0);
|
||||||
}
|
|
||||||
|
|
||||||
self->display = NULL;
|
self->display = NULL;
|
||||||
self->egl = NULL;
|
self->egl = NULL;
|
||||||
@@ -157,14 +113,6 @@ void gsr_cursor_deinit(gsr_cursor *self) {
|
|||||||
|
|
||||||
bool gsr_cursor_on_event(gsr_cursor *self, XEvent *xev) {
|
bool gsr_cursor_on_event(gsr_cursor *self, XEvent *xev) {
|
||||||
bool updated = false;
|
bool updated = false;
|
||||||
XGenericEventCookie *cookie = (XGenericEventCookie*)&xev->xcookie;
|
|
||||||
const Bool got_event_data = XGetEventData(self->display, cookie);
|
|
||||||
if(got_event_data && cookie->type == GenericEvent && cookie->extension == self->xi_opcode && cookie->evtype == XI_RawMotion) {
|
|
||||||
updated = true;
|
|
||||||
self->cursor_moved = true;
|
|
||||||
}
|
|
||||||
if(got_event_data)
|
|
||||||
XFreeEventData(self->display, cookie);
|
|
||||||
|
|
||||||
if(xev->type == self->x_fixes_event_base + XFixesCursorNotify) {
|
if(xev->type == self->x_fixes_event_base + XFixesCursorNotify) {
|
||||||
XFixesCursorNotifyEvent *cursor_notify_event = (XFixesCursorNotifyEvent*)xev;
|
XFixesCursorNotifyEvent *cursor_notify_event = (XFixesCursorNotifyEvent*)xev;
|
||||||
@@ -183,11 +131,6 @@ bool gsr_cursor_on_event(gsr_cursor *self, XEvent *xev) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void gsr_cursor_tick(gsr_cursor *self, Window relative_to) {
|
void gsr_cursor_tick(gsr_cursor *self, Window relative_to) {
|
||||||
if(!self->cursor_moved)
|
|
||||||
return;
|
|
||||||
|
|
||||||
self->cursor_moved = false;
|
|
||||||
|
|
||||||
Window dummy_window;
|
Window dummy_window;
|
||||||
int dummy_i;
|
int dummy_i;
|
||||||
unsigned int dummy_u;
|
unsigned int dummy_u;
|
||||||
|
|||||||
Reference in New Issue
Block a user