mirror of
https://github.com/debauchee/barrier.git
synced 2026-07-11 06:17:40 +08:00
Fix for Issue 378, updating deprecated calls for creating mouse events under MacOS 10.6.
Thanks to snes350 for the initial patch to help fix this problem.
This commit is contained in:
@@ -15,11 +15,14 @@
|
||||
#ifndef COSXSCREEN_H
|
||||
#define COSXSCREEN_H
|
||||
|
||||
#include <bitset>
|
||||
|
||||
#include "stdmap.h"
|
||||
#include "stdvector.h"
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
#include "COSXClipboard.h"
|
||||
#include "CPlatformScreen.h"
|
||||
#include "stdmap.h"
|
||||
#include "stdvector.h"
|
||||
|
||||
#include <mach/mach_port.h>
|
||||
#include <mach/mach_interface.h>
|
||||
@@ -102,6 +105,8 @@ private:
|
||||
bool onMouseButton(bool pressed, UInt16 macButton);
|
||||
bool onMouseWheel(SInt32 xDelta, SInt32 yDelta) const;
|
||||
|
||||
void constructMouseButtonEventMap();
|
||||
|
||||
bool onKey(CGEventRef event);
|
||||
bool onHotKey(EventRef event) const;
|
||||
|
||||
@@ -174,6 +179,28 @@ private:
|
||||
UInt32 m_keycode;
|
||||
UInt32 m_mask;
|
||||
};
|
||||
|
||||
enum MouseButtonState {
|
||||
kMouseButtonUp = 0,
|
||||
kMouseButtonDragged,
|
||||
kMouseButtonDown,
|
||||
kMouseButtonStateMax
|
||||
};
|
||||
|
||||
|
||||
class CMouseButtonState {
|
||||
public:
|
||||
void set(UInt32 button, MouseButtonState state);
|
||||
bool any();
|
||||
void reset();
|
||||
void overwrite(UInt32 buttons);
|
||||
|
||||
bool test(UInt32 button) const;
|
||||
SInt8 getFirstButtonDown() const;
|
||||
private:
|
||||
std::bitset<NumButtonIDs> m_buttons;
|
||||
};
|
||||
|
||||
typedef std::map<UInt32, CHotKeyItem> HotKeyMap;
|
||||
typedef std::vector<UInt32> HotKeyIDList;
|
||||
typedef std::map<KeyModifierMask, UInt32> ModifierHotKeyMap;
|
||||
@@ -196,7 +223,17 @@ private:
|
||||
// mouse state
|
||||
mutable SInt32 m_xCursor, m_yCursor;
|
||||
mutable bool m_cursorPosValid;
|
||||
mutable boolean_t m_buttons[5];
|
||||
|
||||
/* FIXME: this data structure is explicitly marked mutable due
|
||||
to a need to track the state of buttons since the remote
|
||||
side only lets us know of change events, and because the
|
||||
fakeMouseButton button method is marked 'const'. This is
|
||||
Evil, and this should be moved to a place where it need not
|
||||
be mutable as soon as possible. */
|
||||
mutable CMouseButtonState m_buttonState;
|
||||
typedef std::map<UInt16, CGEventType> MouseButtonEventMapType;
|
||||
std::vector<MouseButtonEventMapType> MouseButtonEventMap;
|
||||
|
||||
bool m_cursorHidden;
|
||||
SInt32 m_dragNumButtonsDown;
|
||||
Point m_dragLastPoint;
|
||||
|
||||
Reference in New Issue
Block a user