9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] [PATCH] Drawterm for OS X multi-screen resize fix
@ 2007-10-06 13:09 underspecified
  0 siblings, 0 replies; only message in thread
From: underspecified @ 2007-10-06 13:09 UTC (permalink / raw)
  To: 9fans


[-- Attachment #1.1: Type: text/plain, Size: 757 bytes --]

Greetings,

I have discovered a bug in the OS X native draw code used in both Drawterm
and Inferno's emu.
In multiple monitor setups, if the secondary monitor has a larger resolution
than the primary, the
window will resize, but the contents will not get any larger than the
maximum size on the primary
monitor. This is because screeninit() allocates enough memory for maximizing
on the primary
window only. I fixed this by writing a function max_bounds() which
calculates the theoretical max
resolution and allocates memory appropriately. I am attaching a patch for
Drawterm. The code is
a little different for Emu because of window resize events that Acme SAC
uses, so I will make a
separate release for that shortly.

--underspecified

[-- Attachment #1.2: Type: text/html, Size: 788 bytes --]

[-- Attachment #2: multiscreen-resize.diff --]
[-- Type: application/octet-stream, Size: 1531 bytes --]

diff -Nru drawterm.orig/gui-osx/screen.c drawterm/gui-osx/screen.c
--- drawterm.orig/gui-osx/screen.c	2007-02-01 14:10:03.000000000 +0900
+++ drawterm/gui-osx/screen.c	2007-10-06 21:42:46.000000000 +0900
@@ -78,6 +78,32 @@
 
 void winproc(void *a);
 
+// Get the largest possible dimensions from all displays
+#define MAX_DISPLAYS 32 
+CGRect
+max_bounds()
+{
+	CGDirectDisplayID d[MAX_DISPLAYS]; 
+	CGDisplayCount c, i;
+	CGRect r;
+	int bx=0, by=0, rx=0, ry=0;
+
+	if (CGGetActiveDisplayList (MAX_DISPLAYS, d, &c) == noErr) {
+		for (i = 0; i < c; i++) {
+			r = CGDisplayBounds(d[i]);
+			rx = r.size.width;
+			ry = r.size.height;
+			if (rx > bx)
+				bx = rx;
+			if (ry > by)
+				by = ry;
+		}
+		return CGRectMake(0,0,bx,by);
+	}
+	else
+		return CGDisplayBounds(CGMainDisplayID());
+}
+
 void screeninit(void)
 {
 	int fmt;
@@ -91,11 +117,9 @@
 	screen.depth = 32;
 	fmt = XBGR32; //XRGB32;
 
-	devRect = CGDisplayBounds(CGMainDisplayID());
-//	devRect.origin.x = 0;
-//	devRect.origin.y = 0;
-//	devRect.size.width = 1024;
-//	devRect.size.height = 768;
+//	devRect = CGDisplayBounds(CGMainDisplayID());
+	// Allocate memory for the largest conceivable display size
+	devRect = max_bounds();
 	dx = devRect.size.width;
 	dy = devRect.size.height;
 
@@ -107,6 +131,9 @@
 				kCGImageAlphaNoneSkipLast,
 				dataProviderRef, 0, 0, kCGRenderingIntentDefault);
 
+	// Set current window size to main display
+	devRect = CGDisplayBounds(CGMainDisplayID());
+
 	kproc("osxscreen", winproc, 0);
 	ksleep(&rend, isready, 0);
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-10-06 13:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-06 13:09 [9fans] [PATCH] Drawterm for OS X multi-screen resize fix underspecified

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).