Merge branch 'wip/chergert/gdk-macos-for-master' into 'master'

macos: tweak opacity, color/alpha size requests

See merge request GNOME/gtk!2786
This commit is contained in:
Matthias Clasen 2020-11-06 01:20:23 +00:00
commit fb27724042
3 changed files with 33 additions and 19 deletions

View File

@ -21,6 +21,7 @@
#include "gdkmacosglcontext-private.h"
#include "gdkmacossurface-private.h"
#include "gdkmacostoplevelsurface-private.h"
#include "gdkinternals.h"
#include "gdkintl.h"
@ -100,6 +101,8 @@ create_pixel_format (int major,
NSOpenGLPFAAccelerated,
NSOpenGLPFADoubleBuffer,
NSOpenGLPFABackingStore,
NSOpenGLPFAColorSize, 32,
NSOpenGLPFAAlphaSize, 8,
(NSOpenGLPixelFormatAttribute)nil
};
@ -172,9 +175,8 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
NSOpenGLPixelFormat *pixelFormat;
GdkGLContext *shared;
GdkGLContext *shared_data;
GdkGLContext *existing;
NSOpenGLContext *existing;
GLint sync_to_framerate = 1;
GLint opaque = 0;
GLint validate = 0;
int major, minor;
@ -183,7 +185,7 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
if (self->gl_context != nil)
return TRUE;
existing = gdk_gl_context_get_current ();
existing = [NSOpenGLContext currentContext];
gdk_gl_context_get_required_version (context, &major, &minor);
@ -225,7 +227,6 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
}
[gl_context setValues:&sync_to_framerate forParameter:NSOpenGLCPSwapInterval];
[gl_context setValues:&opaque forParameter:NSOpenGLCPSurfaceOpacity];
[gl_context setValues:&validate forParameter:NSOpenGLContextParameterStateValidation];
self->dummy_window = [[NSWindow alloc] initWithContentRect:NSZeroRect
@ -248,7 +249,7 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
self->gl_context = g_steal_pointer (&gl_context);
if (existing != NULL)
[GDK_MACOS_GL_CONTEXT (existing)->gl_context makeCurrentContext];
[existing makeCurrentContext];
return TRUE;
}
@ -280,6 +281,9 @@ gdk_macos_gl_context_begin_frame (GdkDrawContext *context,
if (self->needs_resize)
{
GdkSurface *surface = gdk_draw_context_get_surface (context);
GLint opaque;
self->needs_resize = FALSE;
if (self->dummy_view != NULL)
@ -291,6 +295,16 @@ gdk_macos_gl_context_begin_frame (GdkDrawContext *context,
[self->dummy_view setFrame:frame];
}
/* Possibly update our opaque setting depending on a resize. We can
* rely on getting a resize if decoarated is changed, so this reduces
* how much we adjust the parameter.
*/
if (GDK_IS_MACOS_TOPLEVEL_SURFACE (surface))
opaque = GDK_MACOS_TOPLEVEL_SURFACE (surface)->decorated;
else
opaque = FALSE;
[self->gl_context setValues:&opaque forParameter:NSOpenGLCPSurfaceOpacity];
[self->gl_context update];
}

View File

@ -24,13 +24,24 @@
G_BEGIN_DECLS
typedef struct _GdkMacosToplevelSurface GdkMacosToplevelSurface;
typedef struct _GdkMacosToplevelSurfaceClass GdkMacosToplevelSurfaceClass;
#define GDK_TYPE_MACOS_TOPLEVEL_SURFACE (_gdk_macos_toplevel_surface_get_type())
#define GDK_MACOS_TOPLEVEL_SURFACE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_MACOS_TOPLEVEL_SURFACE, GdkMacosToplevelSurface))
#define GDK_IS_MACOS_TOPLEVEL_SURFACE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MACOS_TOPLEVEL_SURFACE))
typedef struct _GdkMacosToplevelSurface GdkMacosToplevelSurface;
typedef struct _GdkMacosToplevelSurfaceClass GdkMacosToplevelSurfaceClass;
struct _GdkMacosToplevelSurface
{
GdkMacosSurface parent_instance;
guint decorated : 1;
};
struct _GdkMacosToplevelSurfaceClass
{
GdkMacosSurfaceClass parent_instance;
};
GType _gdk_macos_toplevel_surface_get_type (void);
GdkMacosSurface *_gdk_macos_toplevel_surface_new (GdkMacosDisplay *display,
GdkSurface *parent,

View File

@ -29,17 +29,6 @@
#include "gdkmacostoplevelsurface-private.h"
#include "gdkmacosutils-private.h"
struct _GdkMacosToplevelSurface
{
GdkMacosSurface parent_instance;
guint decorated : 1;
};
struct _GdkMacosToplevelSurfaceClass
{
GdkMacosSurfaceClass parent_instance;
};
static void
_gdk_macos_toplevel_surface_fullscreen (GdkMacosToplevelSurface *self)
{