case NSLeftMouseUp:
leftDown = NO;
inMove = NO;
+ inManualMove = NO;
+ inManualResize = NO;
+ break;
+
+ case NSLeftMouseDragged:
+ if ([self trackManualMove] || [self trackManualResize])
+ return;
break;
default:
return YES;
}
+- (BOOL)trackManualMove
+{
+ 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. */
+ if (newOrigin.y + windowFrame.size.height > screenFrame.origin.y + screenFrame.size.height)
+ newOrigin.y = screenFrame.origin.y + screenFrame.size.height - windowFrame.size.height;
+
+ [self setFrameOrigin:newOrigin];
+
+ return YES;
+}
+
+-(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
+{
+ NSPoint currentLocation;
+ NSRect newFrame;
+ float dx, dy;
+ NSSize min_size;
+
+ if (!inManualResize)
+ return NO;
+
+ currentLocation = [self convertBaseToScreen:[self mouseLocationOutsideOfEventStream]];
+ currentLocation.x -= initialResizeFrame.origin.x;
+ currentLocation.y -= initialResizeFrame.origin.y;
+
+ dx = currentLocation.x - initialResizeLocation.x;
+ dy = -(currentLocation.y - initialResizeLocation.y);
+
+ newFrame = initialResizeFrame;
+ newFrame.size.width = initialResizeFrame.size.width + dx;
+ newFrame.size.height = initialResizeFrame.size.height + dy;
+
+ min_size = [self contentMinSize];
+ if (newFrame.size.width < min_size.width)
+ newFrame.size.width = min_size.width;
+ if (newFrame.size.height < min_size.height)
+ newFrame.size.height = min_size.height;
+
+ /* We could also apply aspect ratio:
+ newFrame.size.height = newFrame.size.width / [self aspectRatio].width * [self aspectRatio].height;
+ */
+
+ dy = newFrame.size.height - initialResizeFrame.size.height;
+
+ newFrame.origin.x = initialResizeFrame.origin.x;
+ newFrame.origin.y = initialResizeFrame.origin.y - dy;
+
+ [self setFrame:newFrame display:YES];
+
+ return YES;
+}
+
+-(void)beginManualResize
+{
+ if (inMove || inManualMove || inManualResize)
+ return;
+
+ inManualResize = YES;
+
+ initialResizeFrame = [self frame];
+ initialResizeLocation = [self convertBaseToScreen:[self mouseLocationOutsideOfEventStream]];
+ initialResizeLocation.x -= initialResizeFrame.origin.x;
+ initialResizeLocation.y -= initialResizeFrame.origin.y;
+}
+
+
static GdkDragContext *current_context = NULL;
static GdkDragAction
gint root_y,
guint32 timestamp)
{
+ GdkWindowObject *private;
+ GdkWindowImplQuartz *impl;
+
g_return_if_fail (GDK_IS_WINDOW (window));
- /* FIXME: Implement */
+ if (edge != GDK_WINDOW_EDGE_SOUTH_EAST)
+ {
+ g_warning ("Resizing is only implemented for GDK_WINDOW_EDGE_SOUTH_EAST on Mac OS");
+ return;
+ }
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ private = GDK_WINDOW_OBJECT (window);
+ impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
+
+ if (!impl->toplevel)
+ {
+ g_warning ("Can't call gdk_window_begin_resize_drag on non-toplevel window");
+ return;
+ }
+
+ [(GdkQuartzWindow *)impl->toplevel beginManualResize];
}
void
gint root_y,
guint32 timestamp)
{
+ GdkWindowObject *private;
+ GdkWindowImplQuartz *impl;
+
g_return_if_fail (GDK_IS_WINDOW (window));
- /* FIXME: Implement */
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ private = GDK_WINDOW_OBJECT (window);
+ impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
+
+ if (!impl->toplevel)
+ {
+ g_warning ("Can't call gdk_window_begin_move_drag on non-toplevel window");
+ return;
+ }
+
+ [(GdkQuartzWindow *)impl->toplevel beginManualMove];
}
void