summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2010-02-01 17:41:32 +0000
committerManolo Gouy <Manolo>2010-02-01 17:41:32 +0000
commitc7b67bc25275b587d357939a21df6c534d56b5e9 (patch)
tree5283ad16c373f68e6b00ad9615690796a14fa57d /src
parent4645ed97031bb2ce1122ec890a6c6ac55590c94a (diff)
fixes STR 2309 by updating Fl::e_x, e_y, e_x_root and e_y_root after window moves, resizes and activations.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7036 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_cocoa.mm43
1 files changed, 20 insertions, 23 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index bd950ebef..27ba2c086 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -713,6 +713,18 @@ int fl_wait( double time )
return (got_events);
}
+// updates Fl::e_x, Fl::e_y, Fl::e_x_root, and Fl::e_y_root
+static void update_e_xy_and_e_xy_root(NSWindow *nsw)
+{
+ NSPoint pt;
+ pt = [nsw mouseLocationOutsideOfEventStream];
+ Fl::e_x = pt.x;
+ Fl::e_y = [[nsw contentView] frame].size.height - pt.y;
+ pt = [NSEvent mouseLocation];
+ Fl::e_x_root = pt.x;
+ Fl::e_y_root = [[nsw screen] frame].size.height - pt.y;
+}
+
/*
* Cocoa Mousewheel handler
*/
@@ -827,11 +839,7 @@ static void cocoaMouseHandler(NSEvent *theEvent)
Fl::e_is_click = 0;
}
mods_to_e_state( mods );
- NSPoint screen = [[theEvent window] convertBaseToScreen:[theEvent locationInWindow]];
- Fl::e_x_root = screen.x;
- Fl::e_y_root = [[[theEvent window] screen] frame].size.height - screen.y;
- Fl::e_x = pos.x;
- Fl::e_y = pos.y;
+ update_e_xy_and_e_xy_root([theEvent window]);
Fl::handle( sendEvent, window );
}
break;
@@ -1301,6 +1309,7 @@ extern "C" {
if ([nsw containsGLsubwindow] ) {
[nsw display];// redraw window after moving if it contains OpenGL subwindows
}
+ update_e_xy_and_e_xy_root(nsw);
}
- (void)windowDidResize:(NSNotification *)notif
{
@@ -1316,6 +1325,7 @@ extern "C" {
(int)([[nsw screen] frame].size.height - pt2.y),
(int)r.size.width,
(int)r.size.height);
+ update_e_xy_and_e_xy_root(nsw);
}
- (void)windowDidBecomeKey:(NSNotification *)notif
{
@@ -1328,12 +1338,14 @@ extern "C" {
FLWindow *nsw = (FLWindow*)[notif object];
Fl_Window *window = [nsw getFl_Window];
Fl::first_window(window);
+ update_e_xy_and_e_xy_root(nsw);
}
- (void)windowDidDeminiaturize:(NSNotification *)notif
{
FLWindow *nsw = (FLWindow*)[notif object];
Fl_Window *window = [nsw getFl_Window];
window->set_visible();
+ update_e_xy_and_e_xy_root(nsw);
}
- (void)windowDidMiniaturize:(NSNotification *)notif
{
@@ -1806,12 +1818,7 @@ static void q_set_window_title(NSWindow *nsw, const char * name ) {
- (NSDragOperation)draggingEntered:(id < NSDraggingInfo >)sender
{
Fl_Window *target = [(FLWindow*)[self window] getFl_Window];
- NSPoint pt = [sender draggingLocation];
- Fl::e_x = pt.x;
- Fl::e_y = [self frame].size.height - pt.y;
- Fl::e_x_root = [[self window] frame].origin.x + Fl::e_x;
- Fl::e_y_root = [[self window] frame].origin.y + pt.y;
- Fl::e_y_root = [[[self window] screen] frame].size.height - Fl::e_y_root;
+ update_e_xy_and_e_xy_root([self window]);
fl_dnd_target_window = target;
int ret = Fl::handle( FL_DND_ENTER, target );
breakMacEventLoop();
@@ -1820,12 +1827,7 @@ static void q_set_window_title(NSWindow *nsw, const char * name ) {
- (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender
{
Fl_Window *target = [(FLWindow*)[self window] getFl_Window];
- NSPoint pt = [sender draggingLocation];
- Fl::e_x = pt.x;
- Fl::e_y = [self frame].size.height - pt.y;
- Fl::e_x_root = [[self window] frame].origin.x + Fl::e_x;
- Fl::e_y_root = [[self window] frame].origin.y + pt.y;
- Fl::e_y_root = [[[self window] screen] frame].size.height - Fl::e_y_root;
+ update_e_xy_and_e_xy_root([self window]);
fl_dnd_target_window = target;
int ret = Fl::handle( FL_DND_DRAG, target );
breakMacEventLoop();
@@ -1843,12 +1845,7 @@ static void q_set_window_title(NSWindow *nsw, const char * name ) {
// NSDragOperation sourceDragMask;
// sourceDragMask = [sender draggingSourceOperationMask];
pboard = [sender draggingPasteboard];
- NSPoint pt = [sender draggingLocation];
- Fl::e_x = pt.x;
- Fl::e_y = [self frame].size.height - pt.y;
- Fl::e_x_root = [[self window] frame].origin.x + Fl::e_x;
- Fl::e_y_root = [[self window] frame].origin.y + pt.y;
- Fl::e_y_root = [[[self window] screen] frame].size.height - Fl::e_y_root;
+ update_e_xy_and_e_xy_root([self window]);
if (DragData) { free(DragData); DragData = NULL; }
if ( [[pboard types] containsObject:NSFilenamesPboardType] ) {
CFArrayRef files = (CFArrayRef)[pboard propertyListForType:NSFilenamesPboardType];