summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJess VanDerwalker <washu@sonic.net>2012-03-10 13:32:09 -0800
committerJess VanDerwalker <washu@sonic.net>2012-03-10 13:32:09 -0800
commitd71769c9e0c95401f49ebe388b639bbfcf2391e5 (patch)
tree07a6a9b415f28aa221b03234fc8b971565b71522
parent25e8dd12027f89602b39a968aab89a6d8056635f (diff)
parentdd950838e2306349a0e63923b780dba597948b61 (diff)
Fix to merge conflict in event_loop
-rw-r--r--src/libcompositewm/event_loop.c7
-rw-r--r--src/xtoq/XtoqApplication.h2
-rw-r--r--src/xtoq/XtoqApplication.m34
-rw-r--r--src/xtoq/XtoqController.h5
-rw-r--r--src/xtoq/XtoqController.m73
-rw-r--r--src/xtoq/XtoqView.m15
6 files changed, 80 insertions, 56 deletions
diff --git a/src/libcompositewm/event_loop.c b/src/libcompositewm/event_loop.c
index 7340192..632aa55 100644
--- a/src/libcompositewm/event_loop.c
+++ b/src/libcompositewm/event_loop.c
@@ -82,7 +82,6 @@ _xtoq_start_event_loop (xcb_connection_t *conn,
run_event_loop,
(void *) conn_data);
-
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
@@ -271,10 +270,10 @@ void *run_event_loop (void *thread_arg_struct)
break;
}
case XCB_MOTION_NOTIFY: {
- printf("X mouse motion from from xserver-");
+ //printf("X mouse motion from from xserver-");
xcb_button_press_event_t *bp = (xcb_button_press_event_t *)evt;
- printf ("mouse motion in window %u, at coordinates (%d,%d)\n",
- bp->event, bp->event_x, bp->event_y );
+ // printf ("mouse motion in window %ld, at coordinates (%d,%d)\n",
+ // bp->event, bp->event_x, bp->event_y );
break;
}
default: {
diff --git a/src/xtoq/XtoqApplication.h b/src/xtoq/XtoqApplication.h
index 61c135f..c0a80cf 100644
--- a/src/xtoq/XtoqApplication.h
+++ b/src/xtoq/XtoqApplication.h
@@ -34,5 +34,7 @@
@interface XtoqApplication : NSApplication
int XtoqApplicationMain(int argc, char** argv);
+- (void) sendEvent:(NSEvent *)e;
+NSNotificationCenter * notificationCenter;
@end
diff --git a/src/xtoq/XtoqApplication.m b/src/xtoq/XtoqApplication.m
index e05bedd..0d83e08 100644
--- a/src/xtoq/XtoqApplication.m
+++ b/src/xtoq/XtoqApplication.m
@@ -21,6 +21,8 @@
#import "XtoqApplication.h"
+#define FILEBAR 23
+
@implementation XtoqApplication
int XtoqApplicationMain(int argc, char** argv){
@@ -107,9 +109,41 @@ int XtoqApplicationMain(int argc, char** argv){
controller = [[XtoqController alloc] init];
[controller setScreen:scrn];
[NSApp setDelegate: controller];
+
+ notificationCenter = [NSNotificationCenter defaultCenter];
+
[NSApp run];
return 1;
}
+- (void) sendEvent:(NSEvent *)e {
+ CGFloat x, y;
+ NSNumber *xObject, *yObject;
+ NSMutableDictionary *threeInfoDict;
+ switch ([e type]) {
+ case NSMouseMoved:
+ // height = [[NSScreen mainScreen] frame].size.height;
+ // you can't call mouseLocation on "e"
+ x = [NSEvent mouseLocation].x;
+ y = [NSEvent mouseLocation].y;
+
+ //NSLog(@"Mouse Moved y=%f", y);
+
+ xObject = [[NSNumber alloc] initWithFloat:x];
+ yObject = [[NSNumber alloc] initWithFloat:y];
+ threeInfoDict = [[NSMutableDictionary alloc] initWithCapacity:3];
+ [threeInfoDict setObject:e forKey:@"1"];
+ [threeInfoDict setObject:xObject forKey:@"2"];
+ [threeInfoDict setObject:yObject forKey:@"3"];
+ [notificationCenter postNotificationName:@"MouseMovedEvent"
+ object:self
+ userInfo:threeInfoDict];
+ break;
+
+ default: [super sendEvent:e];
+ break;
+ }
+}
+
@end
diff --git a/src/xtoq/XtoqController.h b/src/xtoq/XtoqController.h
index b12c190..51839a5 100644
--- a/src/xtoq/XtoqController.h
+++ b/src/xtoq/XtoqController.h
@@ -67,8 +67,7 @@ id referenceToSelf;
XtoqImageRep *image;
XtoqImageRep *imageNew;
XtoqView *view;
- NSString *file;
- NSImage *image2;
+
int originalHeight;
int originalWidth;
NSRect imageRec;
@@ -107,6 +106,8 @@ id referenceToSelf;
- (void) runXlogo: (id) sender;
- (void) runXterm: (id) sedner;
+- (void) mouseMovedInApp: (NSNotification *) aNotification;
+
/**
* Send an image to the view after being notified of a damage event from
* the event handler.
diff --git a/src/xtoq/XtoqController.m b/src/xtoq/XtoqController.m
index 10d42a4..283eeaa 100644
--- a/src/xtoq/XtoqController.m
+++ b/src/xtoq/XtoqController.m
@@ -128,6 +128,11 @@
selector: @selector(mouseButtonReleaseInView:)
name: @"XTOQmouseButtonReleaseEvent"
object: nil];
+
+ [nc addObserver: self
+ selector: @selector(mouseMovedInApp:)
+ name: @"MouseMovedEvent"
+ object: nil];
// register for destroy event
[nc addObserver: self
@@ -135,10 +140,6 @@
name: @"XTOQdestroyTheWindow"
object: nil];
- [nc addObserver: self
- selector: @selector(mouseMovedInView:)
- name: @"XTOQviewMouseMovedEvent"
- object: nil];
// regester for window will/did movement notification
[nc addObserver:self
selector:@selector(windowWillMove:)
@@ -181,6 +182,33 @@
xtoq_start_event_loop(rootContext, (void *) eventHandler);
}
+- (void) mouseMovedInApp: (NSNotification *) aNotification {
+
+ //CGFloat heightFloat;
+ NSDictionary *mouseMoveInfo = [aNotification userInfo];
+ NSEvent * event = [mouseMoveInfo objectForKey: @"1"];
+ NSNumber * xVal = [NSNumber alloc];
+ NSNumber * yVal = [NSNumber alloc];
+ xVal = [mouseMoveInfo objectForKey: @"2"];
+ yVal = [mouseMoveInfo objectForKey: @"3"];
+
+ float height = [[NSScreen mainScreen] frame].size.height;
+
+ int yInt = height - FILEBAR - [yVal intValue];
+ yVal = [[NSNumber alloc] initWithInt:yInt];
+
+ NSLog(@"Mouse x = %i, y = %i", [xVal intValue], [yVal intValue]);
+
+ dispatch_async(xtoqDispatchQueue,
+ ^{ xtoq_mouse_motion (rootContext,
+ [xVal intValue],
+ [yVal intValue],
+ (int)[event windowNumber],
+ 0);;});
+
+
+}
+
- (void) keyDownInView: (NSNotification *) aNotification
{
NSDictionary *keyInfo = [aNotification userInfo];
@@ -220,8 +248,8 @@
dispatch_async(xtoqDispatchQueue,
^{ xtoq_button_press (rootContext,
- 0,//[NSEvent mouseLocation].x,
- 0,// height - FILEBAR - [NSEvent mouseLocation].y,
+ 0,
+ 0,
(int)[event windowNumber],
0);;});
}
@@ -244,8 +272,8 @@
dispatch_async(xtoqDispatchQueue,
^{ xtoq_button_release (rootContext,
- 0,//[NSEvent mouseLocation].x,
- 0,//height - FILEBAR - [NSEvent mouseLocation].y,
+ 0,
+ 0,
(int)[event windowNumber],
0);;});
}
@@ -255,29 +283,6 @@
screen = scrn;
}
-- (void) mouseMovedInView: (NSNotification *) aNotification
-{
- CGFloat heightFloat;
- NSDictionary *mouseDownInfo = [aNotification userInfo];
- NSEvent * event = [mouseDownInfo objectForKey: @"1"];
- NSNumber * heightAsNumber = [NSNumber alloc];
- heightAsNumber = [mouseDownInfo objectForKey: @"2"];
- heightFloat = [heightAsNumber floatValue];
- //NSLog(@"Mouse Info: %@", [mouseDownInfo objectForKey: @"2"]);
-
- float height = [[NSScreen mainScreen] frame].size.height;
-
- NSLog(@"Mouse x = %i, y = %i", (int)[NSEvent mouseLocation].x,
- (int)[[NSScreen mainScreen] frame].size.height - FILEBAR - (int)[NSEvent mouseLocation].y);
-
- dispatch_async(xtoqDispatchQueue,
- ^{ xtoq_mouse_motion (rootContext,
- [NSEvent mouseLocation].x,
- height - FILEBAR - [NSEvent mouseLocation].y,
- (int)[event windowNumber],
- 0);;});
-}
-
- (void) makeMenu {
// Create and show menu - http://cocoawithlove.com/2010/09/minimalist-cocoa-programming.html
NSMenu *menubar;
@@ -494,15 +499,13 @@
if (moveWindow != nil) {
xtoq_context_t *moveContext = [moveWindow getContext];
NSRect moveFrame = [moveWindow frame];
-
int x = (int)moveFrame.origin.x;
int y = [self osxToXserver:(int)moveFrame.origin.y
windowHeight:moveContext->height] - WINDOWBAR;
int width = (int)moveFrame.size.width;
int height = (int)moveFrame.size.height - WINDOWBAR;
- NSLog(@"x = %i, y = %i, width = %i, height = %i,", x, y, width, height);
- NSLog(@"Call xtoq_configure_window(moveContext, x, y, height, width)");
- xtoq_configure_window(moveContext, x, y, height, width);
+ NSLog(@"Call xtoq_configure_window(moveContext, x = %i, y = %i, height = %i, width = %i)", x, y, height, width);
+ xtoq_configure_window(moveContext, x, y - height, height, width);
}
}
diff --git a/src/xtoq/XtoqView.m b/src/xtoq/XtoqView.m
index 0587966..6397fa3 100644
--- a/src/xtoq/XtoqView.m
+++ b/src/xtoq/XtoqView.m
@@ -76,21 +76,6 @@ acceptsFirstResponder {
return YES;
}
-- (void)mouseMoved:(NSEvent *)mouseMovedEvent
-{
- CGFloat f = [self bounds].size.height;
- NSNumber *n = [[NSNumber alloc] initWithFloat:f];
- NSMutableDictionary *twoInfoDict = [[NSMutableDictionary alloc] initWithCapacity:2];
- [twoInfoDict setObject:mouseMovedEvent forKey:@"1"];
- [twoInfoDict setObject:n forKey:@"2"];
-
- //NSLog(@"bound %f location %f", CGRectGetHeight(bnd), [mouseMovedEvent locationInWindow].y );
- [notificationCenter postNotificationName:@"XTOQviewMouseMovedEvent"
- object:self
- userInfo:twoInfoDict];
-}
-
-
/*- (void)mouseEntered:(NSEvent *)theEvent {
}