mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
ShortcutGuide, FancyZones: split window filtering (#1225)
Splits the code use to filter windows for FancyZones and the "active window" for the ShortcutGuide. The FancyZones logic is preserved and merged into a single function. We keep it in common.h, as it might be also used in other PowerToys, like maximized to new desktop. We do however change the return type to be more descriptive. It also returns a separate flag for if the window has a visible owner. This can be used to implement the approved apps list. For the ShortcutGuide, the logic is relaxed to include more windows. One example are Explorer properties windows. Those are (and should) filtered by the FancyZones, but should appear in the window preview in the SCG. The new return type also includes information if the window will react to the default Windows Snap. This is not ideal though. Currently, SCG can only disable the entire "Windows Controls" group. OTOH windows like "Save As..." dialogs can be snapped to corners etc., but cannot be minimized nor maximized. Until SCG can separately disable those buttons we will display the buttons in the enabled state only if the window supports all settings. In the future, we should integrate FancyZones snap override here too.
This commit is contained in:
committed by
GitHub
parent
f963d28ba8
commit
0fdc1d0a1f
@@ -13,15 +13,21 @@ std::optional<RECT> get_window_pos(HWND hwnd);
|
||||
// Gets mouse postion.
|
||||
std::optional<POINT> get_mouse_pos();
|
||||
|
||||
// Gets window ancestor (usualy the window we want to do stuff with), filtering out all "non standard" windows like the taskbar, etc. and provide the app process path
|
||||
struct WindowAndProcPath {
|
||||
HWND hwnd = nullptr;
|
||||
std::wstring process_path;
|
||||
// Test if window can be zoned by FancyZones
|
||||
struct FancyZonesFilter {
|
||||
bool zonable = false; // If the window is zonable by FancyZones by default - true when both standard_window and no_visible_owner are also true
|
||||
bool standard_window = false; // True if from the styles the window looks like a standard window
|
||||
bool no_visible_owner = false; // True if the window is a top-level window that does not have a visible owner
|
||||
std::wstring process_path; // Path to the executable owning the window
|
||||
};
|
||||
WindowAndProcPath get_filtered_base_window_and_path(HWND window);
|
||||
// Gets active window, filtering out all "non standard" windows like the taskbar, etc.
|
||||
HWND get_filtered_active_window();
|
||||
FancyZonesFilter get_fancyzones_filtered_window(HWND window);
|
||||
|
||||
// Gets active foreground window, filtering out all "non standard" windows like the taskbar, etc.
|
||||
struct ShortcutGuideFilter {
|
||||
HWND hwnd = nullptr; // Handle to the top-level foreground window or nullptr if there is no such window
|
||||
bool snappable = false; // True, if the window can react to Windows Snap keys
|
||||
};
|
||||
ShortcutGuideFilter get_shortcutguide_filtered_window();
|
||||
|
||||
// Calculate sizes
|
||||
int width(const RECT& rect);
|
||||
|
||||
Reference in New Issue
Block a user