瀏覽代碼

input: pass button mask for button events

osy 4 天之前
父節點
當前提交
227c31ed30
共有 2 個文件被更改,包括 26 次插入25 次删除
  1. 13 13
      Sources/CocoaSpice/CSInput.m
  2. 13 12
      Sources/CocoaSpice/include/CSInput.h

+ 13 - 13
Sources/CocoaSpice/CSInput.m

@@ -217,7 +217,7 @@ static int cs_button_to_spice(CSInputButton button)
     return spice;
 }
 
-- (void)sendMouseMotion:(CSInputButton)button relativePoint:(CGPoint)relativePoint forMonitorID:(NSInteger)monitorID {
+- (void)sendMouseMotion:(CSInputButton)buttonMask relativePoint:(CGPoint)relativePoint forMonitorID:(NSInteger)monitorID {
     SpiceInputsChannel *inputs = self.channel;
     
     if (!inputs) {
@@ -232,16 +232,16 @@ static int cs_button_to_spice(CSInputButton button)
             SPICE_DEBUG("[CocoaSpice] %s:%d ignoring mouse motion event since we are in client mode", __FUNCTION__, __LINE__);
         } else {
             spice_inputs_channel_motion(inputs, relativePoint.x, relativePoint.y,
-                                        cs_button_mask_to_spice(button));
+                                        cs_button_mask_to_spice(buttonMask));
         }
     }];
 }
 
-- (void)sendMouseMotion:(CSInputButton)button relativePoint:(CGPoint)relativePoint {
-    [self sendMouseMotion:button relativePoint:relativePoint forMonitorID:0];
+- (void)sendMouseMotion:(CSInputButton)buttonMask relativePoint:(CGPoint)relativePoint {
+    [self sendMouseMotion:buttonMask relativePoint:relativePoint forMonitorID:0];
 }
 
-- (void)sendMousePosition:(CSInputButton)button absolutePoint:(CGPoint)absolutePoint forMonitorID:(NSInteger)monitorID {
+- (void)sendMousePosition:(CSInputButton)buttonMask absolutePoint:(CGPoint)absolutePoint forMonitorID:(NSInteger)monitorID {
     SpiceInputsChannel *inputs = self.channel;
     
     if (!inputs) {
@@ -256,18 +256,18 @@ static int cs_button_to_spice(CSInputButton button)
             SPICE_DEBUG("[CocoaSpice] %s:%d ignoring mouse position event since we are in server mode", __FUNCTION__, __LINE__);
         } else {
             spice_inputs_channel_position(inputs, absolutePoint.x, absolutePoint.y, (int)monitorID,
-                                          cs_button_mask_to_spice(button));
+                                          cs_button_mask_to_spice(buttonMask));
         }
     }];
 }
 
-- (void)sendMousePosition:(CSInputButton)button absolutePoint:(CGPoint)absolutePoint {
-    [self sendMousePosition:button absolutePoint:absolutePoint forMonitorID:0];
+- (void)sendMousePosition:(CSInputButton)buttonMask absolutePoint:(CGPoint)absolutePoint {
+    [self sendMousePosition:buttonMask absolutePoint:absolutePoint forMonitorID:0];
 }
 
-- (void)sendMouseScroll:(CSInputScroll)type button:(CSInputButton)button dy:(CGFloat)dy {
+- (void)sendMouseScroll:(CSInputScroll)type buttonMask:(CSInputButton)buttonMask dy:(CGFloat)dy {
     SpiceInputsChannel *inputs = self.channel;
-    gint button_state = cs_button_mask_to_spice(button);
+    gint button_state = cs_button_mask_to_spice(buttonMask);
     
     SPICE_DEBUG("%s", __FUNCTION__);
     
@@ -308,7 +308,7 @@ static int cs_button_to_spice(CSInputButton button)
     }];
 }
 
-- (void)sendMouseButton:(CSInputButton)button pressed:(BOOL)pressed {
+- (void)sendMouseButton:(CSInputButton)button mask:(CSInputButton)mask pressed:(BOOL)pressed {
     SpiceInputsChannel *inputs = self.channel;
     SPICE_DEBUG("%s %s: button %u", __FUNCTION__,
                   pressed ? "press" : "release",
@@ -325,11 +325,11 @@ static int cs_button_to_spice(CSInputButton button)
         if (pressed) {
             spice_inputs_channel_button_press(inputs,
                                               cs_button_to_spice(button),
-                                              cs_button_mask_to_spice(button));
+                                              cs_button_mask_to_spice(mask));
         } else {
             spice_inputs_channel_button_release(inputs,
                                                 cs_button_to_spice(button),
-                                                cs_button_mask_to_spice(button));
+                                                cs_button_mask_to_spice(mask));
         }
     }];
 }

+ 13 - 12
Sources/CocoaSpice/include/CSInput.h

@@ -118,42 +118,43 @@ NS_ASSUME_NONNULL_BEGIN
 /// Sends a relative mouse movement event to the main monitor
 ///
 /// Must use `-requestMouseMode:` to set server mode to `true` before calling this.
-/// @param button Mask of mouse buttons pressed
+/// @param buttonMask Mask of mouse buttons pressed
 /// @param relativePoint Delta of previous mouse coordinates
-- (void)sendMouseMotion:(CSInputButton)button relativePoint:(CGPoint)relativePoint;
+- (void)sendMouseMotion:(CSInputButton)buttonMask relativePoint:(CGPoint)relativePoint;
 
 /// Sends a relative mouse movement event
 ///
 /// Must use `-requestMouseMode:` to set server mode to `true` before calling this. Otherwise, the event is ignored.
-/// @param button Mask of mouse buttons pressed
+/// @param buttonMask Mask of mouse buttons pressed
 /// @param relativePoint Delta of previous mouse coordinates
 /// @param monitorID Monitor where the mouse event is sent to
-- (void)sendMouseMotion:(CSInputButton)button relativePoint:(CGPoint)relativePoint forMonitorID:(NSInteger)monitorID;
+- (void)sendMouseMotion:(CSInputButton)buttonMask relativePoint:(CGPoint)relativePoint forMonitorID:(NSInteger)monitorID;
 
 /// Sends an absolute mouse movement event (if supported) to the main monitor
 ///
 /// Must use `-requestMouseMode:` to set server mode to `false` before calling this. Otherwise, the event is ignored.
-/// @param button Mask of mouse buttons pressed
+/// @param buttonMask Mask of mouse buttons pressed
 /// @param absolutePoint Absolute position of mouse coordinates
-- (void)sendMousePosition:(CSInputButton)button absolutePoint:(CGPoint)absolutePoint;
+- (void)sendMousePosition:(CSInputButton)buttonMask absolutePoint:(CGPoint)absolutePoint;
 
 /// Sends an absolute mouse movement event (if supported)
 ///
-/// @param button Mask of mouse buttons pressed
+/// @param buttonMask Mask of mouse buttons pressed
 /// @param absolutePoint Absolute position of mouse coordinates
 /// @param monitorID Monitor where the mouse event is sent to
-- (void)sendMousePosition:(CSInputButton)button absolutePoint:(CGPoint)absolutePoint forMonitorID:(NSInteger)monitorID;
+- (void)sendMousePosition:(CSInputButton)buttonMask absolutePoint:(CGPoint)absolutePoint forMonitorID:(NSInteger)monitorID;
 
 /// Sends a mouse scroll event
 /// @param type Scroll event type
-/// @param button Mask of mouse buttons pressed
+/// @param buttonMask Mask of mouse buttons pressed
 /// @param dy If `type` is `kCSInputScrollSmooth` then this is a positive or negative amount to scroll. Otherwise it is ignored.
-- (void)sendMouseScroll:(CSInputScroll)type button:(CSInputButton)button dy:(CGFloat)dy;
+- (void)sendMouseScroll:(CSInputScroll)type buttonMask:(CSInputButton)buttonMask dy:(CGFloat)dy;
 
 /// Sends a mouse button without moving the mouse
-/// @param button Mask of mouse buttons
+/// @param button New button being pressed or released
+/// @param mask Mask of all buttons currently pressed
 /// @param pressed Pressed or released
-- (void)sendMouseButton:(CSInputButton)button pressed:(BOOL)pressed;
+- (void)sendMouseButton:(CSInputButton)button mask:(CSInputButton)mask pressed:(BOOL)pressed;
 
 /// Request change to absolute or relative positioning for mouse events
 ///