aboutsummaryrefslogtreecommitdiff
path: root/src/ui/host/WindowHost.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/host/WindowHost.cpp')
-rw-r--r--src/ui/host/WindowHost.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/ui/host/WindowHost.cpp b/src/ui/host/WindowHost.cpp
index f4a9a928..737a7594 100644
--- a/src/ui/host/WindowHost.cpp
+++ b/src/ui/host/WindowHost.cpp
@@ -7,6 +7,7 @@
#include "cru/platform/gui/InputMethod.h"
#include "cru/platform/gui/UiApplication.h"
#include "cru/platform/gui/Window.h"
+#include "cru/ui/Base.h"
#include "cru/ui/DebugFlags.h"
#include "cru/ui/host/LayoutPaintCycler.h"
#include "cru/ui/render/MeasureRequirement.h"
@@ -105,6 +106,15 @@ inline void BindNativeEvent(
}
} // namespace
+int WindowHost::event_handling_depth_ = 0;
+
+void WindowHost::EnterEventHandling() { event_handling_depth_++; }
+
+void WindowHost::LeaveEventHandling() {
+ Expects(event_handling_depth_ > 0);
+ event_handling_depth_--;
+}
+
WindowHost::WindowHost(controls::Control* root_control)
: root_control_(root_control), focus_control_(root_control) {
root_render_object_ = root_control->GetRenderObject();
@@ -438,4 +448,16 @@ void WindowHost::SetOverrideCursor(
override_cursor_ = cursor;
UpdateCursor();
}
+
+void WindowHost::OnControlDetach(controls::Control* control) {
+ if (GetFocusControl() == control) {
+ SetFocusControl(nullptr);
+ }
+ if (GetMouseCaptureControl() == control) {
+ CaptureMouseFor(nullptr);
+ }
+ if (GetMouseHoverControl() == control) {
+ mouse_hover_control_ = HitTest(GetNativeWindow()->GetMousePosition());
+ }
+}
} // namespace cru::ui::host