mirror of
https://github.com/libretro/RetroArch
synced 2025-01-31 06:32:48 +00:00
xshm: fix compatibility with x input
This commit is contained in:
parent
cfe68a4c2d
commit
c4b4961ed1
@ -32,15 +32,14 @@
|
|||||||
#include "../../menu/menu_driver.h"
|
#include "../../menu/menu_driver.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "../../configuration.h"
|
||||||
|
|
||||||
#include "../font_driver.h"
|
#include "../font_driver.h"
|
||||||
|
|
||||||
#include "../common/x11_common.h"
|
#include "../common/x11_common.h"
|
||||||
|
|
||||||
typedef struct xshm
|
typedef struct xshm
|
||||||
{
|
{
|
||||||
Display* display;
|
|
||||||
Window wndw;
|
|
||||||
|
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
|
||||||
@ -57,20 +56,20 @@ static void *xshm_gfx_init(const video_info_t *video,
|
|||||||
|
|
||||||
XInitThreads();
|
XInitThreads();
|
||||||
|
|
||||||
xshm->display = XOpenDisplay(NULL);
|
g_x11_dpy = XOpenDisplay(NULL);
|
||||||
|
|
||||||
#ifdef RARCH_INTERNAL
|
#ifdef RARCH_INTERNAL
|
||||||
parent = DefaultRootWindow(xshm->display);
|
parent = DefaultRootWindow(g_x11_dpy);
|
||||||
#else
|
#else
|
||||||
parent = video->parent;
|
parent = video->parent;
|
||||||
#endif
|
#endif
|
||||||
XSetWindowAttributes attributes;
|
XSetWindowAttributes attributes;
|
||||||
attributes.border_pixel=0;
|
attributes.border_pixel=0;
|
||||||
xshm->wndw = XCreateWindow(xshm->display, parent,
|
g_x11_win = XCreateWindow(g_x11_dpy, parent,
|
||||||
0, 0, video->width, video->height,
|
0, 0, video->width, video->height,
|
||||||
0, 24, CopyFromParent, NULL, CWBorderPixel, &attributes);
|
0, 24, CopyFromParent, NULL, CWBorderPixel, &attributes);
|
||||||
XSetWindowBackground(xshm->display, xshm->wndw, 0);
|
XSetWindowBackground(g_x11_dpy, g_x11_win, 0);
|
||||||
XMapWindow(xshm->display, xshm->wndw);
|
XMapWindow(g_x11_dpy, g_x11_win);
|
||||||
|
|
||||||
xshm->shmInfo.shmid = shmget(IPC_PRIVATE, sizeof(uint32_t) * video->width * video->height,
|
xshm->shmInfo.shmid = shmget(IPC_PRIVATE, sizeof(uint32_t) * video->width * video->height,
|
||||||
IPC_CREAT|0600);
|
IPC_CREAT|0600);
|
||||||
@ -78,20 +77,37 @@ static void *xshm_gfx_init(const video_info_t *video,
|
|||||||
|
|
||||||
xshm->shmInfo.shmaddr = (char*)shmat(xshm->shmInfo.shmid, 0, 0);
|
xshm->shmInfo.shmaddr = (char*)shmat(xshm->shmInfo.shmid, 0, 0);
|
||||||
xshm->shmInfo.readOnly = False;
|
xshm->shmInfo.readOnly = False;
|
||||||
XShmAttach(xshm->display, &xshm->shmInfo);
|
XShmAttach(g_x11_dpy, &xshm->shmInfo);
|
||||||
XSync(xshm->display, False);//no idea why this is required, but I get weird errors without it
|
XSync(g_x11_dpy, False);//no idea why this is required, but I get weird errors without it
|
||||||
xshm->image = XShmCreateImage(xshm->display, NULL, 24, ZPixmap,
|
xshm->image = XShmCreateImage(g_x11_dpy, NULL, 24, ZPixmap,
|
||||||
xshm->shmInfo.shmaddr, &xshm->shmInfo, video->width, video->height);
|
xshm->shmInfo.shmaddr, &xshm->shmInfo, video->width, video->height);
|
||||||
|
|
||||||
xshm->gc = XCreateGC(xshm->display, xshm->wndw, 0, NULL);
|
xshm->gc = XCreateGC(g_x11_dpy, g_x11_win, 0, NULL);
|
||||||
|
|
||||||
xshm->width = video->width;
|
xshm->width = video->width;
|
||||||
xshm->height = video->height;
|
xshm->height = video->height;
|
||||||
|
|
||||||
if (input) *input = NULL;
|
if (!x11_input_ctx_new(true))
|
||||||
if (input_data) *input_data = NULL;
|
goto error;
|
||||||
|
|
||||||
|
if (input && input_data)
|
||||||
|
{
|
||||||
|
void *xinput = NULL;
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
xinput = input_x.init(settings->arrays.input_joypad_driver);
|
||||||
|
if (xinput)
|
||||||
|
{
|
||||||
|
*input = &input_x;
|
||||||
|
*input_data = xinput;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*input = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return xshm;
|
return xshm;
|
||||||
|
error:
|
||||||
|
free (xshm);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool xshm_gfx_frame(void *data, const void *frame, unsigned width,
|
static bool xshm_gfx_frame(void *data, const void *frame, unsigned width,
|
||||||
@ -110,9 +126,9 @@ static bool xshm_gfx_frame(void *data, const void *frame, unsigned width,
|
|||||||
menu_driver_frame(menu_is_alive, video_info);
|
menu_driver_frame(menu_is_alive, video_info);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
XShmPutImage(xshm->display, xshm->wndw, xshm->gc, xshm->image,
|
XShmPutImage(g_x11_dpy, g_x11_win, xshm->gc, xshm->image,
|
||||||
0, 0, 0, 0, xshm->width, xshm->height, False);
|
0, 0, 0, 0, xshm->width, xshm->height, False);
|
||||||
XFlush(xshm->display);
|
XFlush(g_x11_dpy);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user