2018-03-20 10:40:08 +00:00
|
|
|
/* GdkQuartzSurface.m
|
2005-11-22 10:03:32 +00:00
|
|
|
*
|
2007-06-16 15:41:27 +00:00
|
|
|
* Copyright (C) 2005-2007 Imendio AB
|
2005-11-22 10:03:32 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2005-11-22 10:03:32 +00:00
|
|
|
*/
|
|
|
|
|
2018-02-27 18:53:43 +00:00
|
|
|
#include "config.h"
|
2010-12-24 19:25:40 +00:00
|
|
|
#import "GdkQuartzNSWindow.h"
|
2018-03-20 10:46:11 +00:00
|
|
|
#include "gdkquartzsurface.h"
|
2010-12-23 11:59:26 +00:00
|
|
|
#include "gdkdnd-quartz.h"
|
2005-11-22 10:03:32 +00:00
|
|
|
#include "gdkprivate-quartz.h"
|
|
|
|
|
2010-12-22 15:55:56 +00:00
|
|
|
@implementation GdkQuartzNSWindow
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2016-02-22 00:22:27 +00:00
|
|
|
- (void)windowWillClose:(NSNotification*)notification
|
|
|
|
{
|
|
|
|
// Clears the delegate when window is going to be closed; since EL
|
|
|
|
// Capitan it is possible that the methods of delegate would get
|
|
|
|
// called after the window has been closed.
|
|
|
|
[self setDelegate:nil];
|
|
|
|
}
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
-(BOOL)windowShouldClose:(id)sender
|
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *window = [[self contentView] gdkSurface];
|
2005-11-22 10:03:32 +00:00
|
|
|
GdkEvent *event;
|
|
|
|
|
|
|
|
event = gdk_event_new (GDK_DELETE);
|
|
|
|
|
2018-03-20 15:25:50 +00:00
|
|
|
event->any.surface = g_object_ref (window);
|
2005-11-22 10:03:32 +00:00
|
|
|
event->any.send_event = FALSE;
|
|
|
|
|
|
|
|
_gdk_event_queue_append (gdk_display_get_default (), event);
|
|
|
|
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2007-07-06 19:49:42 +00:00
|
|
|
-(void)windowWillMiniaturize:(NSNotification *)aNotification
|
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *window = [[self contentView] gdkSurface];
|
2007-07-06 19:49:42 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_quartz_surface_detach_from_parent (window);
|
2007-07-06 19:49:42 +00:00
|
|
|
}
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
-(void)windowDidMiniaturize:(NSNotification *)aNotification
|
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *window = [[self contentView] gdkSurface];
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2019-11-16 19:50:57 +00:00
|
|
|
gdk_synthesize_surface_state (window, 0, GDK_SURFACE_STATE_MINIMIZED);
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)windowDidDeminiaturize:(NSNotification *)aNotification
|
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *window = [[self contentView] gdkSurface];
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_quartz_surface_attach_to_parent (window);
|
2007-07-06 19:49:42 +00:00
|
|
|
|
2019-11-16 19:50:57 +00:00
|
|
|
gdk_synthesize_surface_state (window, GDK_SURFACE_STATE_MINIMIZED, 0);
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)windowDidBecomeKey:(NSNotification *)aNotification
|
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *window = [[self contentView] gdkSurface];
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
gdk_synthesize_surface_state (window, 0, GDK_SURFACE_STATE_FOCUSED);
|
2007-04-06 21:12:48 +00:00
|
|
|
_gdk_quartz_events_update_focus_window (window, TRUE);
|
2006-07-19 17:06:40 +00:00
|
|
|
}
|
|
|
|
|
2006-07-24 10:46:21 +00:00
|
|
|
-(void)windowDidResignKey:(NSNotification *)aNotification
|
2006-07-19 17:06:40 +00:00
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *window = [[self contentView] gdkSurface];
|
2006-07-19 17:06:40 +00:00
|
|
|
|
2007-04-06 21:12:48 +00:00
|
|
|
_gdk_quartz_events_update_focus_window (window, FALSE);
|
2018-03-20 11:05:26 +00:00
|
|
|
gdk_synthesize_surface_state (window, GDK_SURFACE_STATE_FOCUSED, 0);
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
2007-07-07 16:19:40 +00:00
|
|
|
-(void)windowDidBecomeMain:(NSNotification *)aNotification
|
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *window = [[self contentView] gdkSurface];
|
2008-02-24 17:51:22 +00:00
|
|
|
|
|
|
|
if (![self isVisible])
|
|
|
|
{
|
|
|
|
/* Note: This is a hack needed because for unknown reasons, hidden
|
|
|
|
* windows get shown when clicking the dock icon when the application
|
|
|
|
* is not already active.
|
|
|
|
*/
|
|
|
|
[self orderOut:nil];
|
|
|
|
return;
|
|
|
|
}
|
2007-07-07 16:19:40 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_quartz_surface_did_become_main (window);
|
2007-07-07 16:19:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)windowDidResignMain:(NSNotification *)aNotification
|
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurface *window;
|
2007-07-07 16:19:40 +00:00
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
window = [[self contentView] gdkSurface];
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_quartz_surface_did_resign_main (window);
|
2007-07-07 16:19:40 +00:00
|
|
|
}
|
|
|
|
|
2007-06-16 15:41:27 +00:00
|
|
|
/* Used in combination with NSLeftMouseUp in sendEvent to keep track
|
|
|
|
* of when the window is being moved with the mouse.
|
|
|
|
*/
|
|
|
|
-(void)windowWillMove:(NSNotification *)aNotification
|
|
|
|
{
|
2007-11-03 09:52:34 +00:00
|
|
|
inMove = YES;
|
2007-06-16 15:41:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)sendEvent:(NSEvent *)event
|
|
|
|
{
|
|
|
|
switch ([event type])
|
|
|
|
{
|
|
|
|
case NSLeftMouseUp:
|
2012-02-19 15:08:26 +00:00
|
|
|
{
|
|
|
|
double time = ((double)[event timestamp]) * 1000.0;
|
|
|
|
|
|
|
|
_gdk_quartz_events_break_all_grabs (time);
|
2007-10-31 11:01:56 +00:00
|
|
|
inManualMove = NO;
|
|
|
|
inManualResize = NO;
|
2007-11-03 09:52:34 +00:00
|
|
|
inMove = NO;
|
2007-10-31 11:01:56 +00:00
|
|
|
break;
|
2012-02-19 15:08:26 +00:00
|
|
|
}
|
2007-10-31 11:01:56 +00:00
|
|
|
|
|
|
|
case NSLeftMouseDragged:
|
|
|
|
if ([self trackManualMove] || [self trackManualResize])
|
|
|
|
return;
|
2007-06-16 15:41:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
[super sendEvent:event];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(BOOL)isInMove
|
|
|
|
{
|
|
|
|
return inMove;
|
|
|
|
}
|
|
|
|
|
2012-11-20 09:28:58 +00:00
|
|
|
-(void)checkSendEnterNotify
|
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *window = [[self contentView] gdkSurface];
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplQuartz *impl = GDK_SURFACE_IMPL_QUARTZ (window->impl);
|
2012-11-20 09:28:58 +00:00
|
|
|
|
|
|
|
/* When a new window has been created, and the mouse
|
|
|
|
* is in the window area, we will not receive an NSMouseEntered
|
|
|
|
* event. Therefore, we synthesize an enter notify event manually.
|
|
|
|
*/
|
|
|
|
if (!initialPositionKnown)
|
|
|
|
{
|
|
|
|
initialPositionKnown = YES;
|
|
|
|
|
|
|
|
if (NSPointInRect ([NSEvent mouseLocation], [self frame]))
|
|
|
|
{
|
|
|
|
NSEvent *event;
|
|
|
|
|
|
|
|
event = [NSEvent enterExitEventWithType: NSMouseEntered
|
|
|
|
location: [self mouseLocationOutsideOfEventStream]
|
|
|
|
modifierFlags: 0
|
|
|
|
timestamp: [[NSApp currentEvent] timestamp]
|
|
|
|
windowNumber: [impl->toplevel windowNumber]
|
|
|
|
context: NULL
|
|
|
|
eventNumber: 0
|
|
|
|
trackingNumber: [impl->view trackingRect]
|
|
|
|
userData: nil];
|
|
|
|
|
|
|
|
[NSApp postEvent:event atStart:NO];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-21 07:36:54 +00:00
|
|
|
-(void)windowDidMove:(NSNotification *)aNotification
|
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *window = [[self contentView] gdkSurface];
|
2006-03-21 07:36:54 +00:00
|
|
|
GdkEvent *event;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplQuartz *impl = GDK_SURFACE_IMPL_QUARTZ (window->impl);
|
|
|
|
gboolean maximized = gdk_surface_get_state (window) & GDK_SURFACE_STATE_MAXIMIZED;
|
2015-07-20 08:40:35 +00:00
|
|
|
|
|
|
|
/* In case the window is changed when maximized remove the maximized state */
|
|
|
|
if (maximized && !inMaximizeTransition && !NSEqualRects (lastMaximizedFrame, [self frame]))
|
|
|
|
{
|
2018-03-20 11:05:26 +00:00
|
|
|
gdk_synthesize_surface_state (window,
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_SURFACE_STATE_MAXIMIZED,
|
2015-07-20 08:40:35 +00:00
|
|
|
0);
|
|
|
|
}
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_quartz_surface_update_position (window);
|
2006-03-21 07:36:54 +00:00
|
|
|
|
|
|
|
/* Synthesize a configure event */
|
|
|
|
event = gdk_event_new (GDK_CONFIGURE);
|
|
|
|
event->configure.window = g_object_ref (window);
|
2010-12-06 13:13:40 +00:00
|
|
|
event->configure.x = window->x;
|
|
|
|
event->configure.y = window->y;
|
|
|
|
event->configure.width = window->width;
|
|
|
|
event->configure.height = window->height;
|
2006-03-21 07:36:54 +00:00
|
|
|
|
|
|
|
_gdk_event_queue_append (gdk_display_get_default (), event);
|
2012-11-20 09:28:58 +00:00
|
|
|
|
|
|
|
[self checkSendEnterNotify];
|
2006-03-21 07:36:54 +00:00
|
|
|
}
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
-(void)windowDidResize:(NSNotification *)aNotification
|
|
|
|
{
|
|
|
|
NSRect content_rect = [self contentRectForFrameRect:[self frame]];
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *window = [[self contentView] gdkSurface];
|
2005-11-22 10:03:32 +00:00
|
|
|
GdkEvent *event;
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplQuartz *impl = GDK_SURFACE_IMPL_QUARTZ (window->impl);
|
|
|
|
gboolean maximized = gdk_surface_get_state (window) & GDK_SURFACE_STATE_MAXIMIZED;
|
2015-07-20 08:40:35 +00:00
|
|
|
|
|
|
|
/* see same in windowDidMove */
|
|
|
|
if (maximized && !inMaximizeTransition && !NSEqualRects (lastMaximizedFrame, [self frame]))
|
|
|
|
{
|
2018-03-20 11:05:26 +00:00
|
|
|
gdk_synthesize_surface_state (window,
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_SURFACE_STATE_MAXIMIZED,
|
2015-07-20 08:40:35 +00:00
|
|
|
0);
|
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
window->width = content_rect.size.width;
|
|
|
|
window->height = content_rect.size.height;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2011-10-08 09:47:11 +00:00
|
|
|
/* Certain resize operations (e.g. going fullscreen), also move the
|
|
|
|
* origin of the window.
|
|
|
|
*/
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_quartz_surface_update_position (window);
|
2011-10-08 09:47:11 +00:00
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
[[self contentView] setFrame:NSMakeRect (0, 0, window->width, window->height)];
|
2007-06-30 08:56:50 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_surface_update_size (window);
|
2009-01-07 20:26:55 +00:00
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
/* Synthesize a configure event */
|
|
|
|
event = gdk_event_new (GDK_CONFIGURE);
|
|
|
|
event->configure.window = g_object_ref (window);
|
2010-12-06 13:13:40 +00:00
|
|
|
event->configure.x = window->x;
|
|
|
|
event->configure.y = window->y;
|
|
|
|
event->configure.width = window->width;
|
|
|
|
event->configure.height = window->height;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
_gdk_event_queue_append (gdk_display_get_default (), event);
|
2012-11-20 09:28:58 +00:00
|
|
|
|
|
|
|
[self checkSendEnterNotify];
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
2009-12-27 21:56:52 +00:00
|
|
|
-(id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag screen:(NSScreen *)screen
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
|
|
|
self = [super initWithContentRect:contentRect
|
|
|
|
styleMask:styleMask
|
|
|
|
backing:backingType
|
2009-10-25 20:36:56 +00:00
|
|
|
defer:flag
|
|
|
|
screen:screen];
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
[self setAcceptsMouseMovedEvents:YES];
|
|
|
|
[self setDelegate:self];
|
|
|
|
[self setReleasedWhenClosed:YES];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2006-01-02 16:34:21 +00:00
|
|
|
-(BOOL)canBecomeMainWindow
|
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *window = [[self contentView] gdkSurface];
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplQuartz *impl = GDK_SURFACE_IMPL_QUARTZ (window->impl);
|
2006-07-19 09:13:24 +00:00
|
|
|
|
|
|
|
switch (impl->type_hint)
|
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_TYPE_HINT_NORMAL:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_DIALOG:
|
2006-07-19 09:13:24 +00:00
|
|
|
return YES;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_TYPE_HINT_MENU:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_TOOLBAR:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_SPLASHSCREEN:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_UTILITY:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_DOCK:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_DESKTOP:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_DROPDOWN_MENU:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_POPUP_MENU:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_TOOLTIP:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_NOTIFICATION:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_COMBO:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_DND:
|
2006-07-19 09:13:24 +00:00
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2006-01-02 16:34:21 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(BOOL)canBecomeKeyWindow
|
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *window = [[self contentView] gdkSurface];
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplQuartz *impl = GDK_SURFACE_IMPL_QUARTZ (window->impl);
|
2006-07-19 09:13:24 +00:00
|
|
|
|
2010-12-06 13:13:40 +00:00
|
|
|
if (!window->accept_focus)
|
2007-06-04 20:45:30 +00:00
|
|
|
return NO;
|
|
|
|
|
2007-06-06 08:21:14 +00:00
|
|
|
/* Popup windows should not be able to get focused in the window
|
|
|
|
* manager sense, it's only handled through grabs.
|
2006-07-29 11:05:15 +00:00
|
|
|
*/
|
2018-03-20 11:05:26 +00:00
|
|
|
if (window->surface_type == GDK_SURFACE_TEMP)
|
2006-07-29 11:05:15 +00:00
|
|
|
return NO;
|
|
|
|
|
2006-07-19 09:13:24 +00:00
|
|
|
switch (impl->type_hint)
|
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_TYPE_HINT_NORMAL:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_DIALOG:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_MENU:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_TOOLBAR:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_UTILITY:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_DOCK:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_DESKTOP:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_DROPDOWN_MENU:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_POPUP_MENU:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_COMBO:
|
2006-07-19 09:13:24 +00:00
|
|
|
return YES;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
case GDK_SURFACE_TYPE_HINT_SPLASHSCREEN:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_TOOLTIP:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_NOTIFICATION:
|
|
|
|
case GDK_SURFACE_TYPE_HINT_DND:
|
2006-07-19 09:13:24 +00:00
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2006-01-02 16:34:21 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2008-01-10 19:35:53 +00:00
|
|
|
- (void)showAndMakeKey:(BOOL)makeKey
|
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *window = [[self contentView] gdkSurface];
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplQuartz *impl = GDK_SURFACE_IMPL_QUARTZ (window->impl);
|
2008-01-10 19:35:53 +00:00
|
|
|
|
|
|
|
inShowOrHide = YES;
|
|
|
|
|
|
|
|
if (makeKey)
|
|
|
|
[impl->toplevel makeKeyAndOrderFront:impl->toplevel];
|
|
|
|
else
|
|
|
|
[impl->toplevel orderFront:nil];
|
|
|
|
|
|
|
|
inShowOrHide = NO;
|
2012-11-20 09:28:58 +00:00
|
|
|
|
|
|
|
[self checkSendEnterNotify];
|
2008-01-10 19:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)hide
|
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *window = [[self contentView] gdkSurface];
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplQuartz *impl = GDK_SURFACE_IMPL_QUARTZ (window->impl);
|
2008-01-10 19:35:53 +00:00
|
|
|
|
|
|
|
inShowOrHide = YES;
|
|
|
|
[impl->toplevel orderOut:nil];
|
|
|
|
inShowOrHide = NO;
|
2012-11-20 09:28:58 +00:00
|
|
|
|
|
|
|
initialPositionKnown = NO;
|
2008-01-10 19:35:53 +00:00
|
|
|
}
|
|
|
|
|
2007-10-31 11:01:56 +00:00
|
|
|
- (BOOL)trackManualMove
|
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *window = [[self contentView] gdkSurface];
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplQuartz *impl = GDK_SURFACE_IMPL_QUARTZ (window->impl);
|
2007-10-31 11:01:56 +00:00
|
|
|
NSPoint currentLocation;
|
|
|
|
NSPoint newOrigin;
|
|
|
|
NSRect screenFrame = [[NSScreen mainScreen] visibleFrame];
|
|
|
|
NSRect windowFrame = [self frame];
|
|
|
|
|
|
|
|
if (!inManualMove)
|
|
|
|
return NO;
|
|
|
|
|
|
|
|
currentLocation = [self convertBaseToScreen:[self mouseLocationOutsideOfEventStream]];
|
|
|
|
newOrigin.x = currentLocation.x - initialMoveLocation.x;
|
|
|
|
newOrigin.y = currentLocation.y - initialMoveLocation.y;
|
|
|
|
|
|
|
|
/* Clamp vertical position to below the menu bar. */
|
2013-12-13 04:31:52 +00:00
|
|
|
if (newOrigin.y + windowFrame.size.height - impl->shadow_top > screenFrame.origin.y + screenFrame.size.height)
|
|
|
|
newOrigin.y = screenFrame.origin.y + screenFrame.size.height - windowFrame.size.height + impl->shadow_top;
|
2007-10-31 11:01:56 +00:00
|
|
|
|
|
|
|
[self setFrameOrigin:newOrigin];
|
|
|
|
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2013-12-13 01:18:01 +00:00
|
|
|
/* Used by gdkevents-quartz.c to decide if our sendEvent() handler above
|
|
|
|
* will see the event or if it will be subjected to standard processing
|
|
|
|
* by GDK.
|
|
|
|
*/
|
|
|
|
-(BOOL)isInManualResizeOrMove
|
2012-02-19 15:08:26 +00:00
|
|
|
{
|
2013-12-13 01:18:01 +00:00
|
|
|
return inManualResize || inManualMove;
|
2012-02-19 15:08:26 +00:00
|
|
|
}
|
|
|
|
|
2007-10-31 11:01:56 +00:00
|
|
|
-(void)beginManualMove
|
|
|
|
{
|
|
|
|
NSRect frame = [self frame];
|
|
|
|
|
|
|
|
if (inMove || inManualMove || inManualResize)
|
|
|
|
return;
|
|
|
|
|
|
|
|
inManualMove = YES;
|
|
|
|
|
|
|
|
initialMoveLocation = [self convertBaseToScreen:[self mouseLocationOutsideOfEventStream]];
|
|
|
|
initialMoveLocation.x -= frame.origin.x;
|
|
|
|
initialMoveLocation.y -= frame.origin.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)trackManualResize
|
|
|
|
{
|
2015-08-06 19:36:57 +00:00
|
|
|
NSPoint mouse_location;
|
|
|
|
NSRect new_frame;
|
|
|
|
float mdx, mdy, dw, dh, dx, dy;
|
2007-10-31 11:01:56 +00:00
|
|
|
NSSize min_size;
|
|
|
|
|
2007-12-20 13:25:37 +00:00
|
|
|
if (!inManualResize || inTrackManualResize)
|
2007-10-31 11:01:56 +00:00
|
|
|
return NO;
|
|
|
|
|
2007-12-20 13:25:37 +00:00
|
|
|
inTrackManualResize = YES;
|
|
|
|
|
2015-08-06 19:36:57 +00:00
|
|
|
mouse_location = [self convertBaseToScreen:[self mouseLocationOutsideOfEventStream]];
|
|
|
|
mdx = initialResizeLocation.x - mouse_location.x;
|
|
|
|
mdy = initialResizeLocation.y - mouse_location.y;
|
2007-10-31 11:01:56 +00:00
|
|
|
|
2015-08-06 19:36:57 +00:00
|
|
|
/* Set how a mouse location delta translates to changes in width,
|
|
|
|
* height and position.
|
|
|
|
*/
|
|
|
|
dw = dh = dx = dy = 0.0;
|
2018-03-20 10:40:08 +00:00
|
|
|
if (resizeEdge == GDK_SURFACE_EDGE_EAST ||
|
|
|
|
resizeEdge == GDK_SURFACE_EDGE_NORTH_EAST ||
|
|
|
|
resizeEdge == GDK_SURFACE_EDGE_SOUTH_EAST)
|
2015-08-06 19:36:57 +00:00
|
|
|
{
|
|
|
|
dw = -1.0;
|
|
|
|
}
|
2018-03-20 10:40:08 +00:00
|
|
|
if (resizeEdge == GDK_SURFACE_EDGE_NORTH ||
|
|
|
|
resizeEdge == GDK_SURFACE_EDGE_NORTH_WEST ||
|
|
|
|
resizeEdge == GDK_SURFACE_EDGE_NORTH_EAST)
|
2015-08-06 19:36:57 +00:00
|
|
|
{
|
|
|
|
dh = -1.0;
|
|
|
|
}
|
2018-03-20 10:40:08 +00:00
|
|
|
if (resizeEdge == GDK_SURFACE_EDGE_SOUTH ||
|
|
|
|
resizeEdge == GDK_SURFACE_EDGE_SOUTH_WEST ||
|
|
|
|
resizeEdge == GDK_SURFACE_EDGE_SOUTH_EAST)
|
2015-08-06 19:36:57 +00:00
|
|
|
{
|
|
|
|
dh = 1.0;
|
|
|
|
dy = -1.0;
|
|
|
|
}
|
2018-03-20 10:40:08 +00:00
|
|
|
if (resizeEdge == GDK_SURFACE_EDGE_WEST ||
|
|
|
|
resizeEdge == GDK_SURFACE_EDGE_NORTH_WEST ||
|
|
|
|
resizeEdge == GDK_SURFACE_EDGE_SOUTH_WEST)
|
2015-08-06 19:36:57 +00:00
|
|
|
{
|
|
|
|
dw = 1.0;
|
|
|
|
dx = -1.0;
|
|
|
|
}
|
2007-10-31 11:01:56 +00:00
|
|
|
|
2015-08-06 19:36:57 +00:00
|
|
|
/* Apply changes to the frame captured when we started resizing */
|
|
|
|
new_frame = initialResizeFrame;
|
|
|
|
new_frame.origin.x += mdx * dx;
|
|
|
|
new_frame.origin.y += mdy * dy;
|
|
|
|
new_frame.size.width += mdx * dw;
|
|
|
|
new_frame.size.height += mdy * dh;
|
2007-10-31 11:01:56 +00:00
|
|
|
|
2015-08-06 19:36:57 +00:00
|
|
|
/* In case the resulting window would be too small reduce the
|
|
|
|
* change to both size and position.
|
|
|
|
*/
|
2007-10-31 11:01:56 +00:00
|
|
|
min_size = [self contentMinSize];
|
|
|
|
|
2015-08-06 19:36:57 +00:00
|
|
|
if (new_frame.size.width < min_size.width)
|
|
|
|
{
|
|
|
|
if (dx)
|
|
|
|
new_frame.origin.x -= min_size.width - new_frame.size.width;
|
|
|
|
new_frame.size.width = min_size.width;
|
|
|
|
}
|
2007-10-31 11:01:56 +00:00
|
|
|
|
2015-08-06 19:36:57 +00:00
|
|
|
if (new_frame.size.height < min_size.height)
|
|
|
|
{
|
|
|
|
if (dy)
|
|
|
|
new_frame.origin.y -= min_size.height - new_frame.size.height;
|
|
|
|
new_frame.size.height = min_size.height;
|
|
|
|
}
|
2007-10-31 11:01:56 +00:00
|
|
|
|
2015-08-06 19:36:57 +00:00
|
|
|
/* We could also apply aspect ratio:
|
|
|
|
new_frame.size.height = new_frame.size.width / [self aspectRatio].width * [self aspectRatio].height;
|
|
|
|
*/
|
2007-10-31 11:01:56 +00:00
|
|
|
|
2015-08-06 19:36:57 +00:00
|
|
|
[self setFrame:new_frame display:YES];
|
2007-10-31 11:01:56 +00:00
|
|
|
|
2007-12-20 13:25:37 +00:00
|
|
|
/* Let the resizing be handled by GTK+. */
|
|
|
|
if (g_main_context_pending (NULL))
|
|
|
|
g_main_context_iteration (NULL, FALSE);
|
|
|
|
|
|
|
|
inTrackManualResize = NO;
|
|
|
|
|
2007-10-31 11:01:56 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
-(void)beginManualResize:(GdkSurfaceEdge)edge
|
2007-10-31 11:01:56 +00:00
|
|
|
{
|
|
|
|
if (inMove || inManualMove || inManualResize)
|
|
|
|
return;
|
|
|
|
|
|
|
|
inManualResize = YES;
|
2015-08-06 19:36:57 +00:00
|
|
|
resizeEdge = edge;
|
2007-10-31 11:01:56 +00:00
|
|
|
|
|
|
|
initialResizeFrame = [self frame];
|
|
|
|
initialResizeLocation = [self convertBaseToScreen:[self mouseLocationOutsideOfEventStream]];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-17 10:11:11 +00:00
|
|
|
|
2006-03-21 08:02:17 +00:00
|
|
|
static GdkDragContext *current_context = NULL;
|
|
|
|
|
|
|
|
static GdkDragAction
|
|
|
|
drag_operation_to_drag_action (NSDragOperation operation)
|
|
|
|
{
|
|
|
|
GdkDragAction result = 0;
|
|
|
|
|
2009-09-30 13:07:37 +00:00
|
|
|
/* GDK and Quartz drag operations do not map 1:1.
|
|
|
|
* This mapping represents about the best that we
|
|
|
|
* can come up.
|
|
|
|
*/
|
|
|
|
|
2006-03-21 08:02:17 +00:00
|
|
|
if (operation & NSDragOperationGeneric)
|
2009-09-30 13:07:37 +00:00
|
|
|
result |= GDK_ACTION_MOVE;
|
|
|
|
if (operation & NSDragOperationCopy)
|
2006-03-21 08:02:17 +00:00
|
|
|
result |= GDK_ACTION_COPY;
|
2009-09-30 13:07:37 +00:00
|
|
|
if (operation & NSDragOperationMove)
|
|
|
|
result |= GDK_ACTION_MOVE;
|
|
|
|
if (operation & NSDragOperationLink)
|
|
|
|
result |= GDK_ACTION_LINK;
|
2006-03-21 08:02:17 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static NSDragOperation
|
|
|
|
drag_action_to_drag_operation (GdkDragAction action)
|
|
|
|
{
|
|
|
|
NSDragOperation result = 0;
|
|
|
|
|
|
|
|
if (action & GDK_ACTION_COPY)
|
|
|
|
result |= NSDragOperationCopy;
|
2009-09-30 13:07:37 +00:00
|
|
|
if (action & GDK_ACTION_LINK)
|
|
|
|
result |= NSDragOperationLink;
|
|
|
|
if (action & GDK_ACTION_MOVE)
|
|
|
|
result |= NSDragOperationMove;
|
2006-03-21 08:02:17 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
update_context_from_dragging_info (id <NSDraggingInfo> sender)
|
|
|
|
{
|
2018-05-13 15:03:57 +00:00
|
|
|
GdkDragAction action;
|
|
|
|
|
2006-03-21 08:02:17 +00:00
|
|
|
g_assert (current_context != NULL);
|
|
|
|
|
2010-12-22 12:32:14 +00:00
|
|
|
GDK_QUARTZ_DRAG_CONTEXT (current_context)->dragging_info = sender;
|
2018-05-13 15:03:57 +00:00
|
|
|
action = drag_operation_to_drag_action ([sender draggingSourceOperationMask]);
|
|
|
|
gdk_drag_context_set_actions (current_context, action, action);
|
2006-03-21 08:02:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
|
|
|
|
{
|
2010-06-30 08:56:10 +00:00
|
|
|
GdkEvent *event;
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurface *window;
|
2006-03-21 08:02:17 +00:00
|
|
|
|
|
|
|
if (current_context)
|
|
|
|
g_object_unref (current_context);
|
2016-11-05 22:03:54 +00:00
|
|
|
|
2018-04-27 10:32:17 +00:00
|
|
|
current_context = g_object_new (GDK_TYPE_QUARTZ_DRAG_CONTEXT,
|
|
|
|
"device", gdk_seat_get_pointer (gdk_display_get_default_seat (current_context->display)),
|
|
|
|
NULL);
|
2006-03-21 08:02:17 +00:00
|
|
|
update_context_from_dragging_info (sender);
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
window = [[self contentView] gdkSurface];
|
2010-06-30 08:56:10 +00:00
|
|
|
|
|
|
|
event = gdk_event_new (GDK_DRAG_ENTER);
|
|
|
|
event->dnd.window = g_object_ref (window);
|
|
|
|
event->dnd.send_event = FALSE;
|
|
|
|
event->dnd.context = g_object_ref (current_context);
|
|
|
|
event->dnd.time = GDK_CURRENT_TIME;
|
|
|
|
|
|
|
|
gdk_event_set_device (event, gdk_drag_context_get_device (current_context));
|
2015-12-14 14:44:15 +00:00
|
|
|
gdk_event_set_seat (event, gdk_device_get_seat (gdk_drag_context_get_device (current_context)));
|
2010-06-30 08:56:10 +00:00
|
|
|
|
2010-12-02 09:59:37 +00:00
|
|
|
_gdk_event_emit (event);
|
2010-06-30 08:56:10 +00:00
|
|
|
|
2018-05-29 19:53:44 +00:00
|
|
|
g_object_unref (event);
|
2006-03-21 08:02:17 +00:00
|
|
|
|
|
|
|
return NSDragOperationNone;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)draggingEnded:(id <NSDraggingInfo>)sender
|
|
|
|
{
|
2009-09-30 13:07:37 +00:00
|
|
|
/* leave a note for the source about what action was taken */
|
|
|
|
if (_gdk_quartz_drag_source_context && current_context)
|
|
|
|
_gdk_quartz_drag_source_context->action = current_context->action;
|
|
|
|
|
2007-11-01 08:45:30 +00:00
|
|
|
if (current_context)
|
|
|
|
g_object_unref (current_context);
|
2006-03-21 08:02:17 +00:00
|
|
|
current_context = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)draggingExited:(id <NSDraggingInfo>)sender
|
|
|
|
{
|
2010-06-30 08:56:10 +00:00
|
|
|
GdkEvent *event;
|
2006-03-21 08:02:17 +00:00
|
|
|
|
2010-06-30 08:56:10 +00:00
|
|
|
event = gdk_event_new (GDK_DRAG_LEAVE);
|
2018-03-21 10:49:14 +00:00
|
|
|
event->dnd.window = g_object_ref ([[self contentView] gdkSurface]);
|
2010-06-30 08:56:10 +00:00
|
|
|
event->dnd.send_event = FALSE;
|
|
|
|
event->dnd.context = g_object_ref (current_context);
|
|
|
|
event->dnd.time = GDK_CURRENT_TIME;
|
2006-03-21 08:02:17 +00:00
|
|
|
|
2010-06-30 08:56:10 +00:00
|
|
|
gdk_event_set_device (event, gdk_drag_context_get_device (current_context));
|
2015-12-14 14:44:15 +00:00
|
|
|
gdk_event_set_seat (event, gdk_device_get_seat (gdk_drag_context_get_device (current_context)));
|
2010-06-30 08:56:10 +00:00
|
|
|
|
2010-12-02 09:59:37 +00:00
|
|
|
_gdk_event_emit (event);
|
2010-06-30 08:56:10 +00:00
|
|
|
|
2018-05-29 19:53:44 +00:00
|
|
|
g_object_unref (event);
|
2006-03-21 08:02:17 +00:00
|
|
|
|
|
|
|
g_object_unref (current_context);
|
|
|
|
current_context = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
|
|
|
|
{
|
|
|
|
NSPoint point = [sender draggingLocation];
|
|
|
|
NSPoint screen_point = [self convertBaseToScreen:point];
|
2010-06-30 08:56:10 +00:00
|
|
|
GdkEvent *event;
|
2009-10-25 20:36:56 +00:00
|
|
|
int gx, gy;
|
2006-03-21 08:02:17 +00:00
|
|
|
|
|
|
|
update_context_from_dragging_info (sender);
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_quartz_surface_nspoint_to_gdk_xy (screen_point, &gx, &gy);
|
2006-03-21 08:02:17 +00:00
|
|
|
|
2010-06-30 08:56:10 +00:00
|
|
|
event = gdk_event_new (GDK_DRAG_MOTION);
|
2018-03-21 10:49:14 +00:00
|
|
|
event->dnd.window = g_object_ref ([[self contentView] gdkSurface]);
|
2010-06-30 08:56:10 +00:00
|
|
|
event->dnd.send_event = FALSE;
|
|
|
|
event->dnd.context = g_object_ref (current_context);
|
|
|
|
event->dnd.time = GDK_CURRENT_TIME;
|
|
|
|
event->dnd.x_root = gx;
|
|
|
|
event->dnd.y_root = gy;
|
|
|
|
|
|
|
|
gdk_event_set_device (event, gdk_drag_context_get_device (current_context));
|
2015-12-14 14:44:15 +00:00
|
|
|
gdk_event_set_seat (event, gdk_device_get_seat (gdk_drag_context_get_device (current_context)));
|
2006-03-21 08:02:17 +00:00
|
|
|
|
2010-12-02 09:59:37 +00:00
|
|
|
_gdk_event_emit (event);
|
2006-03-21 08:02:17 +00:00
|
|
|
|
2018-05-29 19:53:44 +00:00
|
|
|
g_object_unref (event);
|
2006-03-21 08:02:17 +00:00
|
|
|
|
|
|
|
return drag_action_to_drag_operation (current_context->action);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
|
|
|
{
|
|
|
|
NSPoint point = [sender draggingLocation];
|
|
|
|
NSPoint screen_point = [self convertBaseToScreen:point];
|
2010-06-30 08:56:10 +00:00
|
|
|
GdkEvent *event;
|
2009-10-25 20:36:56 +00:00
|
|
|
int gy, gx;
|
2006-03-21 08:02:17 +00:00
|
|
|
|
|
|
|
update_context_from_dragging_info (sender);
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_quartz_surface_nspoint_to_gdk_xy (screen_point, &gx, &gy);
|
2006-03-21 08:02:17 +00:00
|
|
|
|
2010-06-30 08:56:10 +00:00
|
|
|
event = gdk_event_new (GDK_DROP_START);
|
2018-03-21 10:49:14 +00:00
|
|
|
event->dnd.window = g_object_ref ([[self contentView] gdkSurface]);
|
2010-06-30 08:56:10 +00:00
|
|
|
event->dnd.send_event = FALSE;
|
|
|
|
event->dnd.context = g_object_ref (current_context);
|
|
|
|
event->dnd.time = GDK_CURRENT_TIME;
|
|
|
|
event->dnd.x_root = gx;
|
|
|
|
event->dnd.y_root = gy;
|
|
|
|
|
|
|
|
gdk_event_set_device (event, gdk_drag_context_get_device (current_context));
|
2015-12-14 14:44:15 +00:00
|
|
|
gdk_event_set_seat (event, gdk_device_get_seat (gdk_drag_context_get_device (current_context)));
|
2006-03-21 08:02:17 +00:00
|
|
|
|
2010-12-02 09:59:37 +00:00
|
|
|
_gdk_event_emit (event);
|
2006-03-21 08:02:17 +00:00
|
|
|
|
2018-05-29 19:53:44 +00:00
|
|
|
g_object_unref (event);
|
2006-03-21 08:02:17 +00:00
|
|
|
|
|
|
|
g_object_unref (current_context);
|
|
|
|
current_context = NULL;
|
|
|
|
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)wantsPeriodicDraggingUpdates
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation
|
|
|
|
{
|
2010-06-30 08:56:10 +00:00
|
|
|
GdkEvent *event;
|
2017-11-01 00:47:57 +00:00
|
|
|
GdkDisplay *display;
|
2015-12-14 14:44:15 +00:00
|
|
|
GdkDevice *device;
|
2006-03-21 08:02:17 +00:00
|
|
|
|
|
|
|
g_assert (_gdk_quartz_drag_source_context != NULL);
|
|
|
|
|
2010-06-30 08:56:10 +00:00
|
|
|
event = gdk_event_new (GDK_DROP_FINISHED);
|
2018-03-21 10:49:14 +00:00
|
|
|
event->dnd.window = g_object_ref ([[self contentView] gdkSurface]);
|
2010-06-30 08:56:10 +00:00
|
|
|
event->dnd.send_event = FALSE;
|
|
|
|
event->dnd.context = g_object_ref (_gdk_quartz_drag_source_context);
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
display = gdk_surface_get_display (event->dnd.window);
|
2015-07-26 06:04:48 +00:00
|
|
|
|
2017-11-01 00:47:57 +00:00
|
|
|
if (display)
|
2015-07-26 06:04:48 +00:00
|
|
|
{
|
|
|
|
GList* windows, *list;
|
|
|
|
gint gx, gy;
|
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
event->dnd.context->dest_surface = NULL;
|
2015-07-26 06:04:48 +00:00
|
|
|
|
2017-11-05 23:28:27 +00:00
|
|
|
windows = get_toplevels ();
|
2018-03-20 10:40:08 +00:00
|
|
|
_gdk_quartz_surface_nspoint_to_gdk_xy (aPoint, &gx, &gy);
|
2015-07-26 06:04:48 +00:00
|
|
|
|
|
|
|
for (list = windows; list; list = list->next)
|
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurface* win = (GdkSurface*) list->data;
|
2015-07-26 06:04:48 +00:00
|
|
|
gint wx, wy;
|
|
|
|
gint ww, wh;
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_surface_get_root_origin (win, &wx, &wy);
|
|
|
|
ww = gdk_surface_get_width (win);
|
|
|
|
wh = gdk_surface_get_height (win);
|
2015-07-26 06:04:48 +00:00
|
|
|
|
|
|
|
if (gx > wx && gy > wy && gx <= wx + ww && gy <= wy + wh)
|
2018-03-20 11:05:26 +00:00
|
|
|
event->dnd.context->dest_surface = win;
|
2015-07-26 06:04:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-14 14:44:15 +00:00
|
|
|
device = gdk_drag_context_get_device (_gdk_quartz_drag_source_context);
|
|
|
|
gdk_event_set_device (event, device);
|
|
|
|
gdk_event_set_seat (event, gdk_device_get_seat (device));
|
2006-03-21 08:02:17 +00:00
|
|
|
|
2010-12-02 09:59:37 +00:00
|
|
|
_gdk_event_emit (event);
|
2006-03-21 08:02:17 +00:00
|
|
|
|
2018-05-29 19:53:44 +00:00
|
|
|
g_object_unref (event);
|
2006-03-21 08:02:17 +00:00
|
|
|
|
|
|
|
g_object_unref (_gdk_quartz_drag_source_context);
|
|
|
|
_gdk_quartz_drag_source_context = NULL;
|
|
|
|
}
|
|
|
|
|
2014-10-26 11:26:48 +00:00
|
|
|
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
|
|
|
|
|
2014-08-23 14:04:46 +00:00
|
|
|
- (void)setStyleMask:(NSUInteger)styleMask
|
|
|
|
{
|
|
|
|
gboolean was_fullscreen;
|
|
|
|
gboolean is_fullscreen;
|
|
|
|
|
|
|
|
was_fullscreen = (([self styleMask] & NSFullScreenWindowMask) != 0);
|
|
|
|
|
|
|
|
[super setStyleMask:styleMask];
|
|
|
|
|
|
|
|
is_fullscreen = (([self styleMask] & NSFullScreenWindowMask) != 0);
|
|
|
|
|
|
|
|
if (was_fullscreen != is_fullscreen)
|
2018-03-21 10:49:14 +00:00
|
|
|
_gdk_quartz_surface_update_fullscreen_state ([[self contentView] gdkSurface]);
|
2014-08-23 14:04:46 +00:00
|
|
|
}
|
|
|
|
|
2014-10-26 11:26:48 +00:00
|
|
|
#endif
|
|
|
|
|
2015-07-20 06:32:05 +00:00
|
|
|
- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen
|
|
|
|
{
|
|
|
|
NSRect rect;
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *window = [[self contentView] gdkSurface];
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplQuartz *impl = GDK_SURFACE_IMPL_QUARTZ (window->impl);
|
2015-07-20 06:32:05 +00:00
|
|
|
|
|
|
|
/* Allow the window to move up "shadow_top" more than normally allowed
|
|
|
|
* by the default impl. This makes it possible to move windows with
|
|
|
|
* client side shadow right up to the screen's menu bar. */
|
|
|
|
rect = [super constrainFrameRect:frameRect toScreen:screen];
|
|
|
|
if (frameRect.origin.y > rect.origin.y)
|
|
|
|
rect.origin.y = MIN (frameRect.origin.y, rect.origin.y + impl->shadow_top);
|
|
|
|
|
|
|
|
return rect;
|
|
|
|
}
|
|
|
|
|
2015-07-20 07:05:52 +00:00
|
|
|
- (NSRect)windowWillUseStandardFrame:(NSWindow *)nsWindow
|
|
|
|
defaultFrame:(NSRect)newFrame
|
|
|
|
{
|
|
|
|
NSRect screenFrame = [[self screen] visibleFrame];
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *window = [[self contentView] gdkSurface];
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplQuartz *impl = GDK_SURFACE_IMPL_QUARTZ (window->impl);
|
|
|
|
gboolean maximized = gdk_surface_get_state (window) & GDK_SURFACE_STATE_MAXIMIZED;
|
2015-07-20 07:05:52 +00:00
|
|
|
|
|
|
|
if (!maximized)
|
|
|
|
return screenFrame;
|
|
|
|
else
|
|
|
|
return lastUnmaximizedFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)windowShouldZoom:(NSWindow *)nsWindow
|
|
|
|
toFrame:(NSRect)newFrame
|
|
|
|
{
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *window = [[self contentView] gdkSurface];
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurfaceImplQuartz *impl = GDK_SURFACE_IMPL_QUARTZ (window->impl);
|
|
|
|
gboolean maximized = gdk_surface_get_state (window) & GDK_SURFACE_STATE_MAXIMIZED;
|
2015-07-20 07:05:52 +00:00
|
|
|
|
|
|
|
if (maximized)
|
|
|
|
{
|
2015-07-20 08:40:35 +00:00
|
|
|
lastMaximizedFrame = newFrame;
|
2018-03-20 11:05:26 +00:00
|
|
|
gdk_synthesize_surface_state (window,
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_SURFACE_STATE_MAXIMIZED,
|
2015-07-20 07:05:52 +00:00
|
|
|
0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lastUnmaximizedFrame = [nsWindow frame];
|
2018-03-20 11:05:26 +00:00
|
|
|
gdk_synthesize_surface_state (window,
|
2015-07-20 07:05:52 +00:00
|
|
|
0,
|
2018-03-20 10:40:08 +00:00
|
|
|
GDK_SURFACE_STATE_MAXIMIZED);
|
2015-07-20 07:05:52 +00:00
|
|
|
}
|
|
|
|
|
2015-07-20 08:40:35 +00:00
|
|
|
inMaximizeTransition = YES;
|
2015-07-20 07:05:52 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2015-07-20 08:40:35 +00:00
|
|
|
-(void)windowDidEndLiveResize:(NSNotification *)aNotification
|
|
|
|
{
|
|
|
|
inMaximizeTransition = NO;
|
|
|
|
}
|
|
|
|
|
2017-02-28 23:44:33 +00:00
|
|
|
-(NSSize)window:(NSWindow *)window willUseFullScreenContentSize:(NSSize)proposedSize
|
|
|
|
{
|
|
|
|
return [[window screen] frame].size;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)windowWillEnterFullScreen:(NSNotification *)aNotification
|
|
|
|
{
|
|
|
|
lastUnfullscreenFrame = [self frame];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)windowWillExitFullScreen:(NSNotification *)aNotification
|
|
|
|
{
|
2017-03-10 12:09:37 +00:00
|
|
|
[self setFrame:lastUnfullscreenFrame display:YES];
|
2017-02-28 23:44:33 +00:00
|
|
|
}
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
@end
|