Search
lxdream.org :: lxdream/src/cocoaui/cocoa_ctrl.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/cocoaui/cocoa_ctrl.c
changeset 849:bbe26d798fc2
prev787:6717c02ff81f
author nkeynes
date Mon Sep 08 05:13:51 2008 +0000 (11 years ago)
permissions -rw-r--r--
last change Refactor mouse event management - button events are now usable for controllers
file annotate diff log raw
1.1 --- a/src/cocoaui/cocoa_ctrl.c Tue Jul 29 10:55:51 2008 +0000
1.2 +++ b/src/cocoaui/cocoa_ctrl.c Mon Sep 08 05:13:51 2008 +0000
1.3 @@ -25,6 +25,8 @@
1.4
1.5 #define MAX_DEVICES 4
1.6
1.7 +#define KEYBINDING_SIZE 110
1.8 +
1.9 static void cocoa_config_keysym_hook(void *data, const gchar *keysym);
1.10
1.11 @interface KeyBindingEditor (Private)
1.12 @@ -88,6 +90,14 @@
1.13 [self fireBindingChanged];
1.14 }
1.15 }
1.16 +- (void)updateMousesym: (int)button
1.17 +{
1.18 + gchar *keysym = input_keycode_to_keysym( &system_mouse_driver, (button+1) );
1.19 + if( keysym != NULL ) {
1.20 + [self updateKeysym: keysym ];
1.21 + g_free(keysym);
1.22 + }
1.23 +}
1.24 - (void)keyPressed: (int)keycode
1.25 {
1.26 gchar *keysym = input_keycode_to_keysym(NULL, keycode);
1.27 @@ -102,8 +112,24 @@
1.28 }
1.29 - (void)mouseDown: (NSEvent *)event
1.30 {
1.31 - [self setPrimed: YES];
1.32 - [super mouseDown: event];
1.33 + if( isPrimed ) {
1.34 + [self updateMousesym: 0];
1.35 + } else {
1.36 + [self setPrimed: YES];
1.37 + [super mouseDown: event];
1.38 + }
1.39 +}
1.40 +- (void)rightMouseDown: (NSEvent *)event
1.41 +{
1.42 + if( isPrimed ) {
1.43 + [self updateMousesym: 1];
1.44 + }
1.45 +}
1.46 +- (void)otherMouseDown: (NSEvent *)event
1.47 +{
1.48 + if( isPrimed ) {
1.49 + [self updateMousesym: [event buttonNumber]];
1.50 + }
1.51 }
1.52 - (void)keyDown: (NSEvent *) event
1.53 {
1.54 @@ -218,7 +244,7 @@
1.55
1.56 for( count=0; config[count].key != NULL; count++ );
1.57 x = TEXT_GAP;
1.58 - NSSize size = NSMakeSize(85*3+TEXT_GAP*4, count*(TEXT_HEIGHT+TEXT_GAP)+TEXT_GAP);
1.59 + NSSize size = NSMakeSize(85+KEYBINDING_SIZE*2+TEXT_GAP*4, count*(TEXT_HEIGHT+TEXT_GAP)+TEXT_GAP);
1.60 [self setFrameSize: size];
1.61 [self scrollRectToVisible: NSMakeRect(0,0,1,1)];
1.62 y = TEXT_GAP;
1.63 @@ -227,14 +253,14 @@
1.64 NSTextField *label = cocoa_gui_add_label(self, NS_(config[i].label), frame);
1.65 [label setAlignment: NSRightTextAlignment];
1.66
1.67 - frame = NSMakeRect( x + 85 + TEXT_GAP, y, 85, TEXT_HEIGHT);
1.68 + frame = NSMakeRect( x + 85 + TEXT_GAP, y, KEYBINDING_SIZE, TEXT_HEIGHT);
1.69 field[i][0] = [[KeyBindingField alloc] initWithFrame: frame];
1.70 [field[i][0] setAutoresizingMask: (NSViewMinYMargin|NSViewMaxXMargin)];
1.71 [field[i][0] setTag: i];
1.72 [field[i][0] setDelegate: self];
1.73 [self addSubview: field[i][0]];
1.74
1.75 - frame = NSMakeRect( x + (85*2) + (TEXT_GAP*2), y, 85, TEXT_HEIGHT);
1.76 + frame = NSMakeRect( x + 85 + KEYBINDING_SIZE + (TEXT_GAP*2), y, KEYBINDING_SIZE, TEXT_HEIGHT);
1.77 field[i][1] = [[KeyBindingField alloc] initWithFrame: frame];
1.78 [field[i][1] setAutoresizingMask: (NSViewMinYMargin|NSViewMaxXMargin)];
1.79 [field[i][1] setTag: i];
.