diff options
author | David Jeannot <djeannot24@gmail.com> | 2012-01-16 17:04:28 -0500 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2012-01-16 17:04:28 -0500 |
commit | e89a71ffdd0b8807505db64ece9307f03252da51 (patch) | |
tree | f1e25bf41141324a7648a8d922781420baae1f2a /src/cmd | |
parent | 5ec2425b17766f20600e224b05988dcc7580ea18 (diff) | |
download | plan9port-e89a71ffdd0b8807505db64ece9307f03252da51.tar.gz plan9port-e89a71ffdd0b8807505db64ece9307f03252da51.tar.bz2 plan9port-e89a71ffdd0b8807505db64ece9307f03252da51.zip |
cocoa devdraw: activation on receiving Ttop messages
(The new variable "willactivate" is in the input
structure "in", which is illogical. But this
structure will soon be renamed "app". I postpone
the renaming to avoid conflicts with simultaneous
Codereview issues.)
R=rsc
CC=plan9port.codebot
http://codereview.appspot.com/5504102
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/devdraw/cocoa-screen.h | 1 | ||||
-rw-r--r-- | src/cmd/devdraw/cocoa-screen.m | 16 | ||||
-rw-r--r-- | src/cmd/devdraw/cocoa-srv.c | 2 |
3 files changed, 17 insertions, 2 deletions
diff --git a/src/cmd/devdraw/cocoa-screen.h b/src/cmd/devdraw/cocoa-screen.h index 797b9a58..3c4c94c5 100644 --- a/src/cmd/devdraw/cocoa-screen.h +++ b/src/cmd/devdraw/cocoa-screen.h @@ -6,6 +6,7 @@ void setcursor(Cursor*); void setlabel(char*); char* getsnarf(void); void putsnarf(char*); +void topwin(void); void mousetrack(int, int, int, uint); void keystroke(int); diff --git a/src/cmd/devdraw/cocoa-screen.m b/src/cmd/devdraw/cocoa-screen.m index 4d664059..ae7f5971 100644 --- a/src/cmd/devdraw/cocoa-screen.m +++ b/src/cmd/devdraw/cocoa-screen.m @@ -105,6 +105,7 @@ struct int mscroll; int undo; int touchevent; + int willactivate; } in; static void hidebars(int); @@ -165,6 +166,7 @@ static NSCursor* makecursor(Cursor*); { return YES; } +- (void)applicationDidBecomeActive:(id)arg{ in.willactivate = 0;} - (void)windowDidEnterFullScreen:(id)arg{ win.isnfs = 1; hidebars(1);} - (void)windowWillExitFullScreen:(id)arg{ win.isnfs = 0; hidebars(0);} - (void)windowDidExitFullScreen:(id)arg @@ -1014,7 +1016,7 @@ setmouse(Point p) NSPoint q; NSRect r; - if([NSApp isActive] == 0) + if([NSApp isActive]==0 && in.willactivate==0) return; if(first){ @@ -1282,3 +1284,15 @@ makecursor(Cursor *c) [i release]; return d; } + +void +topwin(void) +{ + [WIN performSelectorOnMainThread: + @selector(makeKeyAndOrderFront:) + withObject:nil + waitUntilDone:NO]; + + in.willactivate = 1; + [NSApp activateIgnoringOtherApps:YES]; +} diff --git a/src/cmd/devdraw/cocoa-srv.c b/src/cmd/devdraw/cocoa-srv.c index 32d83bfc..ac6658ef 100644 --- a/src/cmd/devdraw/cocoa-srv.c +++ b/src/cmd/devdraw/cocoa-srv.c @@ -212,7 +212,7 @@ runmsg(Wsysmsg *m) break; case Ttop: - // _xtopwindow(); + topwin(); replymsg(m); break; |