(CodeQL) Only use 'cpp' language

(X11) Use HAVE_XF86VM for XFree86-VidMode X extension library
This commit is contained in:
LibretroAdmin 2022-09-05 18:26:08 +02:00
parent 5e985f0553
commit 77f3e20e3c
8 changed files with 126 additions and 44 deletions

View File

@ -32,7 +32,7 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'cpp', 'java', 'javascript', 'python' ]
language: [ 'cpp' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

View File

@ -36,7 +36,9 @@
#include "x11_common.h"
#ifdef HAVE_XF86VM
#include <X11/extensions/xf86vmode.h>
#endif
#include <encodings/utf.h>
#include <compat/strl.h>
@ -68,7 +70,9 @@ Window g_x11_win = None;
Colormap g_x11_cmap;
/* TODO/FIXME - static globals */
#ifdef HAVE_XF86VM
static XF86VidModeModeInfo desktop_mode;
#endif
static bool xdg_screensaver_available = true;
static bool g_x11_has_focus = false;
static bool g_x11_true_full = false;
@ -249,6 +253,7 @@ void x11_suspend_screensaver(Window wnd, bool enable)
xdg_screensaver_inhibit(wnd);
}
#ifdef HAVE_XF86VM
float x11_get_refresh_rate(void *data)
{
XWindowAttributes attr;
@ -256,7 +261,6 @@ float x11_get_refresh_rate(void *data)
Screen *screen;
int screenid;
int dotclock;
float refresh;
if (!g_x11_dpy || g_x11_win == None)
return 0.0f;
@ -273,9 +277,7 @@ float x11_get_refresh_rate(void *data)
if (modeline.flags & V_DBLSCAN)
dotclock /= 2;
refresh = (float)dotclock * 1000.0f / modeline.htotal / modeline.vtotal;
return refresh;
return (float)dotclock * 1000.0f / modeline.htotal / modeline.vtotal;
}
static bool get_video_mode(
@ -354,6 +356,7 @@ void x11_exit_fullscreen(Display *dpy)
XF86VidModeSwitchToMode(dpy, DefaultScreen(dpy), &desktop_mode);
XF86VidModeSetViewPort(dpy, DefaultScreen(dpy), 0, 0);
}
#endif
static void x11_init_keyboard_lut(void)
{

View File

@ -31,9 +31,7 @@ extern unsigned g_x11_screen;
void x11_show_mouse(Display *dpy, Window win, bool state);
void x11_set_net_wm_fullscreen(Display *dpy, Window win);
void x11_suspend_screensaver(Window win, bool enable);
bool x11_enter_fullscreen(Display *dpy, unsigned width, unsigned height);
void x11_exit_fullscreen(Display *dpy);
void x11_move_window(Display *dpy, Window win,
int x, int y, unsigned width, unsigned height);
@ -43,8 +41,14 @@ void x11_set_window_attr(Display *dpy, Window win);
bool x11_get_metrics(void *data,
enum display_metric_types type, float *value);
#ifdef HAVE_XF86VM
float x11_get_refresh_rate(void *data);
bool x11_enter_fullscreen(Display *dpy, unsigned width, unsigned height);
void x11_exit_fullscreen(Display *dpy);
#endif
void x11_check_window(void *data, bool *quit,
bool *resize, unsigned *width, unsigned *height);

View File

@ -185,7 +185,11 @@ static video_poke_interface_t xshm_video_poke_interface = {
NULL,
NULL,
NULL,
#ifdef HAVE_XF86VM
x11_get_refresh_rate,
#else
NULL,
#endif
xshm_poke_set_filtering,
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */

View File

@ -1099,7 +1099,11 @@ static video_poke_interface_t xv_video_poke_interface = {
NULL,
NULL,
NULL,
#ifdef HAVE_XF86VM
x11_get_refresh_rate,
#else
NULL,
#endif
NULL,
NULL,
NULL,

View File

@ -64,7 +64,9 @@ typedef struct gfx_ctx_x_data
bool core_es;
bool core_es_core;
bool debug;
#ifdef HAVE_XF86VM
bool should_reset_mode;
#endif
bool is_fullscreen;
bool is_double;
bool core_hw_context_enable;
@ -213,6 +215,7 @@ static void gfx_ctx_x_destroy_resources(gfx_ctx_x_data_t *x)
x11_colormap_destroy();
#ifdef HAVE_XF86VM
if (g_x11_dpy)
{
if (x->should_reset_mode)
@ -221,6 +224,7 @@ static void gfx_ctx_x_destroy_resources(gfx_ctx_x_data_t *x)
x->should_reset_mode = false;
}
}
#endif
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE)
g_pglSwapInterval = NULL;
@ -444,13 +448,14 @@ static bool gfx_ctx_x_set_video_mode(void *data,
bool fullscreen)
{
XEvent event;
#ifdef HAVE_XF86VM
bool true_full = false;
#endif
int val = 0;
int x_off = 0;
int y_off = 0;
XVisualInfo *vi = NULL;
XSetWindowAttributes swa = {0};
char *wm_name = NULL;
int (*old_handler)(Display*, XErrorEvent*) = NULL;
gfx_ctx_x_data_t *x = (gfx_ctx_x_data_t*)data;
Atom net_wm_icon = XInternAtom(g_x11_dpy, "_NET_WM_ICON", False);
@ -504,6 +509,7 @@ static bool gfx_ctx_x_set_video_mode(void *data,
x->is_fullscreen = fullscreen;
#ifdef HAVE_XF86VM
if (fullscreen && !windowed_full)
{
if (x11_enter_fullscreen(g_x11_dpy, width, height))
@ -515,20 +521,24 @@ static bool gfx_ctx_x_set_video_mode(void *data,
RARCH_ERR("[GLX]: Entering true fullscreen failed. Will attempt windowed mode.\n");
}
wm_name = x11_get_wm_name(g_x11_dpy);
if (wm_name)
if (true_full)
{
RARCH_LOG("[GLX]: Window manager is %s.\n", wm_name);
char *wm_name = x11_get_wm_name(g_x11_dpy);
if (wm_name)
{
RARCH_LOG("[GLX]: Window manager is %s.\n", wm_name);
if (strcasestr(wm_name, "xfwm"))
{
RARCH_LOG("[GLX]: Using override-redirect workaround.\n");
swa.override_redirect = True;
}
free(wm_name);
}
if (true_full && strcasestr(wm_name, "xfwm"))
{
RARCH_LOG("[GLX]: Using override-redirect workaround.\n");
if (!x11_has_net_wm_fullscreen(g_x11_dpy))
swa.override_redirect = True;
}
free(wm_name);
}
if (!x11_has_net_wm_fullscreen(g_x11_dpy) && true_full)
swa.override_redirect = True;
#endif
if (video_monitor_index)
g_x11_screen = video_monitor_index - 1;
@ -614,13 +624,16 @@ static bool gfx_ctx_x_set_video_mode(void *data,
if (fullscreen)
x11_show_mouse(g_x11_dpy, g_x11_win, false);
#ifdef HAVE_XF86VM
if (true_full)
{
RARCH_LOG("[GLX]: Using true fullscreen.\n");
XMapRaised(g_x11_dpy, g_x11_win);
x11_set_net_wm_fullscreen(g_x11_dpy, g_x11_win);
}
else if (fullscreen)
else
#endif
if (fullscreen)
{
/* We attempted true fullscreen, but failed.
* Attempt using windowed fullscreen. */
@ -904,8 +917,13 @@ static bool gfx_ctx_x_set_video_mode(void *data,
XFree(vi);
vi = NULL;
#ifdef HAVE_XF86VM
if (!x11_input_ctx_new(true_full))
goto error;
#else
if (!x11_input_ctx_new(false))
goto error;
#endif
return true;
@ -1153,7 +1171,11 @@ const gfx_ctx_driver_t gfx_ctx_x = {
gfx_ctx_x_swap_interval,
gfx_ctx_x_set_video_mode,
x11_get_video_size,
#ifdef HAVE_XF86VM
x11_get_refresh_rate,
#else
NULL,
#endif
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */

View File

@ -42,7 +42,9 @@
typedef struct gfx_ctx_x_vk_data
{
#ifdef HAVE_XF86VM
bool should_reset_mode;
#endif
bool is_fullscreen;
int interval;
@ -103,6 +105,7 @@ static void gfx_ctx_x_vk_destroy_resources(gfx_ctx_x_vk_data_t *x)
x11_colormap_destroy();
#ifdef HAVE_XF86VM
if (g_x11_dpy)
{
if (x->should_reset_mode)
@ -111,6 +114,7 @@ static void gfx_ctx_x_vk_destroy_resources(gfx_ctx_x_vk_data_t *x)
x->should_reset_mode = false;
}
}
#endif
}
static void gfx_ctx_x_vk_destroy(void *data)
@ -239,13 +243,14 @@ static bool gfx_ctx_x_vk_set_video_mode(void *data,
bool fullscreen)
{
XEvent event;
#ifdef HAVE_XF86VM
bool true_full = false;
#endif
int val = 0;
int x_off = 0;
int y_off = 0;
XVisualInfo *vi = NULL;
XSetWindowAttributes swa = {0};
char *wm_name = NULL;
int (*old_handler)(Display*, XErrorEvent*) = NULL;
gfx_ctx_x_vk_data_t *x = (gfx_ctx_x_vk_data_t*)data;
Atom net_wm_icon = XInternAtom(g_x11_dpy, "_NET_WM_ICON", False);
@ -284,6 +289,7 @@ static bool gfx_ctx_x_vk_set_video_mode(void *data,
x->is_fullscreen = fullscreen;
#ifdef HAVE_XF86VM
if (fullscreen && !windowed_full)
{
if (x11_enter_fullscreen(g_x11_dpy, width, height))
@ -295,20 +301,24 @@ static bool gfx_ctx_x_vk_set_video_mode(void *data,
RARCH_ERR("[X/Vulkan]: Entering true fullscreen failed. Will attempt windowed mode.\n");
}
wm_name = x11_get_wm_name(g_x11_dpy);
if (wm_name)
if (true_full)
{
RARCH_LOG("[X/Vulkan]: Window manager is %s.\n", wm_name);
if (true_full && strcasestr(wm_name, "xfwm"))
char *wm_name = x11_get_wm_name(g_x11_dpy);
if (wm_name)
{
RARCH_LOG("[X/Vulkan]: Using override-redirect workaround.\n");
swa.override_redirect = True;
RARCH_LOG("[X/Vulkan]: Window manager is %s.\n", wm_name);
if (strcasestr(wm_name, "xfwm"))
{
RARCH_LOG("[X/Vulkan]: Using override-redirect workaround.\n");
swa.override_redirect = True;
}
free(wm_name);
}
free(wm_name);
if (!x11_has_net_wm_fullscreen(g_x11_dpy))
swa.override_redirect = True;
}
if (!x11_has_net_wm_fullscreen(g_x11_dpy) && true_full)
swa.override_redirect = True;
#endif
if (video_monitor_index)
g_x11_screen = video_monitor_index - 1;
@ -380,13 +390,16 @@ static bool gfx_ctx_x_vk_set_video_mode(void *data,
if (fullscreen)
x11_show_mouse(g_x11_dpy, g_x11_win, false);
#ifdef HAVE_XF86VM
if (true_full)
{
RARCH_LOG("[X/Vulkan]: Using true fullscreen.\n");
XMapRaised(g_x11_dpy, g_x11_win);
x11_set_net_wm_fullscreen(g_x11_dpy, g_x11_win);
}
else if (fullscreen)
else
#endif
if (fullscreen)
{
/* We attempted true fullscreen, but failed.
* Attempt using windowed fullscreen. */
@ -445,8 +458,13 @@ static bool gfx_ctx_x_vk_set_video_mode(void *data,
XFree(vi);
vi = NULL;
#ifdef HAVE_XF86VM
if (!x11_input_ctx_new(true_full))
goto error;
#else
if (!x11_input_ctx_new(false))
goto error;
#endif
return true;
@ -553,7 +571,11 @@ const gfx_ctx_driver_t gfx_ctx_vk_x = {
gfx_ctx_x_vk_swap_interval,
gfx_ctx_x_vk_set_video_mode,
x11_get_video_size,
#ifdef HAVE_XF86VM
x11_get_refresh_rate,
#else
NULL,
#endif
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */

View File

@ -50,7 +50,9 @@ typedef struct
#ifdef HAVE_EGL
egl_ctx_data_t egl;
#endif
#ifdef HAVE_XF86VM
bool should_reset_mode;
#endif
} xegl_ctx_data_t;
/* TODO/FIXME - static globals */
@ -79,11 +81,13 @@ static void gfx_ctx_xegl_destroy(void *data)
x11_colormap_destroy();
#ifdef HAVE_XF86VM
if (xegl->should_reset_mode)
{
x11_exit_fullscreen(g_x11_dpy);
xegl->should_reset_mode = false;
}
#endif
free(data);
@ -264,13 +268,14 @@ static bool gfx_ctx_xegl_set_video_mode(void *data,
EGLint egl_attribs[16];
EGLint vid, num_visuals;
EGLint *attr = NULL;
#ifdef HAVE_XF86VM
bool true_full = false;
#endif
int x_off = 0;
int y_off = 0;
XVisualInfo temp = {0};
XSetWindowAttributes swa = {0};
XVisualInfo *vi = NULL;
char *wm_name = NULL;
xegl_ctx_data_t *xegl = (xegl_ctx_data_t*)data;
settings_t *settings = config_get_ptr();
bool video_disable_composition = settings->bools.video_disable_composition;
@ -303,6 +308,7 @@ static bool gfx_ctx_xegl_set_video_mode(void *data,
EnterWindowMask | LeaveWindowMask;
swa.override_redirect = False;
#ifdef HAVE_XF86VM
if (fullscreen && !windowed_fullscreen)
{
if (x11_enter_fullscreen(g_x11_dpy, width, height))
@ -314,20 +320,25 @@ static bool gfx_ctx_xegl_set_video_mode(void *data,
RARCH_ERR("[X/EGL]: Entering true fullscreen failed. Will attempt windowed mode.\n");
}
wm_name = x11_get_wm_name(g_x11_dpy);
if (wm_name)
if (true_full)
{
RARCH_LOG("[X/EGL]: Window manager is %s.\n", wm_name);
if (true_full && strcasestr(wm_name, "xfwm"))
char *wm_name = x11_get_wm_name(g_x11_dpy);
if (wm_name)
{
RARCH_LOG("[X/EGL]: Using override-redirect workaround.\n");
swa.override_redirect = True;
RARCH_LOG("[X/EGL]: Window manager is %s.\n", wm_name);
if (strcasestr(wm_name, "xfwm"))
{
RARCH_LOG("[X/EGL]: Using override-redirect workaround.\n");
swa.override_redirect = True;
}
free(wm_name);
}
free(wm_name);
if (!x11_has_net_wm_fullscreen(g_x11_dpy))
swa.override_redirect = True;
}
if (!x11_has_net_wm_fullscreen(g_x11_dpy) && true_full)
swa.override_redirect = True;
#endif
if (video_monitor_index)
g_x11_screen = video_monitor_index - 1;
@ -387,13 +398,16 @@ static bool gfx_ctx_xegl_set_video_mode(void *data,
if (fullscreen)
x11_show_mouse(g_x11_dpy, g_x11_win, false);
#ifdef HAVE_XF86VM
if (true_full)
{
RARCH_LOG("[X/EGL]: Using true fullscreen.\n");
XMapRaised(g_x11_dpy, g_x11_win);
x11_set_net_wm_fullscreen(g_x11_dpy, g_x11_win);
}
else if (fullscreen)
else
#endif
if (fullscreen)
{
/* We attempted true fullscreen, but failed.
* Attempt using windowed fullscreen. */
@ -439,8 +453,13 @@ static bool gfx_ctx_xegl_set_video_mode(void *data,
XFree(vi);
g_egl_inited = true;
#ifdef HAVE_XF86VM
if (!x11_input_ctx_new(true_full))
goto error;
#else
if (!x11_input_ctx_new(false))
goto error;
#endif
return true;
@ -588,7 +607,11 @@ const gfx_ctx_driver_t gfx_ctx_x_egl =
gfx_ctx_xegl_set_swap_interval,
gfx_ctx_xegl_set_video_mode,
x11_get_video_size,
#ifdef HAVE_XF86VM
x11_get_refresh_rate,
#else
NULL,
#endif
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */