Start splitting up xinerama functions

This commit is contained in:
twinaphex 2017-03-23 19:46:06 +01:00
parent 4c0ce28e6e
commit 09e7186a4e
4 changed files with 34 additions and 30 deletions

View File

@ -396,7 +396,7 @@ void x11_exit_fullscreen(Display *dpy, XF86VidModeModeInfo *desktop_mode)
}
#ifdef HAVE_XINERAMA
static XineramaScreenInfo *x11_query_screens(Display *dpy, int *num_screens)
static XineramaScreenInfo *xinerama_query_screens(Display *dpy, int *num_screens)
{
int major, minor;
@ -412,12 +412,12 @@ static XineramaScreenInfo *x11_query_screens(Display *dpy, int *num_screens)
return XineramaQueryScreens(dpy, num_screens);
}
bool x11_get_xinerama_coord(Display *dpy, int screen,
bool xinerama_get_coord(Display *dpy, int screen,
int *x, int *y, unsigned *w, unsigned *h)
{
int i, num_screens = 0;
bool ret = false;
XineramaScreenInfo *info = x11_query_screens(dpy, &num_screens);
XineramaScreenInfo *info = xinerama_query_screens(dpy, &num_screens);
RARCH_LOG("[X11]: Xinerama screens: %d.\n", num_screens);
@ -438,13 +438,13 @@ bool x11_get_xinerama_coord(Display *dpy, int screen,
return ret;
}
unsigned x11_get_xinerama_monitor(Display *dpy, int x, int y,
unsigned xinerama_get_monitor(Display *dpy, int x, int y,
int w, int h)
{
int i, num_screens = 0;
unsigned monitor = 0;
int largest_area = 0;
XineramaScreenInfo *info = x11_query_screens(dpy, &num_screens);
XineramaScreenInfo *info = xinerama_query_screens(dpy, &num_screens);
RARCH_LOG("[X11]: Xinerama screens: %d.\n", num_screens);
@ -475,6 +475,23 @@ unsigned x11_get_xinerama_monitor(Display *dpy, int x, int y,
XFree(info);
return monitor;
}
void xinerama_save_last_used_monitor(Window win)
{
XWindowAttributes target;
Window child;
int x = 0, y = 0;
XGetWindowAttributes(g_x11_dpy, g_x11_win, &target);
XTranslateCoordinates(g_x11_dpy, g_x11_win,
DefaultRootWindow(g_x11_dpy),
target.x, target.y, &x, &y, &child);
g_x11_screen = xinerama_get_monitor(g_x11_dpy, x, y,
target.width, target.height);
RARCH_LOG("[X11]: Saved monitor #%u.\n", g_x11_screen);
}
#endif
bool x11_create_input_context(Display *dpy, Window win, XIM *xim, XIC *xic)
@ -785,21 +802,3 @@ void x11_event_queue_check(XEvent *event)
XIfEvent(g_x11_dpy, event, x11_wait_notify, NULL);
}
void x11_save_last_used_monitor(Window win)
{
#ifdef HAVE_XINERAMA
XWindowAttributes target;
Window child;
int x = 0, y = 0;
XGetWindowAttributes(g_x11_dpy, g_x11_win, &target);
XTranslateCoordinates(g_x11_dpy, g_x11_win,
DefaultRootWindow(g_x11_dpy),
target.x, target.y, &x, &y, &child);
g_x11_screen = x11_get_xinerama_monitor(g_x11_dpy, x, y,
target.width, target.height);
RARCH_LOG("[X11]: Saved monitor #%u.\n", g_x11_screen);
#endif
}

View File

@ -41,7 +41,6 @@ extern Display *g_x11_dpy;
extern Colormap g_x11_cmap;
extern unsigned g_x11_screen;
void x11_save_last_used_monitor(Window win);
void x11_show_mouse(Display *dpy, Window win, bool state);
void x11_windowed_fullscreen(Display *dpy, Window win);
void x11_suspend_screensaver(Window win, bool enable);
@ -57,10 +56,12 @@ void x11_move_window(Display *dpy, Window win,
void x11_set_window_attr(Display *dpy, Window win);
#ifdef HAVE_XINERAMA
bool x11_get_xinerama_coord(Display *dpy, int screen,
void xinerama_save_last_used_monitor(Window win);
bool xinerama_get_coord(Display *dpy, int screen,
int *x, int *y, unsigned *w, unsigned *h);
unsigned x11_get_xinerama_monitor(Display *dpy,
unsigned xinerama_get_monitor(Display *dpy,
int x, int y, int w, int h);
#endif

View File

@ -198,8 +198,10 @@ static void gfx_ctx_x_destroy_resources(gfx_ctx_x_data_t *x)
if (g_x11_win && g_x11_dpy)
{
#ifdef HAVE_XINERAMA
/* Save last used monitor for later. */
x11_save_last_used_monitor(DefaultRootWindow(g_x11_dpy));
xinerama_save_last_used_monitor(DefaultRootWindow(g_x11_dpy));
#endif
x11_window_destroy(false);
}
@ -624,7 +626,7 @@ static bool gfx_ctx_x_set_video_mode(void *data,
unsigned new_width = width;
unsigned new_height = height;
if (x11_get_xinerama_coord(g_x11_dpy, g_x11_screen,
if (xinerama_get_coord(g_x11_dpy, g_x11_screen,
&x_off, &y_off, &new_width, &new_height))
RARCH_LOG("[GLX]: Using Xinerama on screen #%u.\n", g_x11_screen);
else

View File

@ -62,9 +62,11 @@ static void gfx_ctx_xegl_destroy(void *data)
if (g_x11_win)
{
#ifdef HAVE_XINERAMA
/* Save last used monitor for later. */
x11_save_last_used_monitor(RootWindow(
xinerama_save_last_used_monitor(RootWindow(
g_x11_dpy, DefaultScreen(g_x11_dpy)));
#endif
x11_window_destroy(false);
}
@ -309,7 +311,7 @@ static bool gfx_ctx_xegl_set_video_mode(void *data,
unsigned new_width = width;
unsigned new_height = height;
if (x11_get_xinerama_coord(g_x11_dpy, g_x11_screen,
if (xinerama_get_coord(g_x11_dpy, g_x11_screen,
&x_off, &y_off, &new_width, &new_height))
RARCH_LOG("[X/EGL]: Using Xinerama on screen #%u.\n", g_x11_screen);
else