Skip to content

Commit d4c23ab

Browse files
committed
Enhance Window class with new visibility and mouse event handling methods
1 parent e5175d0 commit d4c23ab

File tree

4 files changed

+36
-12
lines changed

4 files changed

+36
-12
lines changed

src/accessibility_manager.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44

55
namespace nativeapi {
66

7-
AccessibilityManager::AccessibilityManager() {
8-
std::cout << "AccessibilityManager::AccessibilityManager()" << std::endl;
9-
};
7+
AccessibilityManager::AccessibilityManager() {}
108

11-
AccessibilityManager::~AccessibilityManager() {
12-
std::cout << "AccessibilityManager::~AccessibilityManager()" << std::endl;
13-
};
9+
AccessibilityManager::~AccessibilityManager() {}
1410

1511
} // namespace nativeapi

src/broadcast_center.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@
44

55
namespace nativeapi {
66

7-
BroadcastCenter::BroadcastCenter() {
8-
std::cout << "BroadcastCenter::BroadcastCenter()" << std::endl;
9-
};
7+
BroadcastCenter::BroadcastCenter() {}
108

11-
BroadcastCenter::~BroadcastCenter() {
12-
std::cout << "BroadcastCenter::~BroadcastCenter()" << std::endl;
13-
};
9+
BroadcastCenter::~BroadcastCenter() {}
1410

1511
BroadcastEventHandler::BroadcastEventHandler(
1612
std::function<void(const std::string& topic, const std::string& message)>

src/window.h

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class Window {
1818
void Blur();
1919
bool IsFocused() const;
2020
void Show();
21+
void ShowInactive();
2122
void Hide();
2223
bool IsVisible() const;
2324
void Maximize();
@@ -62,6 +63,10 @@ class Window {
6263
bool HasShadow() const;
6364
void SetOpacity(float opacity);
6465
float GetOpacity() const;
66+
void SetVisibleOnAllWorkspaces(bool is_visible_on_all_workspaces);
67+
bool IsVisibleOnAllWorkspaces() const;
68+
void SetIgnoreMouseEvents(bool is_ignore_mouse_events);
69+
bool IsIgnoreMouseEvents() const;
6570
void SetFocusable(bool is_focusable);
6671
bool IsFocusable() const;
6772
void StartDragging();

src/window_macos.mm

+27
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@
3939
}
4040

4141
void Window::Show() {
42+
[pimpl_->ns_window_ setIsVisible:YES];
43+
// Panels receive key focus when shown but should not activate the app.
44+
if (![pimpl_->ns_window_ isKindOfClass:[NSPanel class]]) {
45+
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
46+
}
47+
[pimpl_->ns_window_ makeKeyAndOrderFront:nil];
48+
}
49+
50+
void Window::ShowInactive() {
4251
[pimpl_->ns_window_ setIsVisible:YES];
4352
[pimpl_->ns_window_ orderFrontRegardless];
4453
}
@@ -282,6 +291,24 @@
282291
return [pimpl_->ns_window_ alphaValue];
283292
}
284293

294+
void Window::SetVisibleOnAllWorkspaces(bool is_visible_on_all_workspaces) {
295+
[pimpl_->ns_window_ setCollectionBehavior:is_visible_on_all_workspaces
296+
? NSWindowCollectionBehaviorCanJoinAllSpaces
297+
: NSWindowCollectionBehaviorDefault];
298+
}
299+
300+
bool Window::IsVisibleOnAllWorkspaces() const {
301+
return [pimpl_->ns_window_ collectionBehavior] & NSWindowCollectionBehaviorCanJoinAllSpaces;
302+
}
303+
304+
void Window::SetIgnoreMouseEvents(bool is_ignore_mouse_events) {
305+
[pimpl_->ns_window_ setIgnoresMouseEvents:is_ignore_mouse_events];
306+
}
307+
308+
bool Window::IsIgnoreMouseEvents() const {
309+
return [pimpl_->ns_window_ ignoresMouseEvents];
310+
}
311+
285312
void Window::SetFocusable(bool is_focusable) {
286313
// TODO: Implement this
287314
}

0 commit comments

Comments
 (0)