[gtk/wip/chergert/macos-iosurface] experiment with altering how we change layers
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/macos-iosurface] experiment with altering how we change layers
- Date: Sat, 12 Feb 2022 01:03:13 +0000 (UTC)
commit 8ad385b9db305b601dabbe412178b310cbdd046d
Author: Christian Hergert <christian hergert me>
Date: Fri Feb 11 17:03:06 2022 -0800
experiment with altering how we change layers
this still needs more work, but its a start. we can track teh edge were
on and make it a bit better
gdk/macos/GdkMacosWindow.c | 64 ++++++++++++++++------------------------------
1 file changed, 22 insertions(+), 42 deletions(-)
---
diff --git a/gdk/macos/GdkMacosWindow.c b/gdk/macos/GdkMacosWindow.c
index 8401f45860..1eaff9b56f 100644
--- a/gdk/macos/GdkMacosWindow.c
+++ b/gdk/macos/GdkMacosWindow.c
@@ -21,6 +21,7 @@
#include "config.h"
+#include <QuartzCore/QuartzCore.h>
#include <gdk/gdk.h>
#import "GdkMacosBaseView.h"
@@ -40,10 +41,6 @@
#include "gdkmonitorprivate.h"
#include "gdksurfaceprivate.h"
-#ifndef AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER
-typedef NSString *CALayerContentsGravity;
-#endif
-
@implementation GdkMacosWindow
-(BOOL)windowShouldClose:(id)sender
@@ -148,9 +145,6 @@ typedef NSString *CALayerContentsGravity;
_gdk_macos_display_break_all_grabs (GDK_MACOS_DISPLAY (display), time);
- /* Reset gravity */
- [[[self contentView] layer] setContentsGravity:kCAGravityBottomLeft];
-
break;
}
@@ -243,6 +237,8 @@ typedef NSString *CALayerContentsGravity;
GdkSurface *surface;
GdkDisplay *display;
gboolean maximized;
+ int width_change;
+ int height_change;
surface = GDK_SURFACE (gdk_surface);
display = gdk_surface_get_display (surface);
@@ -254,6 +250,9 @@ typedef NSString *CALayerContentsGravity;
if (maximized && !inMaximizeTransition && !NSEqualRects (lastMaximizedFrame, [self frame]))
[self windowDidUnmaximize];
+ width_change = content_rect.size.width - surface->width;
+ height_change = content_rect.size.height - surface->height;
+
surface->width = content_rect.size.width;
surface->height = content_rect.size.height;
@@ -264,6 +263,13 @@ typedef NSString *CALayerContentsGravity;
[[self contentView] setFrame:NSMakeRect (0, 0, surface->width, surface->height)];
+ /* Adjust things to align until the next buffer comes in */
+ [CATransaction setDisableActions:YES];
+ [[[self contentView] layer]
+ setFrame:NSMakeRect (width_change, height_change,
+ surface->width + width_change,
+ surface->height + height_change)];
+
_gdk_macos_surface_update_size (gdk_surface);
gdk_surface_request_layout (surface);
@@ -560,47 +566,12 @@ typedef NSString *CALayerContentsGravity;
-(void)beginManualResize:(GdkSurfaceEdge)edge
{
- CALayerContentsGravity gravity = kCAGravityBottomLeft;
-
if (inMove || inManualMove || inManualResize)
return;
inManualResize = YES;
resizeEdge = edge;
-
- switch (edge)
- {
- default:
- case GDK_SURFACE_EDGE_NORTH:
- gravity = kCAGravityTopLeft;
- break;
-
- case GDK_SURFACE_EDGE_NORTH_WEST:
- gravity = kCAGravityTopRight;
- break;
-
- case GDK_SURFACE_EDGE_SOUTH_WEST:
- case GDK_SURFACE_EDGE_WEST:
- gravity = kCAGravityBottomRight;
- break;
-
- case GDK_SURFACE_EDGE_SOUTH:
- case GDK_SURFACE_EDGE_SOUTH_EAST:
- gravity = kCAGravityBottomLeft;
- break;
-
- case GDK_SURFACE_EDGE_EAST:
- gravity = kCAGravityBottomLeft;
- break;
-
- case GDK_SURFACE_EDGE_NORTH_EAST:
- gravity = kCAGravityTopLeft;
- break;
- }
-
- [[[self contentView] layer] setContentsGravity:gravity];
-
initialResizeFrame = [self frame];
initialResizeLocation = convert_nspoint_to_screen (self, [self mouseLocationOutsideOfEventStream]);
}
@@ -851,6 +822,15 @@ typedef NSString *CALayerContentsGravity;
-(void)swapBuffer:(GdkMacosBuffer *)buffer withDamage:(const cairo_region_t *)damage
{
+ CALayer *layer = [[self contentView] layer];
+ NSRect frame = [layer frame];
+
+ if (frame.origin.x != 0 || frame.origin.y != 0)
+ {
+ GdkSurface *surface = GDK_SURFACE ([self gdkSurface]);
+ [layer setFrame:NSMakeRect (0, 0, surface->width, surface->height)];
+ }
+
[(GdkMacosView *)[self contentView] swapBuffer:buffer withDamage:damage];
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]