From 4c54893156cf2489081fe63eb37a0e4d3ede1e05 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 14 Jan 2020 12:06:34 -0500 Subject: devdraw: do not force-hide menu and dock during full screen on mac This hides the menu on dock on all screens which is more than we want. The code was added to fix a problem with Catalina that I can no longer reproduce, so I guess it works now. Fixes #336. --- src/cmd/devdraw/mac-screen.m | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/cmd/devdraw') diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index e02a2524..5e23c43a 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -930,6 +930,13 @@ rpc_setmouse(Client *c, Point p) - (NSApplicationPresentationOptions)window:(id)arg willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions { + // The default for full-screen is to auto-hide the dock and menu bar, + // but the menu bar in particular comes back when the cursor is just + // near the top of the screen, which makes acme's top tag line very difficult to use. + // Disable the menu bar entirely. + // In theory this code disables the dock entirely too, but if you drag the mouse + // down far enough off the bottom of the screen the dock still unhides. + // That's OK. NSApplicationPresentationOptions o; o = proposedOptions; o &= ~(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar); @@ -938,16 +945,21 @@ rpc_setmouse(Client *c, Point p) } - (void)windowWillEnterFullScreen:(NSNotification*)notification { - // TODO: This should only be done if the window - // is on the screen with the dock. - // But how can you tell which window has the dock? + // This is a heavier-weight way to make sure the menu bar and dock go away, + // but this affects all screens even though the app is running on full screen + // on only one screen, so it's not great. The behavior from the + // willUseFullScreenPresentationOptions seems to be enough for now. + /* [[NSApplication sharedApplication] setPresentationOptions:NSApplicationPresentationHideMenuBar | NSApplicationPresentationHideDock]; + */ } - (void)windowDidExitFullScreen:(NSNotification*)notification { + /* [[NSApplication sharedApplication] setPresentationOptions:NSApplicationPresentationDefault]; + */ } @end -- cgit v1.2.3 From 1f799495e4aa89be5f32e3fcda8da342f3057f3c Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 14 Jan 2020 19:43:32 -0500 Subject: devdraw: notify window resize promptly on x11 Fixes #339. --- src/cmd/devdraw/devdraw.c | 5 +---- src/cmd/devdraw/devdraw.h | 1 + src/cmd/devdraw/mac-screen.m | 1 - src/cmd/devdraw/srv.c | 18 ++++++++++++++++++ src/cmd/devdraw/x11-screen.c | 16 ++++++++-------- 5 files changed, 28 insertions(+), 13 deletions(-) (limited to 'src/cmd/devdraw') diff --git a/src/cmd/devdraw/devdraw.c b/src/cmd/devdraw/devdraw.c index 086574ef..b4c373ad 100644 --- a/src/cmd/devdraw/devdraw.c +++ b/src/cmd/devdraw/devdraw.c @@ -55,10 +55,7 @@ gfx_replacescreenimage(Client *c, Memimage *m) _freememimage(om); } qunlock(&c->drawlk); - - qlock(&c->eventlk); - c->mouse.resized = 1; - qunlock(&c->eventlk); + gfx_mouseresized(c); } static void diff --git a/src/cmd/devdraw/devdraw.h b/src/cmd/devdraw/devdraw.h index 4980ed90..6829ab32 100644 --- a/src/cmd/devdraw/devdraw.h +++ b/src/cmd/devdraw/devdraw.h @@ -187,6 +187,7 @@ void gfx_keystroke(Client*, int); void gfx_main(void); void gfx_mousetrack(Client*, int, int, int, uint); void gfx_replacescreenimage(Client*, Memimage*); +void gfx_mouseresized(Client*); void gfx_started(void); // rpc_* routines are called on the RPC thread, diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index 5e23c43a..4bc3f088 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -518,7 +518,6 @@ rpc_resizeimg(Client *c) - (void)resizeimg { [self initimg]; gfx_replacescreenimage(self.client, self.img); - [self sendmouse:0]; } - (void)windowDidResize:(NSNotification *)notification { diff --git a/src/cmd/devdraw/srv.c b/src/cmd/devdraw/srv.c index bfeb7c38..c98a865f 100644 --- a/src/cmd/devdraw/srv.c +++ b/src/cmd/devdraw/srv.c @@ -394,12 +394,30 @@ matchmouse(Client *c) } } +void +gfx_mouseresized(Client *c) +{ + gfx_mousetrack(c, -1, -1, -1, -1); +} + void gfx_mousetrack(Client *c, int x, int y, int b, uint ms) { Mouse *m; qlock(&c->eventlk); + if(x == -1 && y == -1 && b == -1 && ms == -1) { + Mouse *copy; + // repeat last mouse event for resize + if(c->mouse.ri == 0) + copy = &c->mouse.m[nelem(c->mouse.m)-1]; + else + copy = &c->mouse.m[c->mouse.ri-1]; + x = copy->xy.x; + y = copy->xy.y; + b = copy->buttons; + ms = copy->msec; + } if(x < c->mouserect.min.x) x = c->mouserect.min.x; if(x > c->mouserect.max.x) diff --git a/src/cmd/devdraw/x11-screen.c b/src/cmd/devdraw/x11-screen.c index 8026e1e6..c3a6fa33 100644 --- a/src/cmd/devdraw/x11-screen.c +++ b/src/cmd/devdraw/x11-screen.c @@ -44,7 +44,7 @@ static Xwin* newxwin(Client *c) { Xwin *w; - + w = mallocz(sizeof *w, 1); if(w == nil) sysfatal("out of memory"); @@ -59,7 +59,7 @@ static Xwin* findxwin(XDrawable d) { Xwin *w, **l; - + for(l=&_x.windows; (w=*l) != nil; l=&w->next) { if(w->drawable == d) { /* move to front */ @@ -658,7 +658,7 @@ xattach(Client *client, char *label, char *winsize) _x.losefocus = XInternAtom(_x.display, "_9WM_LOSE_FOCUS", False); _x.wmprotos = XInternAtom(_x.display, "WM_PROTOCOLS", False); } - + atoms[0] = _x.takefocus; atoms[1] = _x.losefocus; XChangeProperty(_x.display, w->drawable, _x.wmprotos, XA_ATOM, 32, @@ -700,7 +700,7 @@ xattach(Client *client, char *label, char *winsize) _x.gcsimplesrc = xgc(w->screenpm, FillStippled, -1); _x.gczero = xgc(w->screenpm, -1, -1); _x.gcreplsrc = xgc(w->screenpm, FillTiled, -1); - + pmid = XCreatePixmap(_x.display, w->drawable, 1, 1, 1); _x.gcfill0 = xgc(pmid, FillSolid, 0); _x.gccopy0 = xgc(pmid, -1, -1); @@ -729,7 +729,7 @@ rpc_setlabel(Client *client, char *label) { Xwin *w = (Xwin*)client->view; XTextProperty name; - + /* * Label and other properties required by ICCCCM. */ @@ -1032,7 +1032,7 @@ _xreplacescreenimage(Client *client) XDrawable pixmap; Rectangle r; Xwin *w; - + w = (Xwin*)client->view; r = w->newscreenr; pixmap = XCreatePixmap(_x.display, w->drawable, Dx(r), Dy(r), _x.depth); @@ -1527,7 +1527,7 @@ __xputsnarf(char *data) { XButtonEvent e; Xwin *w; - + if(strlen(data) >= SnarfSize) return; qlock(&clip.lk); @@ -1730,7 +1730,7 @@ rpc_bouncemouse(Client *c, Mouse m) Xwin *w = (Xwin*)c->view; XButtonEvent e; XWindow dw; - + xlock(); e.type = ButtonPress; e.state = 0; -- cgit v1.2.3 From ba60bab3cd247284977ff99573db0c1f3d056953 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 15 Jan 2020 11:09:16 -0500 Subject: devdraw: actually send resize event on resize Fixes #340. Fixes #343. --- src/cmd/devdraw/srv.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/cmd/devdraw') diff --git a/src/cmd/devdraw/srv.c b/src/cmd/devdraw/srv.c index c98a865f..570091bc 100644 --- a/src/cmd/devdraw/srv.c +++ b/src/cmd/devdraw/srv.c @@ -37,6 +37,8 @@ usage(void) void threadmain(int argc, char **argv) { + char *p; + ARGBEGIN{ case 'D': /* for good ps -a listings */ break; @@ -52,6 +54,10 @@ threadmain(int argc, char **argv) usage(); }ARGEND + fmtinstall('H', encodefmt); + if((p = getenv("DEVDRAWTRACE")) != nil) + trace = atoi(p); + if(srvname == nil) { client0 = mallocz(sizeof(Client), 1); if(client0 == nil){ @@ -417,6 +423,7 @@ gfx_mousetrack(Client *c, int x, int y, int b, uint ms) y = copy->xy.y; b = copy->buttons; ms = copy->msec; + c->mouse.resized = 1; } if(x < c->mouserect.min.x) x = c->mouserect.min.x; -- cgit v1.2.3 From fe2b2de9844749c876df209bb8d9413e0074cbcf Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 15 Jan 2020 11:25:36 -0500 Subject: devdraw: set windowrect correctly on x11 if window gets unexpected size Fixes #54. --- src/cmd/devdraw/x11-screen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/cmd/devdraw') diff --git a/src/cmd/devdraw/x11-screen.c b/src/cmd/devdraw/x11-screen.c index c3a6fa33..d01e8496 100644 --- a/src/cmd/devdraw/x11-screen.c +++ b/src/cmd/devdraw/x11-screen.c @@ -550,8 +550,6 @@ xattach(Client *client, char *label, char *winsize) havemin = 0; } w = newxwin(client); - w->screenrect = Rect(0, 0, WidthOfScreen(xscreen), HeightOfScreen(xscreen)); - w->windowrect = r; memset(&attr, 0, sizeof attr); attr.colormap = _x.cmap; @@ -679,6 +677,8 @@ xattach(Client *client, char *label, char *winsize) } }else fprint(2, "XGetWindowAttributes: bad attrs\n"); + w->screenrect = Rect(0, 0, WidthOfScreen(xscreen), HeightOfScreen(xscreen)); + w->windowrect = r; /* * Allocate our local backing store. -- cgit v1.2.3 From 0be57355f912dbedb76cea1a7a4f9a1deb5bde2b Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 15 Jan 2020 11:59:45 -0500 Subject: devdraw: avoid deadlock in x11 resize Fixes #347. --- src/cmd/devdraw/x11-inc.h | 1 + src/cmd/devdraw/x11-screen.c | 2 ++ 2 files changed, 3 insertions(+) (limited to 'src/cmd/devdraw') diff --git a/src/cmd/devdraw/x11-inc.h b/src/cmd/devdraw/x11-inc.h index dca3ebcd..ab4c2505 100644 --- a/src/cmd/devdraw/x11-inc.h +++ b/src/cmd/devdraw/x11-inc.h @@ -17,6 +17,7 @@ #include #include #ifdef SHOWEVENT +#include #include "../rio/showevent/ShowEvent.c" #endif diff --git a/src/cmd/devdraw/x11-screen.c b/src/cmd/devdraw/x11-screen.c index d01e8496..62f49f2f 100644 --- a/src/cmd/devdraw/x11-screen.c +++ b/src/cmd/devdraw/x11-screen.c @@ -1042,7 +1042,9 @@ _xreplacescreenimage(Client *client) w->nextscreenpm = pixmap; w->screenr = r; client->mouserect = r; + xunlock(); gfx_replacescreenimage(client, m); + xlock(); return 1; } -- cgit v1.2.3 From 1d0d432ccb000b28de3309db5f8299357a46c903 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 16 Jan 2020 12:07:42 -0500 Subject: devdraw: abort alt sequence on window change on macOS Fixes #3. --- src/cmd/devdraw/mac-screen.m | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/cmd/devdraw') diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index 4bc3f088..dedbfb84 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -560,6 +560,10 @@ rpc_resizewindow(Client *c, Rectangle r) [self sendmouse:0]; } +- (void)windowDidResignKey:(id)arg { + gfx_abortcompose(self.client); +} + - (void)mouseMoved:(NSEvent*)e{ [self getmouse:e];} - (void)mouseDown:(NSEvent*)e{ [self getmouse:e];} - (void)mouseDragged:(NSEvent*)e{ [self getmouse:e];} -- cgit v1.2.3 From f66f0a587b48337388296c8f1820f9b3dbfd0085 Mon Sep 17 00:00:00 2001 From: Martin Palma Date: Mon, 3 Feb 2020 20:59:58 +0100 Subject: devdraw: fix `cmd-r` to toggle retina vs. non-retina mode on macOS (#361) and not unexpectedly quitting an application. Fixes #360 --- src/cmd/devdraw/mac-screen.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/cmd/devdraw') diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index dedbfb84..c6e58341 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -510,7 +510,7 @@ void rpc_resizeimg(Client *c) { DrawView *view = (__bridge DrawView*)c->view; - dispatch_sync(dispatch_get_main_queue(), ^(void){ + dispatch_async(dispatch_get_main_queue(), ^(void){ [view resizeimg]; }); } -- cgit v1.2.3