Dispite other options like font scaling are given, I came up with a
patch to let you have the same "blurry X11 experience" with metal-cacoa
------------------------------------------
9fans: 9fans
Permalink:
https://9fans.topicbox.com/groups/9fans/Td7c2ae50f4223392-M115f25fa5bf7b2b385601e54
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
diff --git a/gui-cocoa/screen.m b/gui-cocoa/screen.m
index b4e7b2d..6192ff9 100644
--- a/gui-cocoa/screen.m
+++ b/gui-cocoa/screen.m
@@ -72,7 +72,7 @@ @interface AppDelegate : NSObject <NSApplicationDelegate,
NSWindowDelegate>
screeninit(void)
{
memimageinit();
- NSSize s = [myview convertSizeToBacking:myview.frame.size];
+ NSSize s = myview.frame.size;
screensize(Rect(0, 0, s.width, s.height), ARGB32);
gscreen->clipr = Rect(0, 0, s.width, s.height);
LOG(@"%g %g", s.width, s.height);
@@ -102,9 +102,8 @@ @interface AppDelegate : NSObject <NSApplicationDelegate,
NSWindowDelegate>
textureDesc.cpuCacheMode = MTLCPUCacheModeWriteCombined;
layer.texture = [layer.device newTextureWithDescriptor:textureDesc];
- CGFloat scale = myview.window.backingScaleFactor;
[layer setDrawableSize:NSMakeSize(Dx(r), Dy(r))];
- [layer setContentsScale:scale];
+ [layer setContentsScale:1.0];
}
gscreen = i;
gscreen->clipr = ZR;
@@ -161,7 +160,7 @@ @interface AppDelegate : NSObject <NSApplicationDelegate,
NSWindowDelegate>
mipmapLevel:0
withBytes:byteaddr(gscreen, Pt(r.min.x, r.min.y))
bytesPerRow:gscreen->width * 4];
- NSRect sr = [[myview window]
convertRectFromBacking:NSMakeRect(r.min.x, r.min.y, Dx(r), Dy(r))];
+ NSRect sr = NSMakeRect(r.min.x, r.min.y, Dx(r), Dy(r));
dispatch_async(dispatch_get_main_queue(),
^(void){@autoreleasepool{
LOG(@"setNeedsDisplayInRect %g %g %g %g", sr.origin.x,
sr.origin.y, sr.size.width, sr.size.height);
[myview setNeedsDisplayInRect:sr];
@@ -284,8 +283,6 @@ @interface AppDelegate : NSObject <NSApplicationDelegate,
NSWindowDelegate>
if([[myview window] isKeyWindow]){
s = NSMakePoint(p.x, p.y);
- LOG(@"-> pixel %g %g", s.x, s.y);
- s = [[myview window] convertPointFromBacking:s];
LOG(@"-> point %g %g", s.x, s.y);
s = [myview convertPoint:s toView:nil];
LOG(@"-> window %g %g", s.x, s.y);
@@ -377,8 +374,8 @@ - (BOOL)
applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApp
- (void) windowDidBecomeKey:(id)arg
{
NSPoint p;
- p = [_window convertPointToBacking:[_window
mouseLocationOutsideOfEventStream]];
- absmousetrack(p.x, [myview
convertSizeToBacking:myview.frame.size].height - p.y, 0, ticks());
+ p = [_window mouseLocationOutsideOfEventStream];
+ absmousetrack(p.x, myview.frame.size.height - p.y, 0, ticks());
}
- (void) windowDidResignKey:(id)arg
@@ -595,7 +592,7 @@ - (void) mouseevent:(NSEvent*)event
NSUInteger u;
NSEventModifierFlags m;
- p = [self.window convertPointToBacking:[self.window
mouseLocationOutsideOfEventStream]];
+ p = [self.window mouseLocationOutsideOfEventStream];
u = [NSEvent pressedMouseButtons];
q.x = p.x;
q.y = p.y;
@@ -609,7 +606,7 @@ - (void) mouseevent:(NSEvent*)event
}else if(m & NSEventModifierFlagCommand)
u = 4;
}
- absmousetrack(p.x, [self convertSizeToBacking:self.frame.size].height -
p.y, u, ticks());
+ absmousetrack(p.x, self.frame.size.height - p.y, u, ticks());
if(u && _lastInputRect.size.width && _lastInputRect.size.height)
[self resetLastInputRect];
}
@@ -697,7 +694,7 @@ - (void) resetCursorRects
- (void) reshape
{
- NSSize s = [self convertSizeToBacking:self.frame.size];
+ NSSize s = self.frame.size;
LOG(@"%g %g", s.width, s.height);
if(gscreen != nil){
screenresize(Rect(0, 0, s.width, s.height));
diff --git a/gui-metal/screen.m b/gui-metal/screen.m
index db03067..c6bb6bb 100644
--- a/gui-metal/screen.m
+++ b/gui-metal/screen.m
@@ -73,7 +73,7 @@ @interface AppDelegate : NSObject <NSApplicationDelegate,
NSWindowDelegate>
screeninit(void)
{
memimageinit();
- NSSize s = [myview convertSizeToBacking:myview.frame.size];
+ NSSize s = myview.frame.size;
screensize(Rect(0, 0, s.width, s.height), ARGB32);
gscreen->clipr = Rect(0, 0, s.width, s.height);
LOG(@"%g %g", s.width, s.height);
@@ -103,9 +103,8 @@ @interface AppDelegate : NSObject <NSApplicationDelegate,
NSWindowDelegate>
textureDesc.cpuCacheMode = MTLCPUCacheModeWriteCombined;
layer.texture = [layer.device newTextureWithDescriptor:textureDesc];
- CGFloat scale = myview.window.backingScaleFactor;
[layer setDrawableSize:NSMakeSize(Dx(r), Dy(r))];
- [layer setContentsScale:scale];
+ [layer setContentsScale:1.0];
}
gscreen = i;
gscreen->clipr = ZR;
@@ -162,7 +161,7 @@ @interface AppDelegate : NSObject <NSApplicationDelegate,
NSWindowDelegate>
mipmapLevel:0
withBytes:byteaddr(gscreen, Pt(r.min.x, r.min.y))
bytesPerRow:gscreen->width * 4];
- NSRect sr = [[myview window]
convertRectFromBacking:NSMakeRect(r.min.x, r.min.y, Dx(r), Dy(r))];
+ NSRect sr = NSMakeRect(r.min.x, r.min.y, Dx(r), Dy(r));
dispatch_async(dispatch_get_main_queue(),
^(void){@autoreleasepool{
LOG(@"setNeedsDisplayInRect %g %g %g %g", sr.origin.x,
sr.origin.y, sr.size.width, sr.size.height);
[myview setNeedsDisplayInRect:sr];
@@ -285,8 +284,6 @@ @interface AppDelegate : NSObject <NSApplicationDelegate,
NSWindowDelegate>
if([[myview window] isKeyWindow]){
s = NSMakePoint(p.x, p.y);
- LOG(@"-> pixel %g %g", s.x, s.y);
- s = [[myview window] convertPointFromBacking:s];
LOG(@"-> point %g %g", s.x, s.y);
s = [myview convertPoint:s toView:nil];
LOG(@"-> window %g %g", s.x, s.y);
@@ -383,8 +380,8 @@ - (BOOL)
applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApp
- (void) windowDidBecomeKey:(id)arg
{
NSPoint p;
- p = [_window convertPointToBacking:[_window
mouseLocationOutsideOfEventStream]];
- absmousetrack(p.x, [myview
convertSizeToBacking:myview.frame.size].height - p.y, 0, ticks());
+ p = [_window mouseLocationOutsideOfEventStream];
+ absmousetrack(p.x, myview.frame.size.height - p.y, 0, ticks());
}
- (void) windowDidResignKey:(id)arg
@@ -601,7 +598,7 @@ - (void) mouseevent:(NSEvent*)event
NSUInteger u;
NSEventModifierFlags m;
- p = [self.window convertPointToBacking:[self.window
mouseLocationOutsideOfEventStream]];
+ p = [self.window mouseLocationOutsideOfEventStream];
u = [NSEvent pressedMouseButtons];
q.x = p.x;
q.y = p.y;
@@ -615,7 +612,7 @@ - (void) mouseevent:(NSEvent*)event
}else if(m & NSEventModifierFlagCommand)
u = 4;
}
- absmousetrack(p.x, [self convertSizeToBacking:self.frame.size].height -
p.y, u, ticks());
+ absmousetrack(p.x, self.frame.size.height - p.y, u, ticks());
if(u && _lastInputRect.size.width && _lastInputRect.size.height)
[self resetLastInputRect];
}
@@ -703,7 +700,7 @@ - (void) resetCursorRects
- (void) reshape
{
- NSSize s = [self convertSizeToBacking:self.frame.size];
+ NSSize s = self.frame.size;
LOG(@"%g %g", s.width, s.height);
if(gscreen != nil){
screenresize(Rect(0, 0, s.width, s.height));