API: gdk: Remove gdk_window_get_visual()

With it, remove window->visual.
This commit is contained in:
Benjamin Otte 2016-10-27 23:27:49 +02:00
parent 6cc94ff176
commit f420dc7456
17 changed files with 40 additions and 104 deletions

View File

@ -314,7 +314,6 @@ gdk_window_destroy
gdk_window_get_window_type gdk_window_get_window_type
gdk_window_get_display gdk_window_get_display
gdk_window_get_screen gdk_window_get_screen
gdk_window_get_visual
gdk_window_show gdk_window_show
gdk_window_show_unraised gdk_window_show_unraised
gdk_window_hide gdk_window_hide

View File

@ -211,7 +211,6 @@ _gdk_broadway_screen_init_root_window (GdkScreen * screen)
window = broadway_screen->root_window; window = broadway_screen->root_window;
window->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_BROADWAY, NULL); window->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_BROADWAY, NULL);
window->impl_window = window; window->impl_window = window;
window->visual = gdk_screen_get_system_visual (screen);
impl = GDK_WINDOW_IMPL_BROADWAY (window->impl); impl = GDK_WINDOW_IMPL_BROADWAY (window->impl);

View File

@ -157,7 +157,6 @@ struct _GdkWindow
GdkWindow *parent; GdkWindow *parent;
GdkWindow *transient_for; GdkWindow *transient_for;
GdkVisual *visual;
gpointer user_data; gpointer user_data;

View File

@ -1231,10 +1231,6 @@ gdk_window_new (GdkWindow *parent,
return NULL; return NULL;
} }
window->visual = gdk_screen_get_rgba_visual (screen);
if (window->visual == NULL)
window->visual = gdk_screen_get_system_visual (screen);
window->event_mask = attributes->event_mask; window->event_mask = attributes->event_mask;
if (attributes->wclass == GDK_INPUT_OUTPUT) if (attributes->wclass == GDK_INPUT_OUTPUT)
@ -2070,24 +2066,6 @@ gdk_window_get_window_type (GdkWindow *window)
return GDK_WINDOW_TYPE (window); return GDK_WINDOW_TYPE (window);
} }
/**
* gdk_window_get_visual:
* @window: a #GdkWindow
*
* Gets the #GdkVisual describing the pixel format of @window.
*
* Returns: (transfer none): a #GdkVisual
*
* Since: 2.24
**/
GdkVisual*
gdk_window_get_visual (GdkWindow *window)
{
g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
return window->visual;
}
/** /**
* gdk_window_get_screen: * gdk_window_get_screen:
* @window: a #GdkWindow * @window: a #GdkWindow
@ -2103,7 +2081,7 @@ gdk_window_get_screen (GdkWindow *window)
{ {
g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
return gdk_visual_get_screen (window->visual); return gdk_display_get_default_screen (window->display);
} }
/** /**

View File

@ -331,7 +331,6 @@ typedef enum
* @height: height of window * @height: height of window
* @wclass: #GDK_INPUT_OUTPUT (normal window) or #GDK_INPUT_ONLY (invisible * @wclass: #GDK_INPUT_OUTPUT (normal window) or #GDK_INPUT_ONLY (invisible
* window that receives events) * window that receives events)
* @visual: #GdkVisual for window
* @window_type: type of window * @window_type: type of window
* @cursor: cursor for the window (see gdk_window_set_cursor()) * @cursor: cursor for the window (see gdk_window_set_cursor())
* @override_redirect: %TRUE to bypass the window manager * @override_redirect: %TRUE to bypass the window manager
@ -493,8 +492,6 @@ GdkWindowType gdk_window_get_window_type (GdkWindow *window);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
gboolean gdk_window_is_destroyed (GdkWindow *window); gboolean gdk_window_is_destroyed (GdkWindow *window);
GDK_AVAILABLE_IN_ALL
GdkVisual * gdk_window_get_visual (GdkWindow *window);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GdkScreen * gdk_window_get_screen (GdkWindow *window); GdkScreen * gdk_window_get_screen (GdkWindow *window);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL

View File

@ -1516,11 +1516,9 @@ find_eglconfig_for_window (GdkWindow *window,
{ {
GdkDisplay *display = gdk_window_get_display (window); GdkDisplay *display = gdk_window_get_display (window);
EGLDisplay *egl_display = _gdk_mir_display_get_egl_display (display); EGLDisplay *egl_display = _gdk_mir_display_get_egl_display (display);
GdkVisual *visual = gdk_window_get_visual (window);
EGLint attrs[MAX_EGL_ATTRS]; EGLint attrs[MAX_EGL_ATTRS];
EGLint count; EGLint count;
EGLConfig *configs; EGLConfig *configs;
gboolean use_rgba;
int i = 0; int i = 0;
@ -1536,19 +1534,8 @@ find_eglconfig_for_window (GdkWindow *window,
attrs[i++] = 1; attrs[i++] = 1;
attrs[i++] = EGL_BLUE_SIZE; attrs[i++] = EGL_BLUE_SIZE;
attrs[i++] = 1; attrs[i++] = 1;
use_rgba = (visual == gdk_screen_get_rgba_visual (gdk_display_get_default_screen (display)));
if (use_rgba)
{
attrs[i++] = EGL_ALPHA_SIZE; attrs[i++] = EGL_ALPHA_SIZE;
attrs[i++] = 1; attrs[i++] = 1;
}
else
{
attrs[i++] = EGL_ALPHA_SIZE;
attrs[i++] = 0;
}
attrs[i++] = EGL_NONE; attrs[i++] = EGL_NONE;
g_assert (i < MAX_EGL_ATTRS); g_assert (i < MAX_EGL_ATTRS);

View File

@ -574,9 +574,7 @@
if (GDK_WINDOW_DESTROYED (gdk_window)) if (GDK_WINDOW_DESTROYED (gdk_window))
return YES; return YES;
/* A view is opaque if its GdkWindow doesn't have the RGBA visual */ return NO;
return gdk_window_get_visual (gdk_window) !=
gdk_screen_get_rgba_visual (_gdk_screen);
} }
-(void)drawRect: (NSRect)rect -(void)drawRect: (NSRect)rect

