-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alex Vallat
committed
Dec 26, 2020
1 parent
6d3f399
commit fc7c32b
Showing
4 changed files
with
92 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Windows.Forms; | ||
using Accessibility; | ||
using CommandLine; | ||
|
||
namespace KeyLayoutAutoSwitch | ||
{ | ||
internal class Chrome : Browser | ||
{ | ||
public override FocusType GetFocusType(IAccessible accessibleObject, out string url) | ||
{ | ||
url = null; | ||
|
||
// Walk up tree finding parent | ||
var parent = accessibleObject; | ||
while (parent != null) | ||
{ | ||
var role = AccessibleObjectHelper.GetRole(parent); | ||
if (role == AccessibleRole.Document && AccessibleObjectHelper.HasState(accessibleObject, AccessibleStates.Focusable)) | ||
{ | ||
// This is a web page | ||
url = AccessibleObjectHelper.GetValue(parent); | ||
return FocusType.Page; | ||
} | ||
|
||
parent = parent.accParent as IAccessible; | ||
} | ||
|
||
return FocusType.Other; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Windows.Forms; | ||
using Accessibility; | ||
using CommandLine; | ||
|
||
namespace KeyLayoutAutoSwitch | ||
{ | ||
internal class ChromeWidgets : Browser | ||
{ | ||
public override FocusType GetFocusType(IAccessible accessibleObject, out string url) | ||
{ | ||
url = null; | ||
|
||
// Walk up tree finding parent | ||
var parent = accessibleObject; | ||
while (parent != null) | ||
{ | ||
var role = AccessibleObjectHelper.GetRole(parent); | ||
if (role == AccessibleRole.Text && AccessibleObjectHelper.HasState(accessibleObject, AccessibleStates.Focusable)) | ||
{ | ||
// Could be the location bar, if the parent is a grouping | ||
if (accessibleObject.accParent is IAccessible immediateParent) | ||
{ | ||
if (AccessibleObjectHelper.GetRole(immediateParent) == AccessibleRole.Grouping && (AccessibleStates)immediateParent.accState[0] == AccessibleStates.None) | ||
{ | ||
return FocusType.Location; | ||
} | ||
else | ||
{ | ||
if (AccessibleObjectHelper.FindAncestor(immediateParent, AccessibleRole.Dialog) != null) | ||
{ | ||
return FocusType.FindInPage; | ||
} | ||
} | ||
} | ||
} | ||
parent = parent.accParent as IAccessible; | ||
} | ||
|
||
return FocusType.Other; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters