Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(655)

Unified Diff: ui/base/win/osk_display_manager.cc

Issue 2971363002: Detect if osk is visible on windows (Closed)
Patch Set: Refactoring base function Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/win/osk_display_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/win/osk_display_manager.cc
diff --git a/ui/base/win/osk_display_manager.cc b/ui/base/win/osk_display_manager.cc
index 0373b48bdd39f79b4f04d4ea45d1326c68a7e48f..5d9e7c3ecb42e6319b72017d16d3e2e97dccf2bb 100644
--- a/ui/base/win/osk_display_manager.cc
+++ b/ui/base/win/osk_display_manager.cc
@@ -63,6 +63,9 @@ class OnScreenKeyboardDetector {
void AddObserver(OnScreenKeyboardObserver* observer);
void RemoveObserver(OnScreenKeyboardObserver* observer);
+ // Returns true if the osk is visible. Sets osk bounding rect if non-null
+ static bool IsKeyboardVisible(gfx::Rect* osk_bounding_rect);
+
private:
// Executes as a task and detects if the on screen keyboard is displayed.
// Once the keyboard is displayed it schedules the HideIfNecessary() task to
@@ -166,15 +169,21 @@ void OnScreenKeyboardDetector::RemoveObserver(
observers_.RemoveObserver(observer);
}
-void OnScreenKeyboardDetector::CheckIfKeyboardVisible() {
+// static
+bool OnScreenKeyboardDetector::IsKeyboardVisible(gfx::Rect* osk_bounding_rect) {
HWND osk = ::FindWindow(kOSKClassName, nullptr);
if (!::IsWindow(osk))
- return;
+ return false;
+ if (osk_bounding_rect) {
+ RECT osk_rect = {};
+ ::GetWindowRect(osk, &osk_rect);
+ *osk_bounding_rect = gfx::Rect(osk_rect);
+ }
+ return ::IsWindowVisible(osk) && ::IsWindowEnabled(osk);
+}
- RECT osk_rect = {};
- ::GetWindowRect(osk, &osk_rect);
- osk_rect_pixels_ = gfx::Rect(osk_rect);
- if (::IsWindowVisible(osk) && ::IsWindowEnabled(osk)) {
+void OnScreenKeyboardDetector::CheckIfKeyboardVisible() {
+ if (IsKeyboardVisible(&osk_rect_pixels_)) {
if (!osk_visible_notification_received_)
HandleKeyboardVisible();
} else {
@@ -360,4 +369,8 @@ bool OnScreenKeyboardDisplayManager::GetOSKPath(base::string16* osk_path) {
return !osk_path->empty();
}
+bool OnScreenKeyboardDisplayManager::IsKeyboardVisible() const {
+ return OnScreenKeyboardDetector::IsKeyboardVisible(nullptr);
+}
+
} // namespace ui
« no previous file with comments | « ui/base/win/osk_display_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698