浏览代码

Update WS state on orderWindow:

Zoe Knox 1 天之前
父节点
当前提交
dc3fa436ed

+ 1 - 1
CoreServices/WindowServer/WindowServer.m

@@ -405,7 +405,7 @@ pthread_mutex_t renderLock;
     return winrec.number;
 }
 
--(void)windowModify:(struct mach_win_data *)data forApp:(WSAppRecord *)app {
+-(void)windowModify:(struct wsRPCWindow *)data forApp:(WSAppRecord *)app {
     if(data->state < 0 || data->state >= WIN_STATE_MAX) {
         NSLog(@"windowModify called with invalid state");
         data->state = NORMAL;

+ 2 - 0
CoreServices/WindowServer/client.m

@@ -52,6 +52,7 @@
     [v addSubview:iv];
     [v setNeedsDisplay:YES];
 
+#if 0
     win = [[NSWindow alloc] initWithContentRect:NSMakeRect(400, 400, 640, 480)
                                      styleMask:NSTitledWindowMask
                                        backing:NSBackingStoreRetained
@@ -61,6 +62,7 @@
     [[win contentView] addSubview:iv2];
     [[win contentView] setNeedsDisplay:YES];
     [win orderFront:self];
+#endif
     [self makeKeyAndOrderFront:self];
 }
 

+ 0 - 10
CoreServices/WindowServer/message.h

@@ -108,16 +108,6 @@ struct mach_event {
     // FIXME: touch and gesture events
 };
 
-/* Intermediate struct for window management */
-struct mach_win_data {
-    uint32_t windowID;
-    double x, y;
-    double w, h;
-    uint32_t style;
-    uint32_t state;
-    char title[128];
-};
-
 struct mach_activation_data {
     uint32_t windowID;
     uint32_t active;

+ 24 - 11
Frameworks/AppKit/NSWindow.m

@@ -421,13 +421,6 @@ NSString * const NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification
             close(shmfd);
         }
 
-        /* If WS has not created the shared mem yet, buffer will be NULL here. This results
-         * in us creating a surface and context anyway, but they won't be visible on the
-         * screen yet. That's ok - when WS finishes creating the display surface, it will
-         * trigger invalidateContextsWithNewSize: to recreate the context and set the actual
-         * size if it changed from the client's request.
-         */
-
         O2ColorSpaceRef colorSpace = O2ColorSpaceCreateDeviceRGB();
         O2Surface *surface = [[O2Surface alloc] initWithBytes:buffer
                 width:_frame.size.width height:_frame.size.height
@@ -942,7 +935,7 @@ NSString * const NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification
 #endif
 
     //CGLSurfaceResize(_cglContext, size.width, size.height);
-    [_threadToContext removeAllObjects];
+    [_threadToContext performSelectorOnMainThread:@selector(removeAllObjects) withObject:nil waitUntilDone:YES];
 }
 
 -(void) invalidateContextsWithNewSize:(NSSize)size
@@ -2113,6 +2106,7 @@ NSString * const NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification
 
      _isVisible=YES;
      [self displayIfNeeded];
+     [self _updateWSState];
      // this is here since it would seem that doing this any earlier will not work.
      if(![self isKindOfClass:[NSPanel class]] && ![self isExcludedFromWindowsMenu]) {
          [NSApp changeWindowsItem:self title:_title filename:NO];
@@ -2125,6 +2119,7 @@ NSString * const NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification
 
      _isVisible=YES;
      [self displayIfNeeded];
+     [self _updateWSState];
      // this is here since it would seem that doing this any earlier will not work.
      if(![self isKindOfClass:[NSPanel class]] && ![self isExcludedFromWindowsMenu]) {
        [NSApp changeWindowsItem:self title:_title filename:NO];
@@ -2470,7 +2465,6 @@ NSString * const NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification
         else
            [self close];
     }
-
 }
 
 -(void)_document:(NSDocument *)document shouldClose:(BOOL)shouldClose contextInfo:(void *)context
@@ -3250,7 +3244,7 @@ NSString * const NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification
 }
 
 // WindowServer wants us to do something...
--(void)processStateUpdate:(struct mach_win_data *)data {
+-(void)processStateUpdate:(struct wsRPCWindow *)data {
     switch(data->state) {
         case NORMAL:
             [self _setVisible:YES];
@@ -3302,7 +3296,7 @@ NSString * const NSWindowDidAnimateNotification=@"NSWindowDidAnimateNotification
 
 
 -(BOOL)_updateWSState {
-    struct mach_win_data data = {
+    struct wsRPCWindow data = {
         { kWSWindowModifyState, sizeof(struct wsRPCWindow) - sizeof(struct wsRPCBase) },
         _number, _frame.origin.x, _frame.origin.y,
         _frame.size.width, _frame.size.height, _styleMask, 0, {'\0'}
@@ -3327,3 +3321,22 @@ CGRect CGOutsetRectForNativeWindowBorder(CGRect frame,unsigned styleMask) {
     return frame;
 }
 
+void CGNativeBorderFrameWidthsForStyle(unsigned styleMask,CGFloat *top,CGFloat *left,
+                                       CGFloat *bottom,CGFloat *right)
+{
+    switch(styleMask & 0x0FFF) {
+        case NSBorderlessWindowMask:
+            *top=0;
+            *left=0;
+            *bottom=0;
+            *right=0;
+            break;
+        // FIXME: tool window style?
+        default:
+            *top=30;
+            *left=0;
+            *bottom=0;
+            *right=0;
+    }
+}
+