mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-02-03 18:22:42 +00:00
(X11) Mouse input is no longer registered when we are on the
titlebar of the window or we are no longer inside the window
This commit is contained in:
parent
7f1c9b33ef
commit
91b1889873
@ -56,6 +56,7 @@ static bool g_x11_has_focus;
|
||||
static XIM g_x11_xim;
|
||||
static XIC g_x11_xic;
|
||||
static bool g_x11_true_full;
|
||||
bool g_x11_entered = false;
|
||||
|
||||
unsigned g_x11_screen;
|
||||
|
||||
@ -647,6 +648,14 @@ bool x11_alive(void *data)
|
||||
}
|
||||
break;
|
||||
|
||||
case EnterNotify:
|
||||
g_x11_entered = true;
|
||||
break;
|
||||
|
||||
case LeaveNotify:
|
||||
g_x11_entered = false;
|
||||
break;
|
||||
|
||||
case ButtonRelease:
|
||||
break;
|
||||
|
||||
|
@ -481,6 +481,7 @@ static bool gfx_ctx_x_set_video_mode(void *data,
|
||||
swa.colormap = g_x11_cmap = XCreateColormap(g_x11_dpy,
|
||||
RootWindow(g_x11_dpy, vi->screen), vi->visual, AllocNone);
|
||||
swa.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask |
|
||||
LeaveWindowMask | EnterWindowMask |
|
||||
ButtonReleaseMask | ButtonPressMask;
|
||||
swa.override_redirect = fullscreen ? True : False;
|
||||
|
||||
|
@ -300,6 +300,8 @@ static void x_input_free(void *data)
|
||||
free(x11);
|
||||
}
|
||||
|
||||
extern bool g_x11_entered;
|
||||
|
||||
static void x_input_poll_mouse(x11_input_t *x11)
|
||||
{
|
||||
unsigned mask;
|
||||
@ -316,31 +318,34 @@ static void x_input_poll_mouse(x11_input_t *x11)
|
||||
&win_x, &win_y,
|
||||
&mask);
|
||||
|
||||
x11->mouse_x = win_x;
|
||||
x11->mouse_y = win_y;
|
||||
x11->mouse_l = mask & Button1Mask;
|
||||
x11->mouse_m = mask & Button2Mask;
|
||||
x11->mouse_r = mask & Button3Mask;
|
||||
|
||||
/* Somewhat hacky, but seem to do the job. */
|
||||
if (x11->grab_mouse && video_driver_is_focused())
|
||||
if (g_x11_entered)
|
||||
{
|
||||
int mid_w, mid_h;
|
||||
struct video_viewport vp = {0};
|
||||
x11->mouse_x = win_x;
|
||||
x11->mouse_y = win_y;
|
||||
x11->mouse_l = mask & Button1Mask;
|
||||
x11->mouse_m = mask & Button2Mask;
|
||||
x11->mouse_r = mask & Button3Mask;
|
||||
|
||||
video_driver_get_viewport_info(&vp);
|
||||
|
||||
mid_w = vp.full_width >> 1;
|
||||
mid_h = vp.full_height >> 1;
|
||||
|
||||
if (x11->mouse_x != mid_w || x11->mouse_y != mid_h)
|
||||
/* Somewhat hacky, but seem to do the job. */
|
||||
if (x11->grab_mouse && video_driver_is_focused())
|
||||
{
|
||||
XWarpPointer(x11->display, None,
|
||||
x11->win, 0, 0, 0, 0,
|
||||
mid_w, mid_h);
|
||||
int mid_w, mid_h;
|
||||
struct video_viewport vp = {0};
|
||||
|
||||
video_driver_get_viewport_info(&vp);
|
||||
|
||||
mid_w = vp.full_width >> 1;
|
||||
mid_h = vp.full_height >> 1;
|
||||
|
||||
if (x11->mouse_x != mid_w || x11->mouse_y != mid_h)
|
||||
{
|
||||
XWarpPointer(x11->display, None,
|
||||
x11->win, 0, 0, 0, 0,
|
||||
mid_w, mid_h);
|
||||
}
|
||||
x11->mouse_last_x = mid_w;
|
||||
x11->mouse_last_y = mid_h;
|
||||
}
|
||||
x11->mouse_last_x = mid_w;
|
||||
x11->mouse_last_y = mid_h;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user