summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Skomra <skomra@gmail.com>2012-03-08 08:14:02 -0800
committerAaron Skomra <skomra@gmail.com>2012-03-08 08:14:02 -0800
commit9e9cb7623f2b3bbfb15c729d5abd08f373c2798e (patch)
treeea6713df66d64cf8b70017dbb130334f184088a4
parent94113ffa39b59a6841d442e4d8a13332111aa9a0 (diff)
added key release in view, controller, and event_loop.c
-rw-r--r--src/libcompositewm/event_loop.c7
-rw-r--r--src/libcompositewm/input.c2
-rw-r--r--src/libcompositewm/xtoq.c1
-rw-r--r--src/xtoq/XtoqController.m30
-rw-r--r--src/xtoq/XtoqView.m17
5 files changed, 55 insertions, 2 deletions
diff --git a/src/libcompositewm/event_loop.c b/src/libcompositewm/event_loop.c
index a37e9cb..e324d4f 100644
--- a/src/libcompositewm/event_loop.c
+++ b/src/libcompositewm/event_loop.c
@@ -239,6 +239,13 @@ void *run_event_loop (void *thread_arg_struct)
bp->event, bp->event_x, bp->event_y );
break;
}
+ case XCB_BUTTON_RELEASE: {
+ printf("X Button release from xserver ");
+ xcb_button_press_event_t *bp = (xcb_button_press_event_t *)evt;
+ printf ("in window %ld, at coordinates (%d,%d)\n",
+ bp->event, bp->event_x, bp->event_y );
+ break;
+ }
case XCB_MOTION_NOTIFY: {
printf("X mouse motion from from xserver-");
xcb_button_press_event_t *bp = (xcb_button_press_event_t *)evt;
diff --git a/src/libcompositewm/input.c b/src/libcompositewm/input.c
index 275b73a..f2413a2 100644
--- a/src/libcompositewm/input.c
+++ b/src/libcompositewm/input.c
@@ -83,7 +83,7 @@ xtoq_button_release (xtoq_context_t *context, long x, long y, int window, int bu
xcb_test_fake_input (context->conn, XCB_BUTTON_RELEASE, 1, XCB_CURRENT_TIME,
context->parent, x, y, 0);
xcb_flush(context->conn);
- printf("button down received by xtoq.c - (%ld,%ld) in Mac window #%i\n", x, y, window);
+ printf("button release received by xtoq.c - (%ld,%ld) in Mac window #%i\n", x, y, window);
}
void
diff --git a/src/libcompositewm/xtoq.c b/src/libcompositewm/xtoq.c
index 12b4f34..a509431 100644
--- a/src/libcompositewm/xtoq.c
+++ b/src/libcompositewm/xtoq.c
@@ -59,6 +59,7 @@ xtoq_init(char *display) {
// we care about catching on the root window.
mask_values[0] = XCB_EVENT_MASK_KEY_PRESS |
XCB_EVENT_MASK_BUTTON_PRESS |
+ XCB_EVENT_MASK_BUTTON_RELEASE |
XCB_EVENT_MASK_STRUCTURE_NOTIFY |
XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT;
diff --git a/src/xtoq/XtoqController.m b/src/xtoq/XtoqController.m
index 15808d2..7e307b3 100644
--- a/src/xtoq/XtoqController.m
+++ b/src/xtoq/XtoqController.m
@@ -122,6 +122,12 @@
selector: @selector(mouseButtonDownInView:)
name: @"XTOQmouseButtonDownEvent"
object: nil];
+
+ [nc addObserver: self
+ selector: @selector(mouseButtonReleaseInView:)
+ name: @"XTOQmouseButtonReleaseEvent"
+ object: nil];
+
// register for destroy event
[nc addObserver: self
selector: @selector(destroy:)
@@ -217,6 +223,30 @@
0);;});
}
+// on this side all I have is a xtoq_context , on the library side I need
+// to turn that into a real context
+- (void) mouseButtonReleaseInView: (NSNotification *) aNotification
+{
+ CGFloat heightFloat;
+ NSDictionary *mouseReleaseInfo = [aNotification userInfo];
+ // NSLog(@"Controller Got a XTOQmouseButtonDownEvent");
+ NSEvent * event = [mouseReleaseInfo objectForKey: @"1"];
+ //NSRect bnd = NSMakeRect(0,0,512,386);
+ NSNumber * heightAsNumber = [NSNumber alloc];
+ heightAsNumber = [mouseReleaseInfo objectForKey: @"2"];
+ heightFloat = [heightAsNumber floatValue];
+ //NSLog(@"Mouse Info: %@", [mouseDownInfo objectForKey: @"2"]);
+ dispatch_async(xtoqDispatchQueue,
+ ^{ xtoq_button_release (rootContext,
+ [event locationInWindow].x,
+ heightFloat - [event locationInWindow].y,
+ (int)[event windowNumber],
+ 0);;});
+}
+
+
+
+
- (void) setScreen:(char *)scrn {
screen = scrn;
}
diff --git a/src/xtoq/XtoqView.m b/src/xtoq/XtoqView.m
index 38d60bd..517c3f9 100644
--- a/src/xtoq/XtoqView.m
+++ b/src/xtoq/XtoqView.m
@@ -98,7 +98,8 @@ acceptsFirstResponder {
}
- (void)mouseExited:(NSEvent *)theEvent {
-
+ }
+- (void)rightMouseDown:(NSEvent *)theEvent
}*/
/**
@@ -128,6 +129,20 @@ mouseDown:(NSEvent *)mouseEvent {
userInfo:twoInfoDict];
}
+- (void)mouseUp:(NSEvent *)theEvent {
+ CGFloat f = [self bounds].size.height;
+ NSNumber *n = [[NSNumber alloc] initWithFloat:f];
+ NSMutableDictionary *twoInfoDict = [[NSMutableDictionary alloc] initWithCapacity:2];
+ [twoInfoDict setObject:theEvent forKey:@"1"];
+ [twoInfoDict setObject:n forKey:@"2"];
+
+ //NSLog(@"bound %f location %f", CGRectGetHeight(bnd), [mouseEvent locationInWindow].y );
+ [notificationCenter postNotificationName:@"XTOQmouseButtonReleaseEvent"
+ object:self
+ userInfo:twoInfoDict];
+
+}
+
- (void)setImage:(XtoqImageRep *)newImage {
image[bufferIndex++] = newImage;
}