summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJess VanDerwalker <washu@sonic.net>2012-04-04 15:23:52 -0700
committerJeremy Huddleston <jeremyhu@apple.com>2012-04-05 11:43:17 -0700
commit239bb8724a8cbdc51b39dda9e4ae154e69791acf (patch)
tree13d8ec8ac5d8663e9beaca8ca18da825805d6f51
parente51189349c1188f41b8458b5dea72e9d69a5f165 (diff)
Mouse handler added to window (from milestone4-sendEvent on old repo).
-rw-r--r--src/xtoq/XtoqWindow.h13
-rw-r--r--src/xtoq/XtoqWindow.m26
2 files changed, 33 insertions, 6 deletions
diff --git a/src/xtoq/XtoqWindow.h b/src/xtoq/XtoqWindow.h
index 1248502..b2ddd5e 100644
--- a/src/xtoq/XtoqWindow.h
+++ b/src/xtoq/XtoqWindow.h
@@ -52,18 +52,19 @@
-(xcwm_context_t *) getContext;
/**
- * Sets the root window's pointer xcwmLocalData to the context's pointer.
- */
-//-(void) setRootDataPointer: (xcwm_context_t *) xqContext;
-
-/**
* Catches the close event from clicking the red button or from preformClose.
*/
- (BOOL)windowShouldClose:(id)sender;
-/*
+/**
* Catches the event that a window gains focus
*/
-(void)windowDidBecomeKey:(NSNotification *)note;
+/**
+ * Handler for mouse movement events.
+ * @param event The mouse movement event.
+ */
+-(void) mouseMoved:(NSEvent *)event;
+
@end
diff --git a/src/xtoq/XtoqWindow.m b/src/xtoq/XtoqWindow.m
index c61629e..b6f3207 100644
--- a/src/xtoq/XtoqWindow.m
+++ b/src/xtoq/XtoqWindow.m
@@ -47,6 +47,7 @@
styleMask:aStyle
backing:bufferingType
defer:flag];
+ [self setAcceptsMouseMovedEvents: YES];
return result;
}
@@ -81,4 +82,29 @@
xcwm_set_window_to_top(winContext);
}
+
+-(void) mouseMoved:(NSEvent *) event {
+ NSMutableDictionary *InfoDict;
+ NSNumber *xNum, *yNum;
+
+ NSPoint location = [event locationInWindow];
+ NSRect frame = [self frame];
+
+ location.x += frame.origin.x;
+ location.y += frame.origin.y;
+
+ xNum = [[NSNumber alloc] initWithFloat:location.x];
+ yNum = [[NSNumber alloc] initWithFloat:location.y];
+
+ InfoDict = [[NSMutableDictionary alloc] initWithCapacity:3];
+ [InfoDict setObject:event forKey:@"1"];
+ [InfoDict setObject:xNum forKey:@"2"];
+ [InfoDict setObject:yNum forKey:@"3"];
+
+ [[NSNotificationCenter defaultCenter]
+ postNotificationName:@"MouseMovedEvent"
+ object:self
+ userInfo:InfoDict];
+}
+
@end