[3.2] Add window click-through support.
This commit is contained in:
@ -114,6 +114,7 @@ public:
|
||||
NSOpenGLPixelFormat *pixelFormat;
|
||||
NSOpenGLContext *context;
|
||||
|
||||
Vector<Vector2> mpath;
|
||||
bool layered_window;
|
||||
|
||||
CursorShape cursor_shape;
|
||||
@ -208,6 +209,7 @@ public:
|
||||
virtual int get_mouse_button_state() const;
|
||||
void update_real_mouse_position();
|
||||
virtual void set_window_title(const String &p_title);
|
||||
virtual void set_window_mouse_passthrough(const PoolVector2Array &p_region);
|
||||
|
||||
virtual Size2 get_window_size() const;
|
||||
virtual Size2 get_real_window_size() const;
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
|
||||
#include "os_osx.h"
|
||||
|
||||
#include "core/math/geometry.h"
|
||||
#include "core/os/keyboard.h"
|
||||
#include "core/print_string.h"
|
||||
#include "core/version_generated.gen.h"
|
||||
@ -2136,6 +2137,13 @@ void OS_OSX::set_window_title(const String &p_title) {
|
||||
[window_object setTitle:[NSString stringWithUTF8String:p_title.utf8().get_data()]];
|
||||
}
|
||||
|
||||
void OS_OSX::set_window_mouse_passthrough(const PoolVector2Array &p_region) {
|
||||
mpath.clear();
|
||||
for (int i = 0; i < p_region.size(); i++) {
|
||||
mpath.push_back(p_region[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void OS_OSX::set_native_icon(const String &p_filename) {
|
||||
|
||||
FileAccess *f = FileAccess::open(p_filename, FileAccess::READ);
|
||||
@ -3053,6 +3061,23 @@ void OS_OSX::process_events() {
|
||||
}
|
||||
process_key_events();
|
||||
|
||||
if (mpath.size() > 0) {
|
||||
const Vector2 mpos = get_mouse_pos([window_object mouseLocationOutsideOfEventStream]);
|
||||
if (Geometry::is_point_in_polygon(mpos, mpath)) {
|
||||
if ([window_object ignoresMouseEvents]) {
|
||||
[window_object setIgnoresMouseEvents:NO];
|
||||
}
|
||||
} else {
|
||||
if (![window_object ignoresMouseEvents]) {
|
||||
[window_object setIgnoresMouseEvents:YES];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ([window_object ignoresMouseEvents]) {
|
||||
[window_object setIgnoresMouseEvents:NO];
|
||||
}
|
||||
}
|
||||
|
||||
[autoreleasePool drain];
|
||||
autoreleasePool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user