mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-12 18:29:24 +08:00
Spelling: ... shortcut guide (#3790)
* spelling: dimension * spelling: hidden * spelling: miniature * spelling: parent * spelling: popin * spelling: signal * spelling: suppress
This commit is contained in:
parent
df93f4ba99
commit
ac6b9712ad
@ -315,7 +315,7 @@ void D2DOverlayWindow::animate(int vk_code, int offset)
|
|||||||
AnimateKeys animation;
|
AnimateKeys animation;
|
||||||
std::wstring id;
|
std::wstring id;
|
||||||
animation.vk_code = vk_code;
|
animation.vk_code = vk_code;
|
||||||
winrt::com_ptr<ID2D1SvgElement> button_letter, parrent;
|
winrt::com_ptr<ID2D1SvgElement> button_letter, parent;
|
||||||
if (vk_code >= 0x41 && vk_code <= 0x5A)
|
if (vk_code >= 0x41 && vk_code <= 0x5A)
|
||||||
{
|
{
|
||||||
id.push_back('A' + (vk_code - 0x41));
|
id.push_back('A' + (vk_code - 0x41));
|
||||||
@ -373,16 +373,16 @@ void D2DOverlayWindow::animate(int vk_code, int offset)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
button_letter->GetParent(parrent.put());
|
button_letter->GetParent(parent.put());
|
||||||
if (!parrent)
|
if (!parent)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
parrent->GetPreviousChild(button_letter.get(), animation.button.put());
|
parent->GetPreviousChild(button_letter.get(), animation.button.put());
|
||||||
if (!animation.button || !animation.button->IsAttributeSpecified(L"fill"))
|
if (!animation.button || !animation.button->IsAttributeSpecified(L"fill"))
|
||||||
{
|
{
|
||||||
animation.button = nullptr;
|
animation.button = nullptr;
|
||||||
parrent->GetNextChild(button_letter.get(), animation.button.put());
|
parent->GetNextChild(button_letter.get(), animation.button.put());
|
||||||
}
|
}
|
||||||
if (!animation.button || !animation.button->IsAttributeSpecified(L"fill"))
|
if (!animation.button || !animation.button->IsAttributeSpecified(L"fill"))
|
||||||
{
|
{
|
||||||
@ -626,7 +626,7 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d2d_dc->Clear();
|
d2d_dc->Clear();
|
||||||
int x_offset = 0, y_offset = 0, dimention = 0;
|
int x_offset = 0, y_offset = 0, dimension = 0;
|
||||||
auto current_anim_value = (float)animation.value(Animation::AnimFunctions::LINEAR);
|
auto current_anim_value = (float)animation.value(Animation::AnimFunctions::LINEAR);
|
||||||
SetLayeredWindowAttributes(hwnd, 0, (int)(255 * current_anim_value), LWA_ALPHA);
|
SetLayeredWindowAttributes(hwnd, 0, (int)(255 * current_anim_value), LWA_ALPHA);
|
||||||
double pos_anim_value = 1 - animation.value(Animation::AnimFunctions::EASE_OUT_EXPO);
|
double pos_anim_value = 1 - animation.value(Animation::AnimFunctions::EASE_OUT_EXPO);
|
||||||
@ -668,7 +668,7 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc)
|
|||||||
// Thumbnail logic:
|
// Thumbnail logic:
|
||||||
auto window_state = get_window_state(active_window);
|
auto window_state = get_window_state(active_window);
|
||||||
auto thumb_window = get_window_pos(active_window);
|
auto thumb_window = get_window_pos(active_window);
|
||||||
bool minature_shown = active_window != nullptr && thumbnail != nullptr && thumb_window && window_state != MINIMIZED;
|
bool miniature_shown = active_window != nullptr && thumbnail != nullptr && thumb_window && window_state != MINIMIZED;
|
||||||
RECT client_rect;
|
RECT client_rect;
|
||||||
if (thumb_window && GetClientRect(active_window, &client_rect))
|
if (thumb_window && GetClientRect(active_window, &client_rect))
|
||||||
{
|
{
|
||||||
@ -679,9 +679,9 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc)
|
|||||||
thumb_window->top += dy;
|
thumb_window->top += dy;
|
||||||
thumb_window->bottom -= dy;
|
thumb_window->bottom -= dy;
|
||||||
}
|
}
|
||||||
if (minature_shown && thumb_window->right - thumb_window->left <= 0 || thumb_window->bottom - thumb_window->top <= 0)
|
if (miniature_shown && thumb_window->right - thumb_window->left <= 0 || thumb_window->bottom - thumb_window->top <= 0)
|
||||||
{
|
{
|
||||||
minature_shown = false;
|
miniature_shown = false;
|
||||||
}
|
}
|
||||||
bool render_monitors = true;
|
bool render_monitors = true;
|
||||||
auto total_monitor_with_screen = total_screen;
|
auto total_monitor_with_screen = total_screen;
|
||||||
@ -703,7 +703,7 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc)
|
|||||||
total_monitor_with_screen = total_screen;
|
total_monitor_with_screen = total_screen;
|
||||||
}
|
}
|
||||||
auto rect_and_scale = use_overlay->get_thumbnail_rect_and_scale(0, 0, total_monitor_with_screen.width(), total_monitor_with_screen.height(), 1);
|
auto rect_and_scale = use_overlay->get_thumbnail_rect_and_scale(0, 0, total_monitor_with_screen.width(), total_monitor_with_screen.height(), 1);
|
||||||
if (minature_shown)
|
if (miniature_shown)
|
||||||
{
|
{
|
||||||
RECT thumbnail_pos;
|
RECT thumbnail_pos;
|
||||||
if (render_monitors)
|
if (render_monitors)
|
||||||
@ -719,7 +719,7 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc)
|
|||||||
}
|
}
|
||||||
// If the animation is done show the thumbnail
|
// If the animation is done show the thumbnail
|
||||||
// we cannot animate the thumbnail, the animation lags behind
|
// we cannot animate the thumbnail, the animation lags behind
|
||||||
minature_shown = show_thumbnail(thumbnail_pos, current_anim_value);
|
miniature_shown = show_thumbnail(thumbnail_pos, current_anim_value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -732,7 +732,7 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc)
|
|||||||
// render the monitors
|
// render the monitors
|
||||||
if (render_monitors)
|
if (render_monitors)
|
||||||
{
|
{
|
||||||
brushColor = D2D1::ColorF(colors.desktop_fill_color, minature_shown ? current_anim_value : current_anim_value * 0.3f);
|
brushColor = D2D1::ColorF(colors.desktop_fill_color, miniature_shown ? current_anim_value : current_anim_value * 0.3f);
|
||||||
brush = nullptr;
|
brush = nullptr;
|
||||||
winrt::check_hresult(d2d_dc->CreateSolidColorBrush(brushColor, brush.put()));
|
winrt::check_hresult(d2d_dc->CreateSolidColorBrush(brushColor, brush.put()));
|
||||||
for (auto& monitor : monitors)
|
for (auto& monitor : monitors)
|
||||||
@ -747,16 +747,16 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Finalize the overlay - dimm the buttons if no thumbnail is present and show "No active window"
|
// Finalize the overlay - dimm the buttons if no thumbnail is present and show "No active window"
|
||||||
use_overlay->toggle_window_group(minature_shown || window_state == MINIMIZED);
|
use_overlay->toggle_window_group(miniature_shown || window_state == MINIMIZED);
|
||||||
if (!minature_shown && window_state != MINIMIZED)
|
if (!miniature_shown && window_state != MINIMIZED)
|
||||||
{
|
{
|
||||||
no_active.render(d2d_dc);
|
no_active.render(d2d_dc);
|
||||||
window_state = UNKNOWN;
|
window_state = UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the animation - move the draw window according to animation step
|
// Set the animation - move the draw window according to animation step
|
||||||
auto popin = D2D1::Matrix3x2F::Translation((float)x_offset, (float)y_offset);
|
auto popIn = D2D1::Matrix3x2F::Translation((float)x_offset, (float)y_offset);
|
||||||
d2d_dc->SetTransform(popin);
|
d2d_dc->SetTransform(popIn);
|
||||||
|
|
||||||
// Animate keys
|
// Animate keys
|
||||||
for (unsigned id = 0; id < key_animations.size();)
|
for (unsigned id = 0; id < key_animations.size();)
|
||||||
@ -862,7 +862,7 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc)
|
|||||||
down = GET_RESOURCE_STRING(IDS_NO_ACTION);
|
down = GET_RESOURCE_STRING(IDS_NO_ACTION);
|
||||||
down_disabled = true;
|
down_disabled = true;
|
||||||
}
|
}
|
||||||
auto text_color = D2D1::ColorF(light_mode ? 0x222222 : 0xDDDDDD, active_window_snappable && (minature_shown || window_state == MINIMIZED) ? 1.0f : 0.3f);
|
auto text_color = D2D1::ColorF(light_mode ? 0x222222 : 0xDDDDDD, active_window_snappable && (miniature_shown || window_state == MINIMIZED) ? 1.0f : 0.3f);
|
||||||
use_overlay->find_element(L"KeyUpGroup")->SetAttributeValue(L"fill-opacity", up_disabled ? 0.3f : 1.0f);
|
use_overlay->find_element(L"KeyUpGroup")->SetAttributeValue(L"fill-opacity", up_disabled ? 0.3f : 1.0f);
|
||||||
text.set_alignment_center().write(d2d_dc, text_color, use_overlay->get_maximize_label(), up);
|
text.set_alignment_center().write(d2d_dc, text_color, use_overlay->get_maximize_label(), up);
|
||||||
use_overlay->find_element(L"KeyDownGroup")->SetAttributeValue(L"fill-opacity", down_disabled ? 0.3f : 1.0f);
|
use_overlay->find_element(L"KeyDownGroup")->SetAttributeValue(L"fill-opacity", down_disabled ? 0.3f : 1.0f);
|
||||||
|
@ -222,7 +222,7 @@ void OverlayWindow::quick_hide()
|
|||||||
|
|
||||||
void OverlayWindow::was_hidden()
|
void OverlayWindow::was_hidden()
|
||||||
{
|
{
|
||||||
target_state->was_hiden();
|
target_state->was_hidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverlayWindow::destroy()
|
void OverlayWindow::destroy()
|
||||||
|
@ -23,18 +23,18 @@ bool TargetState::signal_event(unsigned vk_code, bool key_down)
|
|||||||
// It can be safely done when the user releases the WinKey.
|
// It can be safely done when the user releases the WinKey.
|
||||||
instance->quick_hide();
|
instance->quick_hide();
|
||||||
}
|
}
|
||||||
bool supress = false;
|
bool suppress = false;
|
||||||
if (!key_down && (vk_code == VK_LWIN || vk_code == VK_RWIN) &&
|
if (!key_down && (vk_code == VK_LWIN || vk_code == VK_RWIN) &&
|
||||||
state == Shown &&
|
state == Shown &&
|
||||||
std::chrono::system_clock::now() - singnal_timestamp > std::chrono::milliseconds(300) &&
|
std::chrono::system_clock::now() - signal_timestamp > std::chrono::milliseconds(300) &&
|
||||||
!key_was_pressed)
|
!key_was_pressed)
|
||||||
{
|
{
|
||||||
supress = true;
|
suppress = true;
|
||||||
}
|
}
|
||||||
events.push_back({ key_down, vk_code });
|
events.push_back({ key_down, vk_code });
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
cv.notify_one();
|
cv.notify_one();
|
||||||
if (supress)
|
if (suppress)
|
||||||
{
|
{
|
||||||
// Send a fake key-stroke to prevent the start menu from appearing.
|
// Send a fake key-stroke to prevent the start menu from appearing.
|
||||||
// We use 0xCF VK code, which is reserved. It still prevents the
|
// We use 0xCF VK code, which is reserved. It still prevents the
|
||||||
@ -54,10 +54,10 @@ bool TargetState::signal_event(unsigned vk_code, bool key_down)
|
|||||||
input[2].ki.dwExtraInfo = CommonSharedConstants::KEYBOARDMANAGER_INJECTED_FLAG;
|
input[2].ki.dwExtraInfo = CommonSharedConstants::KEYBOARDMANAGER_INJECTED_FLAG;
|
||||||
SendInput(3, input, sizeof(INPUT));
|
SendInput(3, input, sizeof(INPUT));
|
||||||
}
|
}
|
||||||
return supress;
|
return suppress;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetState::was_hiden()
|
void TargetState::was_hidden()
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(mutex);
|
std::unique_lock<std::mutex> lock(mutex);
|
||||||
state = Hidden;
|
state = Hidden;
|
||||||
@ -173,7 +173,7 @@ void TargetState::handle_timeout()
|
|||||||
}
|
}
|
||||||
if (std::chrono::system_clock::now() - winkey_timestamp < delay)
|
if (std::chrono::system_clock::now() - winkey_timestamp < delay)
|
||||||
return;
|
return;
|
||||||
singnal_timestamp = std::chrono::system_clock::now();
|
signal_timestamp = std::chrono::system_clock::now();
|
||||||
key_was_pressed = false;
|
key_was_pressed = false;
|
||||||
state = Shown;
|
state = Shown;
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
@ -17,7 +17,7 @@ class TargetState
|
|||||||
public:
|
public:
|
||||||
TargetState(int ms_delay);
|
TargetState(int ms_delay);
|
||||||
bool signal_event(unsigned vk_code, bool key_down);
|
bool signal_event(unsigned vk_code, bool key_down);
|
||||||
void was_hiden();
|
void was_hidden();
|
||||||
void exit();
|
void exit();
|
||||||
void set_delay(int ms_delay);
|
void set_delay(int ms_delay);
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ private:
|
|||||||
void thread_proc();
|
void thread_proc();
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
std::condition_variable cv;
|
std::condition_variable cv;
|
||||||
std::chrono::system_clock::time_point winkey_timestamp, singnal_timestamp;
|
std::chrono::system_clock::time_point winkey_timestamp, signal_timestamp;
|
||||||
std::chrono::milliseconds delay;
|
std::chrono::milliseconds delay;
|
||||||
std::deque<KeyEvent> events;
|
std::deque<KeyEvent> events;
|
||||||
enum
|
enum
|
||||||
|
Loading…
Reference in New Issue
Block a user