@@ -278,32 +278,23 @@ std::optional<int> CountClassInSubtreeRaw(
278278 return count;
279279}
280280
281- std::optional<TabContainer> FindTabContainerFromHwnd (
282- const ComPtr<IUIAutomation>& automation,
283- HWND hwnd) {
284- auto root = GetElementFromHandle (automation, hwnd);
285- if (!root) {
286- return std::nullopt ;
287- }
288-
289- if (auto c = FindFirstInSubtree (
290- root, CreateClassCondition (automation, L" TabContainerImpl" )))
291- return TabContainer{c, L" Tab" };
292- if (auto c = FindFirstInSubtree (
293- root, CreateClassCondition (automation,
294- L" VerticalUnpinnedTabContainerView" ))) {
295- return TabContainer{c, L" VerticalTabView" };
281+ bool IsWindowFullScreen (HWND hwnd) {
282+ RECT window_rect;
283+ if (!GetWindowRect (hwnd, &window_rect)) {
284+ return false ;
296285 }
297-
298- if (auto c = FindFirstInSubtreeRaw (automation, root, L" TabContainerImpl " ) ) {
299- return TabContainer{c, L" Tab " } ;
286+ HMONITOR monitor = MonitorFromWindow (hwnd, MONITOR_DEFAULTTONEAREST);
287+ if (!monitor ) {
288+ return false ;
300289 }
301- if ( auto c = FindFirstInSubtreeRaw (automation, root,
302- L" VerticalUnpinnedTabContainerView " )) {
303- return TabContainer{c, L" VerticalTabView " } ;
290+ MONITORINFO mi = { sizeof (mi)};
291+ if (! GetMonitorInfoW (monitor, &mi )) {
292+ return false ;
304293 }
305-
306- return std::nullopt ;
294+ return window_rect.left == mi.rcMonitor .left &&
295+ window_rect.top == mi.rcMonitor .top &&
296+ window_rect.right == mi.rcMonitor .right &&
297+ window_rect.bottom == mi.rcMonitor .bottom ;
307298}
308299
309300ComPtr<IUIAutomationElement> FindSiblingByClass (
@@ -340,6 +331,55 @@ ComPtr<IUIAutomationElement> FindSiblingByClass(
340331 return nullptr ;
341332}
342333
334+ std::optional<TabContainer> FindTabContainerFromHwnd (
335+ const ComPtr<IUIAutomation>& automation,
336+ HWND hwnd) {
337+ auto root = GetElementFromHandle (automation, hwnd);
338+ if (!root) {
339+ return std::nullopt ;
340+ }
341+
342+ if (auto tab_strip = FindFirstInSubtree (
343+ root,
344+ CreateClassCondition (automation, L" TabStrip::TabDragContextImpl" ))) {
345+ if (auto c =
346+ FindSiblingByClass (automation, tab_strip, L" TabContainerImpl" )) {
347+ return TabContainer{c, L" Tab" };
348+ }
349+ }
350+
351+ if (auto tab_strip_region = FindFirstInSubtree (
352+ root,
353+ CreateClassCondition (automation, L" HorizontalTabStripRegionView" ))) {
354+ if (auto c = FindFirstInSubtree (
355+ tab_strip_region,
356+ CreateClassCondition (automation, L" TabContainerImpl" ))) {
357+ return TabContainer{c, L" Tab" };
358+ }
359+ }
360+
361+ if (auto c = FindFirstInSubtree (
362+ root, CreateClassCondition (automation,
363+ L" VerticalUnpinnedTabContainerView" ))) {
364+ return TabContainer{c, L" VerticalTabView" };
365+ }
366+
367+ if (!IsWindowFullScreen (hwnd)) {
368+ return std::nullopt ;
369+ }
370+
371+ if (auto c = FindFirstInSubtreeRaw (automation, root, L" TabContainerImpl" )) {
372+ return TabContainer{c, L" Tab" };
373+ }
374+
375+ if (auto c = FindFirstInSubtreeRaw (automation, root,
376+ L" VerticalUnpinnedTabContainerView" )) {
377+ return TabContainer{c, L" VerticalTabView" };
378+ }
379+
380+ return std::nullopt ;
381+ }
382+
343383ComPtr<IUIAutomationElement> FindParentByClass (
344384 const ComPtr<IUIAutomation>& automation,
345385 const ComPtr<IUIAutomationElement>& element,
0 commit comments