View File

@ -862,11 +862,8 @@ _gdk_quartz_display_create_window_impl (GdkDisplay *display,
gdk_window_set_title (window, title); gdk_window_set_title (window, title);
if (gdk_window_get_visual (window) == gdk_screen_get_rgba_visual (_gdk_screen))
{
[impl->toplevel setOpaque:NO]; [impl->toplevel setOpaque:NO];
[impl->toplevel setBackgroundColor:[NSColor clearColor]]; [impl->toplevel setBackgroundColor:[NSColor clearColor]];
}
content_rect.origin.x = 0; content_rect.origin.x = 0;
content_rect.origin.y = 0; content_rect.origin.y = 0;

View File

@ -373,12 +373,9 @@ find_eglconfig_for_window (GdkWindow *window,
{ {
GdkDisplay *display = gdk_window_get_display (window); GdkDisplay *display = gdk_window_get_display (window);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display); GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
GdkVisual *visual = gdk_window_get_visual (window);
EGLint attrs[MAX_EGL_ATTRS]; EGLint attrs[MAX_EGL_ATTRS];
EGLint count; EGLint count;
EGLConfig *configs; EGLConfig *configs;
gboolean use_rgba;
int i = 0; int i = 0;
attrs[i++] = EGL_SURFACE_TYPE; attrs[i++] = EGL_SURFACE_TYPE;
@ -393,19 +390,8 @@ find_eglconfig_for_window (GdkWindow *window,
attrs[i++] = 1; attrs[i++] = 1;
attrs[i++] = EGL_BLUE_SIZE; attrs[i++] = EGL_BLUE_SIZE;
attrs[i++] = 1; attrs[i++] = 1;
use_rgba = (visual == gdk_screen_get_rgba_visual (gdk_display_get_default_screen (display)));
if (use_rgba)
{
attrs[i++] = EGL_ALPHA_SIZE; attrs[i++] = EGL_ALPHA_SIZE;
attrs[i++] = 1; attrs[i++] = 1;
}
else
{
attrs[i++] = EGL_ALPHA_SIZE;
attrs[i++] = 0;
}
attrs[i++] = EGL_NONE; attrs[i++] = EGL_NONE;
g_assert (i < MAX_EGL_ATTRS); g_assert (i < MAX_EGL_ATTRS);

View File

@ -359,7 +359,6 @@ _gdk_wayland_screen_create_root_window (GdkScreen *screen,
window = _gdk_display_create_window (GDK_DISPLAY (display_wayland)); window = _gdk_display_create_window (GDK_DISPLAY (display_wayland));
window->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_WAYLAND, NULL); window->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_WAYLAND, NULL);
window->impl_window = window; window->impl_window = window;
window->visual = gdk_screen_get_system_visual (screen);
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl); impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);

View File

@ -278,7 +278,6 @@ _get_dummy_window_hwnd (GdkWGLDummy *dummy)
static gint static gint
_get_wgl_pfd (HDC hdc, _get_wgl_pfd (HDC hdc,
const gboolean need_alpha_bits,
PIXELFORMATDESCRIPTOR *pfd) PIXELFORMATDESCRIPTOR *pfd)
{ {
gint best_pf = 0; gint best_pf = 0;
@ -293,16 +292,6 @@ _get_wgl_pfd (HDC hdc,
best_pf = ChoosePixelFormat (hdc, pfd); best_pf = ChoosePixelFormat (hdc, pfd);
if (best_pf == 0)
/* give another chance if need_alpha_bits is FALSE,
* meaning we prefer to have an alpha channel anyways
*/
if (!need_alpha_bits)
{
pfd->cAlphaBits = 0;
best_pf = ChoosePixelFormat (hdc, pfd);
}
return best_pf; return best_pf;
} }
@ -310,8 +299,7 @@ _get_wgl_pfd (HDC hdc,
* one and cache it for later use * one and cache it for later use
*/ */
static gint static gint
_gdk_init_dummy_context (GdkWGLDummy *dummy, _gdk_init_dummy_context (GdkWGLDummy *dummy)
const gboolean need_alpha_bits)
{ {
PIXELFORMATDESCRIPTOR pfd; PIXELFORMATDESCRIPTOR pfd;
gboolean set_pixel_format_result = FALSE; gboolean set_pixel_format_result = FALSE;
@ -322,7 +310,7 @@ _gdk_init_dummy_context (GdkWGLDummy *dummy,
dummy->hdc = GetDC (dummy->hwnd); dummy->hdc = GetDC (dummy->hwnd);
memset (&pfd, 0, sizeof (PIXELFORMATDESCRIPTOR)); memset (&pfd, 0, sizeof (PIXELFORMATDESCRIPTOR));
best_idx = _get_wgl_pfd (dummy->hdc, need_alpha_bits, &pfd); best_idx = _get_wgl_pfd (dummy->hdc, &pfd);
if (best_idx != 0) if (best_idx != 0)
set_pixel_format_result = SetPixelFormat (dummy->hdc, set_pixel_format_result = SetPixelFormat (dummy->hdc,
@ -342,8 +330,7 @@ _gdk_init_dummy_context (GdkWGLDummy *dummy,
} }
gboolean gboolean
_gdk_win32_display_init_gl (GdkDisplay *display, _gdk_win32_display_init_gl (GdkDisplay *display)
const gboolean need_alpha_bits)
{ {
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display); GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display);
gint best_idx = 0; gint best_idx = 0;
@ -358,7 +345,7 @@ _gdk_win32_display_init_gl (GdkDisplay *display,
* dummy GL Context, it is used to query functions * dummy GL Context, it is used to query functions
* and used for other stuff as well * and used for other stuff as well
*/ */
best_idx = _gdk_init_dummy_context (&dummy, need_alpha_bits); best_idx = _gdk_init_dummy_context (&dummy);
if (best_idx == 0 || !wglMakeCurrent (dummy.hdc, dummy.hglrc)) if (best_idx == 0 || !wglMakeCurrent (dummy.hdc, dummy.hglrc))
return FALSE; return FALSE;
@ -541,15 +528,12 @@ _gdk_win32_window_create_gl_context (GdkWindow *window,
GdkDisplay *display = gdk_window_get_display (window); GdkDisplay *display = gdk_window_get_display (window);
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (gdk_window_get_display (window)); GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (gdk_window_get_display (window));
GdkWin32GLContext *context = NULL; GdkWin32GLContext *context = NULL;
GdkVisual *visual = gdk_window_get_visual (window);
gboolean need_alpha_bits = (visual == gdk_screen_get_rgba_visual (gdk_display_get_default_screen (display)));
/* Acquire and store up the Windows-specific HWND and HDC */ /* Acquire and store up the Windows-specific HWND and HDC */
HWND hwnd; HWND hwnd;
HDC hdc; HDC hdc;
if (!_gdk_win32_display_init_gl (display, need_alpha_bits)) if (!_gdk_win32_display_init_gl (display))
{ {
g_set_error_literal (error, GDK_GL_ERROR, g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_NOT_AVAILABLE, GDK_GL_ERROR_NOT_AVAILABLE,
@ -580,7 +564,6 @@ _gdk_win32_window_create_gl_context (GdkWindow *window,
"shared-context", share, "shared-context", share,
NULL); NULL);
context->need_alpha_bits = need_alpha_bits;
context->gl_hdc = hdc; context->gl_hdc = hdc;
context->is_attached = attached; context->is_attached = attached;
@ -662,7 +645,7 @@ gdk_win32_display_get_wgl_version (GdkDisplay *display,
if (!GDK_IS_WIN32_DISPLAY (display)) if (!GDK_IS_WIN32_DISPLAY (display))
return FALSE; return FALSE;
if (!_gdk_win32_display_init_gl (display, FALSE)) if (!_gdk_win32_display_init_gl (display))
return FALSE; return FALSE;
if (major != NULL) if (major != NULL)

View File

@ -964,12 +964,11 @@ _gdk_win32_window_description (GdkWindow *d)
{ {
g_return_val_if_fail (GDK_IS_WINDOW (d), NULL); g_return_val_if_fail (GDK_IS_WINDOW (d), NULL);
return static_printf ("%s:%p:%dx%dx%d", return static_printf ("%s:%p:%dx%d",
G_OBJECT_TYPE_NAME (d), G_OBJECT_TYPE_NAME (d),
GDK_WINDOW_HWND (d), GDK_WINDOW_HWND (d),
gdk_window_get_width (GDK_WINDOW (d)), gdk_window_get_width (GDK_WINDOW (d)),
gdk_window_get_height (GDK_WINDOW (d)), gdk_window_get_height (GDK_WINDOW (d)));
gdk_visual_get_depth (gdk_window_get_visual (GDK_WINDOW (d))));
} }
#endif /* G_ENABLE_DEBUG */ #endif /* G_ENABLE_DEBUG */

View File

@ -2262,10 +2262,9 @@ gdk_win32_window_get_geometry (GdkWindow *window,
if (height) if (height)
*height = rect.bottom - rect.top; *height = rect.bottom - rect.top;
GDK_NOTE (MISC, g_print ("gdk_win32_window_get_geometry: %p: %ldx%ldx%d@%+ld%+ld\n", GDK_NOTE (MISC, g_print ("gdk_win32_window_get_geometry: %p: %ldx%ld@%+ld%+ld\n",
GDK_WINDOW_HWND (window), GDK_WINDOW_HWND (window),
rect.right - rect.left, rect.bottom - rect.top, rect.right - rect.left, rect.bottom - rect.top,
gdk_window_get_visual (window)->depth,
rect.left, rect.top)); rect.left, rect.top));
} }
} }

View File

@ -2899,6 +2899,21 @@ gdk_x11_display_get_primary_monitor (GdkDisplay *display)
return NULL; return NULL;
} }
GdkVisual *
gdk_x11_display_get_window_visual (GdkX11Display *display)
{
GdkScreen *screen;
GdkVisual *visual;
screen = gdk_display_get_default_screen (GDK_DISPLAY (display));
visual = gdk_screen_get_rgba_visual (screen);
if (visual == NULL)
visual = gdk_screen_get_system_visual (screen);
return visual;
}
static void static void
gdk_x11_display_class_init (GdkX11DisplayClass * class) gdk_x11_display_class_init (GdkX11DisplayClass * class)
{ {

View File

@ -22,6 +22,7 @@
#include "gdkglcontext-x11.h" #include "gdkglcontext-x11.h"
#include "gdkdisplay-x11.h" #include "gdkdisplay-x11.h"
#include "gdkprivate-x11.h"
#include "gdkscreen-x11.h" #include "gdkscreen-x11.h"
#include "gdkx11display.h" #include "gdkx11display.h"
@ -1275,7 +1276,7 @@ gdk_x11_window_create_gl_context (GdkWindow *window,
return NULL; return NULL;
} }
visual = gdk_window_get_visual (window); visual = gdk_x11_display_get_window_visual (GDK_X11_DISPLAY (display));
if (!find_fbconfig_for_visual (display, visual, &config, error)) if (!find_fbconfig_for_visual (display, visual, &config, error))
return NULL; return NULL;

View File

@ -70,6 +70,7 @@ void _gdk_x11_screen_query_visual_types (GdkScreen *screen
GList * _gdk_x11_screen_list_visuals (GdkScreen *screen); GList * _gdk_x11_screen_list_visuals (GdkScreen *screen);
GdkVisual * gdk_x11_display_get_window_visual (GdkX11Display *display);
void _gdk_x11_display_add_window (GdkDisplay *display, void _gdk_x11_display_add_window (GdkDisplay *display,
XID *xid, XID *xid,

View File

@ -466,7 +466,7 @@ gdk_x11_create_cairo_surface (GdkWindowImplX11 *impl,
{ {
GdkVisual *visual; GdkVisual *visual;
visual = gdk_window_get_visual (impl->wrapper); visual = gdk_x11_display_get_window_visual (GDK_X11_DISPLAY (gdk_window_get_display (impl->wrapper)));
return cairo_xlib_surface_create (GDK_WINDOW_XDISPLAY (impl->wrapper), return cairo_xlib_surface_create (GDK_WINDOW_XDISPLAY (impl->wrapper),
GDK_WINDOW_IMPL_X11 (impl)->xid, GDK_WINDOW_IMPL_X11 (impl)->xid,
GDK_VISUAL_XVISUAL (visual), GDK_VISUAL_XVISUAL (visual),
@ -632,7 +632,6 @@ _gdk_x11_screen_init_root_window (GdkScreen *screen)
window->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL); window->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL);
window->impl_window = window; window->impl_window = window;
window->visual = gdk_screen_get_system_visual (screen);
impl = GDK_WINDOW_IMPL_X11 (window->impl); impl = GDK_WINDOW_IMPL_X11 (window->impl);
@ -903,6 +902,7 @@ _gdk_x11_display_create_window_impl (GdkDisplay *display,
GdkWindowImplX11 *impl; GdkWindowImplX11 *impl;
GdkX11Screen *x11_screen; GdkX11Screen *x11_screen;
GdkX11Display *display_x11; GdkX11Display *display_x11;
GdkVisual *visual;
Window xparent; Window xparent;
Visual *xvisual; Visual *xvisual;
@ -929,7 +929,8 @@ _gdk_x11_display_create_window_impl (GdkDisplay *display,
xattributes_mask = 0; xattributes_mask = 0;
xvisual = gdk_x11_visual_get_xvisual (window->visual); visual = gdk_x11_display_get_window_visual (display_x11);
xvisual = gdk_x11_visual_get_xvisual (visual);
if (attributes_mask & GDK_WA_NOREDIR) if (attributes_mask & GDK_WA_NOREDIR)
{ {
@ -966,7 +967,7 @@ _gdk_x11_display_create_window_impl (GdkDisplay *display,
xattributes.bit_gravity = NorthWestGravity; xattributes.bit_gravity = NorthWestGravity;
xattributes_mask |= CWBitGravity; xattributes_mask |= CWBitGravity;
xattributes.colormap = _gdk_visual_get_x11_colormap (window->visual); xattributes.colormap = _gdk_visual_get_x11_colormap (visual);
xattributes_mask |= CWColormap; xattributes_mask |= CWColormap;
if (window->window_type == GDK_WINDOW_TEMP) if (window->window_type == GDK_WINDOW_TEMP)
@ -1128,8 +1129,6 @@ gdk_x11_window_foreign_new_for_display (GdkDisplay *display,
win = _gdk_display_create_window (display); win = _gdk_display_create_window (display);
win->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL); win->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL);
win->impl_window = win; win->impl_window = win;
win->visual = gdk_x11_screen_lookup_visual (screen,
XVisualIDFromVisual (attrs.visual));
impl = GDK_WINDOW_IMPL_X11 (win->impl); impl = GDK_WINDOW_IMPL_X11 (win->impl);
impl->wrapper = win; impl->wrapper = win;