|
@@ -261,61 +261,61 @@ static float X11Toolkit_GetUIScale(XSettingsClient *client, Display *display)
|
|
|
static void X11Toolkit_InitWindowPixmap(SDL_ToolkitWindowX11 *data) {
|
|
static void X11Toolkit_InitWindowPixmap(SDL_ToolkitWindowX11 *data) {
|
|
|
if (data->pixmap) {
|
|
if (data->pixmap) {
|
|
|
#ifndef NO_SHARED_MEMORY
|
|
#ifndef NO_SHARED_MEMORY
|
|
|
- if (!data->shm_pixmap) {
|
|
|
|
|
- data->drawable = X11_XCreatePixmap(data->display, data->window, data->pixmap_width, data->pixmap_height, data->depth);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (!data->shm_pixmap) {
|
|
|
|
|
+ data->drawable = X11_XCreatePixmap(data->display, data->window, data->pixmap_width, data->pixmap_height, data->depth);
|
|
|
|
|
+ }
|
|
|
#else
|
|
#else
|
|
|
- data->drawable = X11_XCreatePixmap(data->display, data->window, data->pixmap_width, data->pixmap_height, data->depth);
|
|
|
|
|
|
|
+ data->drawable = X11_XCreatePixmap(data->display, data->window, data->pixmap_width, data->pixmap_height, data->depth);
|
|
|
#endif
|
|
#endif
|
|
|
#ifndef NO_SHARED_MEMORY
|
|
#ifndef NO_SHARED_MEMORY
|
|
|
- if (data->shm) {
|
|
|
|
|
- data->image = X11_XShmCreateImage(data->display, data->visual, data->depth, ZPixmap, NULL, &data->shm_info, data->pixmap_width, data->pixmap_height);
|
|
|
|
|
- if (data->image) {
|
|
|
|
|
- data->shm_bytes_per_line = data->image->bytes_per_line;
|
|
|
|
|
-
|
|
|
|
|
- data->shm_info.shmid = shmget(IPC_PRIVATE, data->image->bytes_per_line * data->image->height, IPC_CREAT | 0777);
|
|
|
|
|
- if (data->shm_info.shmid < 0) {
|
|
|
|
|
- XDestroyImage(data->image);
|
|
|
|
|
- data->image = NULL;
|
|
|
|
|
- data->shm = false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- data->shm_info.readOnly = False;
|
|
|
|
|
- data->shm_info.shmaddr = data->image->data = (char *)shmat(data->shm_info.shmid, 0, 0);
|
|
|
|
|
- if (((signed char *)data->shm_info.shmaddr) == (signed char *)-1) {
|
|
|
|
|
- XDestroyImage(data->image);
|
|
|
|
|
- data->shm = false;
|
|
|
|
|
- data->image = NULL;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- g_shm_error = False;
|
|
|
|
|
- g_old_error_handler = X11_XSetErrorHandler(X11Toolkit_SharedMemoryErrorHandler);
|
|
|
|
|
- X11_XShmAttach(data->display, &data->shm_info);
|
|
|
|
|
- X11_XSync(data->display, False);
|
|
|
|
|
- X11_XSetErrorHandler(g_old_error_handler);
|
|
|
|
|
- if (g_shm_error) {
|
|
|
|
|
- XDestroyImage(data->image);
|
|
|
|
|
- shmdt(data->shm_info.shmaddr);
|
|
|
|
|
- shmctl(data->shm_info.shmid, IPC_RMID, 0);
|
|
|
|
|
- data->image = NULL;
|
|
|
|
|
- data->shm = false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (data->shm_pixmap) {
|
|
|
|
|
- data->drawable = X11_XShmCreatePixmap(data->display, data->window, data->shm_info.shmaddr, &data->shm_info, data->pixmap_width, data->pixmap_height, data->depth);
|
|
|
|
|
- if (data->drawable == None) {
|
|
|
|
|
- data->shm_pixmap = False;
|
|
|
|
|
- } else {
|
|
|
|
|
- XDestroyImage(data->image);
|
|
|
|
|
- data->image = NULL;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- shmctl(data->shm_info.shmid, IPC_RMID, 0);
|
|
|
|
|
- } else {
|
|
|
|
|
- data->shm = false;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (data->shm) {
|
|
|
|
|
+ data->image = X11_XShmCreateImage(data->display, data->visual, data->depth, ZPixmap, NULL, &data->shm_info, data->pixmap_width, data->pixmap_height);
|
|
|
|
|
+ if (data->image) {
|
|
|
|
|
+ data->shm_bytes_per_line = data->image->bytes_per_line;
|
|
|
|
|
+
|
|
|
|
|
+ data->shm_info.shmid = shmget(IPC_PRIVATE, data->image->bytes_per_line * data->image->height, IPC_CREAT | 0777);
|
|
|
|
|
+ if (data->shm_info.shmid < 0) {
|
|
|
|
|
+ XDestroyImage(data->image);
|
|
|
|
|
+ data->image = NULL;
|
|
|
|
|
+ data->shm = false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ data->shm_info.readOnly = False;
|
|
|
|
|
+ data->shm_info.shmaddr = data->image->data = (char *)shmat(data->shm_info.shmid, 0, 0);
|
|
|
|
|
+ if (((signed char *)data->shm_info.shmaddr) == (signed char *)-1) {
|
|
|
|
|
+ XDestroyImage(data->image);
|
|
|
|
|
+ data->shm = false;
|
|
|
|
|
+ data->image = NULL;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ g_shm_error = False;
|
|
|
|
|
+ g_old_error_handler = X11_XSetErrorHandler(X11Toolkit_SharedMemoryErrorHandler);
|
|
|
|
|
+ X11_XShmAttach(data->display, &data->shm_info);
|
|
|
|
|
+ X11_XSync(data->display, False);
|
|
|
|
|
+ X11_XSetErrorHandler(g_old_error_handler);
|
|
|
|
|
+ if (g_shm_error) {
|
|
|
|
|
+ XDestroyImage(data->image);
|
|
|
|
|
+ shmdt(data->shm_info.shmaddr);
|
|
|
|
|
+ shmctl(data->shm_info.shmid, IPC_RMID, 0);
|
|
|
|
|
+ data->image = NULL;
|
|
|
|
|
+ data->shm = false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (data->shm_pixmap) {
|
|
|
|
|
+ data->drawable = X11_XShmCreatePixmap(data->display, data->window, data->shm_info.shmaddr, &data->shm_info, data->pixmap_width, data->pixmap_height, data->depth);
|
|
|
|
|
+ if (data->drawable == None) {
|
|
|
|
|
+ data->shm_pixmap = False;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ XDestroyImage(data->image);
|
|
|
|
|
+ data->image = NULL;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ shmctl(data->shm_info.shmid, IPC_RMID, 0);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ data->shm = false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -332,26 +332,26 @@ static void X11Toolkit_InitWindowFonts(SDL_ToolkitWindowX11 *window)
|
|
|
window->font_struct = NULL;
|
|
window->font_struct = NULL;
|
|
|
for (i_font = 0; g_ToolkitFont[i_font]; ++i_font) {
|
|
for (i_font = 0; g_ToolkitFont[i_font]; ++i_font) {
|
|
|
char *font;
|
|
char *font;
|
|
|
-
|
|
|
|
|
- if (SDL_strstr(g_ToolkitFont[i_font], "%d")) {
|
|
|
|
|
- try_load_font:
|
|
|
|
|
- SDL_asprintf(&font, g_ToolkitFont[i_font], G_TOOLKITFONT_SIZE * window->iscale);
|
|
|
|
|
- window->font_set = X11_XCreateFontSet(window->display, font, &missing, &num_missing, NULL);
|
|
|
|
|
- SDL_free(font);
|
|
|
|
|
-
|
|
|
|
|
- if (!window->font_set) {
|
|
|
|
|
- if (window->scale && window->iscale > 0) {
|
|
|
|
|
- window->iscale = (int)SDL_ceilf(window->scale);
|
|
|
|
|
- window->scale = 0;
|
|
|
|
|
- } else {
|
|
|
|
|
- window->iscale--;
|
|
|
|
|
- }
|
|
|
|
|
- goto try_load_font;
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- window->font_set = X11_XCreateFontSet(window->display, g_ToolkitFont[i_font], &missing, &num_missing, NULL);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (SDL_strstr(g_ToolkitFont[i_font], "%d")) {
|
|
|
|
|
+ try_load_font:
|
|
|
|
|
+ SDL_asprintf(&font, g_ToolkitFont[i_font], G_TOOLKITFONT_SIZE * window->iscale);
|
|
|
|
|
+ window->font_set = X11_XCreateFontSet(window->display, font, &missing, &num_missing, NULL);
|
|
|
|
|
+ SDL_free(font);
|
|
|
|
|
+
|
|
|
|
|
+ if (!window->font_set) {
|
|
|
|
|
+ if (window->scale && window->iscale > 0) {
|
|
|
|
|
+ window->iscale = (int)SDL_ceilf(window->scale);
|
|
|
|
|
+ window->scale = 0;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ window->iscale--;
|
|
|
|
|
+ }
|
|
|
|
|
+ goto try_load_font;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ window->font_set = X11_XCreateFontSet(window->display, g_ToolkitFont[i_font], &missing, &num_missing, NULL);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (missing) {
|
|
if (missing) {
|
|
|
X11_XFreeStringList(missing);
|
|
X11_XFreeStringList(missing);
|
|
|
}
|
|
}
|
|
@@ -371,18 +371,18 @@ static void X11Toolkit_InitWindowFonts(SDL_ToolkitWindowX11 *window)
|
|
|
|
|
|
|
|
load_font_traditional:
|
|
load_font_traditional:
|
|
|
window->utf8 = false;
|
|
window->utf8 = false;
|
|
|
- SDL_asprintf(&font, g_ToolkitFontLatin1, G_TOOLKITFONT_SIZE * window->iscale);
|
|
|
|
|
|
|
+ SDL_asprintf(&font, g_ToolkitFontLatin1, G_TOOLKITFONT_SIZE * window->iscale);
|
|
|
window->font_struct = X11_XLoadQueryFont(window->display, font);
|
|
window->font_struct = X11_XLoadQueryFont(window->display, font);
|
|
|
SDL_free(font);
|
|
SDL_free(font);
|
|
|
- if (!window->font_struct) {
|
|
|
|
|
- if (window->scale && window->iscale > 0) {
|
|
|
|
|
- window->iscale = (int)SDL_ceilf(window->scale);
|
|
|
|
|
- window->scale = 0;
|
|
|
|
|
- } else {
|
|
|
|
|
- window->iscale--;
|
|
|
|
|
- }
|
|
|
|
|
- goto load_font_traditional;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (!window->font_struct) {
|
|
|
|
|
+ if (window->scale && window->iscale > 0) {
|
|
|
|
|
+ window->iscale = (int)SDL_ceilf(window->scale);
|
|
|
|
|
+ window->scale = 0;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ window->iscale--;
|
|
|
|
|
+ }
|
|
|
|
|
+ goto load_font_traditional;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -426,7 +426,7 @@ static void X11Toolkit_SettingsNotify(const char *name, XSettingsAction action,
|
|
|
X11_XFreeFont(window->display, window->font_struct);
|
|
X11_XFreeFont(window->display, window->font_struct);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- X11Toolkit_InitWindowFonts(window);
|
|
|
|
|
|
|
+ X11Toolkit_InitWindowFonts(window);
|
|
|
|
|
|
|
|
/* set up window */
|
|
/* set up window */
|
|
|
if (window->scale != 0) {
|
|
if (window->scale != 0) {
|
|
@@ -448,15 +448,15 @@ static void X11Toolkit_SettingsNotify(const char *name, XSettingsAction action,
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
X11_XFreePixmap(window->display, window->drawable);
|
|
X11_XFreePixmap(window->display, window->drawable);
|
|
|
- X11Toolkit_InitWindowPixmap(window);
|
|
|
|
|
|
|
+ X11Toolkit_InitWindowPixmap(window);
|
|
|
} else {
|
|
} else {
|
|
|
if (!dbe_already_setup) {
|
|
if (!dbe_already_setup) {
|
|
|
X11_XFreePixmap(window->display, window->drawable);
|
|
X11_XFreePixmap(window->display, window->drawable);
|
|
|
#ifndef NO_SHARED_MEMORY
|
|
#ifndef NO_SHARED_MEMORY
|
|
|
- if (window->image) {
|
|
|
|
|
- XDestroyImage(window->image);
|
|
|
|
|
- window->image = NULL;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (window->image) {
|
|
|
|
|
+ XDestroyImage(window->image);
|
|
|
|
|
+ window->image = NULL;
|
|
|
|
|
+ }
|
|
|
#endif
|
|
#endif
|
|
|
#ifdef SDL_VIDEO_DRIVER_X11_XDBE
|
|
#ifdef SDL_VIDEO_DRIVER_X11_XDBE
|
|
|
if (SDL_X11_HAVE_XDBE && window->xdbe) {
|
|
if (SDL_X11_HAVE_XDBE && window->xdbe) {
|
|
@@ -567,28 +567,28 @@ SDL_ToolkitWindowX11 *X11Toolkit_CreateWindowStruct(SDL_Window *parent, SDL_Tool
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
window->parent_device = NULL;
|
|
window->parent_device = NULL;
|
|
|
- if (create_new_display) {
|
|
|
|
|
- window->display = X11_XOpenDisplay(NULL);
|
|
|
|
|
- window->display_close = true;
|
|
|
|
|
- if (!window->display) {
|
|
|
|
|
- ErrorFreeRetNull("Couldn't open X11 display", window);
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- if (parent) {
|
|
|
|
|
- window->parent_device = SDL_GetVideoDevice();
|
|
|
|
|
- window->display = window->parent_device->internal->display;
|
|
|
|
|
- window->display_close = false;
|
|
|
|
|
- } else if (tkparent) {
|
|
|
|
|
- window->display = tkparent->display;
|
|
|
|
|
- window->display_close = false;
|
|
|
|
|
- } else {
|
|
|
|
|
- window->display = X11_XOpenDisplay(NULL);
|
|
|
|
|
- window->display_close = true;
|
|
|
|
|
- if (!window->display) {
|
|
|
|
|
- ErrorFreeRetNull("Couldn't open X11 display", window);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (create_new_display) {
|
|
|
|
|
+ window->display = X11_XOpenDisplay(NULL);
|
|
|
|
|
+ window->display_close = true;
|
|
|
|
|
+ if (!window->display) {
|
|
|
|
|
+ ErrorFreeRetNull("Couldn't open X11 display", window);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (parent) {
|
|
|
|
|
+ window->parent_device = SDL_GetVideoDevice();
|
|
|
|
|
+ window->display = window->parent_device->internal->display;
|
|
|
|
|
+ window->display_close = false;
|
|
|
|
|
+ } else if (tkparent) {
|
|
|
|
|
+ window->display = tkparent->display;
|
|
|
|
|
+ window->display_close = false;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ window->display = X11_XOpenDisplay(NULL);
|
|
|
|
|
+ window->display_close = true;
|
|
|
|
|
+ if (!window->display) {
|
|
|
|
|
+ ErrorFreeRetNull("Couldn't open X11 display", window);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
#ifdef SDL_VIDEO_DRIVER_X11_XRANDR
|
|
#ifdef SDL_VIDEO_DRIVER_X11_XRANDR
|
|
|
int xrandr_event_base, xrandr_error_base;
|
|
int xrandr_event_base, xrandr_error_base;
|
|
@@ -596,19 +596,19 @@ SDL_ToolkitWindowX11 *X11Toolkit_CreateWindowStruct(SDL_Window *parent, SDL_Tool
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef NO_SHARED_MEMORY
|
|
#ifndef NO_SHARED_MEMORY
|
|
|
- window->shm_pixmap = False;
|
|
|
|
|
- window->shm = X11_XShmQueryExtension(window->display) ? SDL_X11_HAVE_SHM : false;
|
|
|
|
|
- if (window->shm) {
|
|
|
|
|
- int major;
|
|
|
|
|
- int minor;
|
|
|
|
|
-
|
|
|
|
|
- X11_XShmQueryVersion(window->display, &major, &minor, &window->shm_pixmap);
|
|
|
|
|
- if (window->shm_pixmap) {
|
|
|
|
|
- if (X11_XShmPixmapFormat(window->display) != ZPixmap) {
|
|
|
|
|
- window->shm_pixmap = False;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ window->shm_pixmap = False;
|
|
|
|
|
+ window->shm = X11_XShmQueryExtension(window->display) ? SDL_X11_HAVE_SHM : false;
|
|
|
|
|
+ if (window->shm) {
|
|
|
|
|
+ int major;
|
|
|
|
|
+ int minor;
|
|
|
|
|
+
|
|
|
|
|
+ X11_XShmQueryVersion(window->display, &major, &minor, &window->shm_pixmap);
|
|
|
|
|
+ if (window->shm_pixmap) {
|
|
|
|
|
+ if (X11_XShmPixmapFormat(window->display) != ZPixmap) {
|
|
|
|
|
+ window->shm_pixmap = False;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
/* Scale/Xsettings */
|
|
/* Scale/Xsettings */
|
|
@@ -622,10 +622,10 @@ SDL_ToolkitWindowX11 *X11Toolkit_CreateWindowStruct(SDL_Window *parent, SDL_Tool
|
|
|
window->scale = 0;
|
|
window->scale = 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /* Fonts */
|
|
|
|
|
- X11Toolkit_InitWindowFonts(window);
|
|
|
|
|
-
|
|
|
|
|
- /* Color hints */
|
|
|
|
|
|
|
+ /* Fonts */
|
|
|
|
|
+ X11Toolkit_InitWindowFonts(window);
|
|
|
|
|
+
|
|
|
|
|
+ /* Color hints */
|
|
|
if (!colorhints) {
|
|
if (!colorhints) {
|
|
|
colorhints = g_default_colors;
|
|
colorhints = g_default_colors;
|
|
|
}
|
|
}
|
|
@@ -994,7 +994,7 @@ bool X11Toolkit_CreateWindowRes(SDL_ToolkitWindowX11 *data, int w, int h, int cx
|
|
|
}
|
|
}
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
- X11Toolkit_InitWindowPixmap(data);
|
|
|
|
|
|
|
+ X11Toolkit_InitWindowPixmap(data);
|
|
|
|
|
|
|
|
SDL_zero(ctx_vals);
|
|
SDL_zero(ctx_vals);
|
|
|
ctx_vals.foreground = data->xcolor[SDL_MESSAGEBOX_COLOR_BACKGROUND].pixel;
|
|
ctx_vals.foreground = data->xcolor[SDL_MESSAGEBOX_COLOR_BACKGROUND].pixel;
|
|
@@ -1028,8 +1028,8 @@ bool X11Toolkit_CreateWindowRes(SDL_ToolkitWindowX11 *data, int w, int h, int cx
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void X11Toolkit_DrawWindow(SDL_ToolkitWindowX11 *data) {
|
|
static void X11Toolkit_DrawWindow(SDL_ToolkitWindowX11 *data) {
|
|
|
- SDL_Rect rect;
|
|
|
|
|
- int i;
|
|
|
|
|
|
|
+ SDL_Rect rect;
|
|
|
|
|
+ int i;
|
|
|
|
|
|
|
|
#ifdef SDL_VIDEO_DRIVER_X11_XDBE
|
|
#ifdef SDL_VIDEO_DRIVER_X11_XDBE
|
|
|
if (SDL_X11_HAVE_XDBE && data->xdbe && !data->pixmap) {
|
|
if (SDL_X11_HAVE_XDBE && data->xdbe && !data->pixmap) {
|
|
@@ -1066,39 +1066,39 @@ static void X11Toolkit_DrawWindow(SDL_ToolkitWindowX11 *data) {
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
if (data->pixmap) {
|
|
if (data->pixmap) {
|
|
|
- SDL_Surface *scale_surface;
|
|
|
|
|
|
|
+ SDL_Surface *scale_surface;
|
|
|
|
|
|
|
|
- rect.x = rect.y = 0;
|
|
|
|
|
- rect.w = data->window_width;
|
|
|
|
|
- rect.h = data->window_height;
|
|
|
|
|
|
|
+ rect.x = rect.y = 0;
|
|
|
|
|
+ rect.w = data->window_width;
|
|
|
|
|
+ rect.h = data->window_height;
|
|
|
#ifndef NO_SHARED_MEMORY
|
|
#ifndef NO_SHARED_MEMORY
|
|
|
- if (data->shm) {
|
|
|
|
|
- if (data->shm_pixmap) {
|
|
|
|
|
- X11_XFlush(data->display);
|
|
|
|
|
- X11_XSync(data->display, false);
|
|
|
|
|
- scale_surface = SDL_CreateSurfaceFrom(data->pixmap_width, data->pixmap_height, X11_GetPixelFormatFromVisualInfo(data->display, &data->vi), data->shm_info.shmaddr, data->shm_bytes_per_line);
|
|
|
|
|
- SDL_BlitSurfaceScaled(scale_surface, NULL, scale_surface, &rect, SDL_SCALEMODE_LINEAR);
|
|
|
|
|
- SDL_DestroySurface(scale_surface);
|
|
|
|
|
- X11_XCopyArea(data->display, data->drawable, data->window, data->ctx, 0, 0, data->window_width, data->window_height, 0, 0);
|
|
|
|
|
- } else {
|
|
|
|
|
- X11_XShmGetImage(data->display, data->drawable, data->image, 0, 0, AllPlanes);
|
|
|
|
|
- scale_surface = SDL_CreateSurfaceFrom(data->pixmap_width, data->pixmap_height, X11_GetPixelFormatFromVisualInfo(data->display, &data->vi), data->image->data, data->image->bytes_per_line);
|
|
|
|
|
- SDL_BlitSurfaceScaled(scale_surface, NULL, scale_surface, &rect, SDL_SCALEMODE_LINEAR);
|
|
|
|
|
- X11_XShmPutImage(data->display, data->window, data->ctx, data->image, 0, 0, 0, 0, data->window_width, data->window_height, False);
|
|
|
|
|
- }
|
|
|
|
|
- } else
|
|
|
|
|
|
|
+ if (data->shm) {
|
|
|
|
|
+ if (data->shm_pixmap) {
|
|
|
|
|
+ X11_XFlush(data->display);
|
|
|
|
|
+ X11_XSync(data->display, false);
|
|
|
|
|
+ scale_surface = SDL_CreateSurfaceFrom(data->pixmap_width, data->pixmap_height, X11_GetPixelFormatFromVisualInfo(data->display, &data->vi), data->shm_info.shmaddr, data->shm_bytes_per_line);
|
|
|
|
|
+ SDL_BlitSurfaceScaled(scale_surface, NULL, scale_surface, &rect, SDL_SCALEMODE_LINEAR);
|
|
|
|
|
+ SDL_DestroySurface(scale_surface);
|
|
|
|
|
+ X11_XCopyArea(data->display, data->drawable, data->window, data->ctx, 0, 0, data->window_width, data->window_height, 0, 0);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ X11_XShmGetImage(data->display, data->drawable, data->image, 0, 0, AllPlanes);
|
|
|
|
|
+ scale_surface = SDL_CreateSurfaceFrom(data->pixmap_width, data->pixmap_height, X11_GetPixelFormatFromVisualInfo(data->display, &data->vi), data->image->data, data->image->bytes_per_line);
|
|
|
|
|
+ SDL_BlitSurfaceScaled(scale_surface, NULL, scale_surface, &rect, SDL_SCALEMODE_LINEAR);
|
|
|
|
|
+ X11_XShmPutImage(data->display, data->window, data->ctx, data->image, 0, 0, 0, 0, data->window_width, data->window_height, False);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else
|
|
|
#endif
|
|
#endif
|
|
|
- {
|
|
|
|
|
- XImage *image;
|
|
|
|
|
-
|
|
|
|
|
- image = X11_XGetImage(data->display, data->drawable, 0, 0 , data->pixmap_width, data->pixmap_height, AllPlanes, ZPixmap);
|
|
|
|
|
- scale_surface = SDL_CreateSurfaceFrom(data->pixmap_width, data->pixmap_height, X11_GetPixelFormatFromVisualInfo(data->display, &data->vi), image->data, image->bytes_per_line);
|
|
|
|
|
- SDL_BlitSurfaceScaled(scale_surface, NULL, scale_surface, &rect, SDL_SCALEMODE_LINEAR);
|
|
|
|
|
- X11_XPutImage(data->display, data->window, data->ctx, image, 0, 0, 0, 0, data->window_width, data->window_height);
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ XImage *image;
|
|
|
|
|
+
|
|
|
|
|
+ image = X11_XGetImage(data->display, data->drawable, 0, 0 , data->pixmap_width, data->pixmap_height, AllPlanes, ZPixmap);
|
|
|
|
|
+ scale_surface = SDL_CreateSurfaceFrom(data->pixmap_width, data->pixmap_height, X11_GetPixelFormatFromVisualInfo(data->display, &data->vi), image->data, image->bytes_per_line);
|
|
|
|
|
+ SDL_BlitSurfaceScaled(scale_surface, NULL, scale_surface, &rect, SDL_SCALEMODE_LINEAR);
|
|
|
|
|
+ X11_XPutImage(data->display, data->window, data->ctx, image, 0, 0, 0, 0, data->window_width, data->window_height);
|
|
|
|
|
|
|
|
- XDestroyImage(image);
|
|
|
|
|
- SDL_DestroySurface(scale_surface);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ XDestroyImage(image);
|
|
|
|
|
+ SDL_DestroySurface(scale_surface);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
X11_XFlush(data->display);
|
|
X11_XFlush(data->display);
|
|
@@ -1351,8 +1351,8 @@ void X11Toolkit_ResizeWindow(SDL_ToolkitWindowX11 *data, int w, int h) {
|
|
|
data->pixmap_width = w;
|
|
data->pixmap_width = w;
|
|
|
data->pixmap_height = h;
|
|
data->pixmap_height = h;
|
|
|
X11_XFreePixmap(data->display, data->drawable);
|
|
X11_XFreePixmap(data->display, data->drawable);
|
|
|
- X11Toolkit_InitWindowPixmap(data);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ X11Toolkit_InitWindowPixmap(data);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
X11_XResizeWindow(data->display, data->window, data->window_width, data->window_height);
|
|
X11_XResizeWindow(data->display, data->window, data->window_width, data->window_height);
|
|
|
}
|
|
}
|
|
@@ -1782,13 +1782,13 @@ void X11Toolkit_DestroyWindow(SDL_ToolkitWindowX11 *data) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#ifndef NO_SHARED_MEMORY
|
|
#ifndef NO_SHARED_MEMORY
|
|
|
- if (data->pixmap && data->shm) {
|
|
|
|
|
- X11_XShmDetach(data->display, &data->shm_info);
|
|
|
|
|
- if (!data->shm_pixmap) {
|
|
|
|
|
- XDestroyImage(data->image);
|
|
|
|
|
- }
|
|
|
|
|
- shmdt(data->shm_info.shmaddr);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (data->pixmap && data->shm) {
|
|
|
|
|
+ X11_XShmDetach(data->display, &data->shm_info);
|
|
|
|
|
+ if (!data->shm_pixmap) {
|
|
|
|
|
+ XDestroyImage(data->image);
|
|
|
|
|
+ }
|
|
|
|
|
+ shmdt(data->shm_info.shmaddr);
|
|
|
|
|
+ }
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef X_HAVE_UTF8_STRING
|
|
#ifdef X_HAVE_UTF8_STRING
|