From 2e740e6c33dc501a488d2ab4fbd46379823f8ca0 Mon Sep 17 00:00:00 2001 From: pit-ray <42631247+pit-ray@users.noreply.github.com> Date: Sat, 18 May 2024 17:15:56 +0900 Subject: [PATCH 1/5] Add showcmd (#236) * update version * show the matching characters to the count * add showcmd option * add document * fix build script * fix cmakelists.txt * support the visualization for count * add document of showcmd * update document --- CMakeLists.txt | 4 ++-- docs/cheat_sheet/options/index.md | 13 ++++++++++-- src/core/entry.cpp | 35 ++++++++++++++++++++++++++++++- src/core/inputhub.cpp | 3 +++ src/core/inputhub.hpp | 2 +- src/core/settable.cpp | 1 + src/core/version.hpp | 2 +- tools/build.bat | 12 +++++------ 8 files changed, 59 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f06671f9..941e5145 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.6.0) -project(win-vind VERSION 5.12.0) -set(INTERNAL_VERSION ${PROJECT_VERSION}.0) +project(win-vind VERSION 5.13.0) +set(INTERNAL_VERSION ${PROJECT_VERSION}.1) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) diff --git a/docs/cheat_sheet/options/index.md b/docs/cheat_sheet/options/index.md index c5911c8e..04bdd2b3 100644 --- a/docs/cheat_sheet/options/index.md +++ b/docs/cheat_sheet/options/index.md @@ -49,12 +49,21 @@ Font size of GUI Specify the characters of hint used for EasyClick and GridMove. It accpets as input a set of non-duplicate characters and assigns them to the hints in order from the first to the last. - ## Command Line ### **`vcmdline`** **type**: bool, **default**: true -show virtual command line +Show virtual command line + +
+ +### **`showcmd`** +**type**: bool, **default**: true +Show the partial command in the virtual command line. +This feature causes some overhead. +If the count of repeats for a command is specified, the command is displayed following the count of repeats. +If you do not enter a repeat count for a command, then the repeat count is denoted as 1. +Unlike Vim, the repeat count is always explicitly displayed to reduce mistakes in the repeat count.
diff --git a/src/core/entry.cpp b/src/core/entry.cpp index 9fc4804b..a5444dd4 100644 --- a/src/core/entry.cpp +++ b/src/core/entry.cpp @@ -60,6 +60,7 @@ SOFTWARE. #include #include #include +#include #include "autocmd.hpp" @@ -317,6 +318,7 @@ namespace vind void VindEntry::update() { auto& ihub = InputHub::get_instance() ; + auto& settable = SetTable::get_instance() ; // NOTE: it assume that these hwnd are fixed. static const auto desktop_hwnd = GetDesktopWindow() ; @@ -370,10 +372,41 @@ namespace vind do { CmdUnit::SPtr input ; - std::uint16_t count ; + std::uint16_t count = 0 ; if(!ihub.pull_input(input, count)) { + if(count > 0) { + opt::VCmdLine::reset() ; + opt::VCmdLine::print(opt::StaticMessage(std::to_string(count))) ; + } continue ; } + + if(settable.get("showcmd").get()) { + auto solver = ihub.get_solver() ; + for(const auto& matcher : solver->get_trigger_matchers()) { + if(!matcher->is_matching()) { + continue ; + } + auto hist_size = matcher->history_size() ; + // If the any matcher isn't matched, the history size is zero. + if(hist_size == 0) { + opt::VCmdLine::reset() ; + break ; + } + std::stringstream ss ; + ss << count ; + + auto cmd = matcher->get_command() ; + auto end_itr = cmd.begin() + hist_size ; + for(auto itr = cmd.begin() ; itr != end_itr ; itr ++) { + ss << **itr ; + } + opt::VCmdLine::reset() ; + opt::VCmdLine::print(opt::StaticMessage(ss.str())) ; + break ; + } + } + handle_system_call(input->execute(count)) ; // correct the state to avoid cases that a virtual key diff --git a/src/core/inputhub.cpp b/src/core/inputhub.cpp index bbef4866..f30e3e76 100644 --- a/src/core/inputhub.cpp +++ b/src/core/inputhub.cpp @@ -151,6 +151,9 @@ namespace vind *input, pimpl->count_.size() > 0) ; if(!new_count.empty()) { pimpl->count_ += new_count ; + + // Store the count number, but return as false. + count = util::extract_num(pimpl->count_) ; return false ; } } diff --git a/src/core/inputhub.hpp b/src/core/inputhub.hpp index 3b2a1862..b6666d38 100644 --- a/src/core/inputhub.hpp +++ b/src/core/inputhub.hpp @@ -27,7 +27,7 @@ namespace vind public: static InputHub& get_instance() ; - std::shared_ptr get_solver(Mode mode) ; + std::shared_ptr get_solver(Mode mode=get_global_mode()) ; /* * Emulate text input and retrieve input at the appropriate time. diff --git a/src/core/settable.cpp b/src/core/settable.cpp index 5871310d..9d2ec132 100644 --- a/src/core/settable.cpp +++ b/src/core/settable.cpp @@ -82,6 +82,7 @@ namespace Param("uiacachebuild_stayend", 2000), Param("vcmdline", true), + Param("showcmd", true), Param("vscroll_pageratio", 0.125f), Param("vscroll_speed", 30), diff --git a/src/core/version.hpp b/src/core/version.hpp index 45521195..c95a7939 100644 --- a/src/core/version.hpp +++ b/src/core/version.hpp @@ -1,6 +1,6 @@ #ifndef _VERSION_HPP #define _VERSION_HPP -#define WIN_VIND_VERSION "5.11.3.0" +#define WIN_VIND_VERSION "5.13.0.1" #endif diff --git a/tools/build.bat b/tools/build.bat index f6a85922..3987251b 100644 --- a/tools/build.bat +++ b/tools/build.bat @@ -39,11 +39,11 @@ @if %compiler% == -msvc ( if %3 == 32 ( - cmake -B release_32 -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 16 2019" -A win32 . + cmake -B release_32 -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 17 2022" -A win32 . cmake --build release_32 --config Release xcopy /E /Y release_32\Release\*.exe release_32 ) else ( - cmake -B release_64 -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 16 2019" -A x64 . + cmake -B release_64 -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 17 2022" -A x64 . cmake --build release_64 --config Release xcopy /E /Y release_64\Release\*.exe release_64 ) @@ -62,10 +62,10 @@ Del /q "debug/Debug" if "%3" == "32" ( - cmake -B debug -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 16 2019" -A win32 . + cmake -B debug -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 17 2022" -A win32 . cmake --build debug --config Debug ) else ( - INTERNALcmake -B debug -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 16 2019" -A x64 . + INTERNALcmake -B debug -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 17 2022" -A x64 . cmake --build debug --config Debug ) @@ -80,7 +80,7 @@ @set covdir=build_cov @if %compiler% == -msvc ( "cov_tools/bin/cov-configure" --config %covdir%/covtest/cov.xml --msvc --template --xml-option=skip_file:".*/libs.*" - cmake -B %covdir% -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 16 2019" -A x64 . + cmake -B %covdir% -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 17 2022" -A x64 . xcopy /e /Y %covdir%\Debug\*.exe %covdir% ) else ( @@ -97,7 +97,7 @@ :test cd tests @if %compiler% == -msvc ( - cmake -B build_msvc -G "Visual Studio 16 2019" unit + cmake -B build_msvc -G "Visual Studio 17 2022" unit cmake --build build_msvc ctest -C Debug --test-dir build_msvc --output-on-failure ) else ( From 5040853444f26b6a810276b365b106dceebc954c Mon Sep 17 00:00:00 2001 From: pit-ray Date: Mon, 20 May 2024 22:20:38 +0900 Subject: [PATCH 2/5] update version --- CMakeLists.txt | 2 +- README.md | 8 ++++---- docs/_config.yml | 10 +++++----- src/core/entry.cpp | 8 +++++--- src/core/version.hpp | 2 +- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 941e5145..56f9e6ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.6.0) project(win-vind VERSION 5.13.0) -set(INTERNAL_VERSION ${PROJECT_VERSION}.1) +set(INTERNAL_VERSION ${PROJECT_VERSION}.0) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) diff --git a/README.md b/README.md index ad0f8174..f2ba5256 100644 --- a/README.md +++ b/README.md @@ -64,12 +64,12 @@ $ scoop install win-vind ``` ### Executable Installer -- [win-vind_5.12.0_32bit_installer.zip](https://github.com/pit-ray/win-vind/releases/download/v5.12.0/win-vind_5.12.0_32bit_installer.zip) -- [win-vind_5.12.0_64bit_installer.zip](https://github.com/pit-ray/win-vind/releases/download/v5.12.0/win-vind_5.12.0_64bit_installer.zip) +- [win-vind_5.13.0_32bit_installer.zip](https://github.com/pit-ray/win-vind/releases/download/v5.13.0/win-vind_5.13.0_32bit_installer.zip) +- [win-vind_5.13.0_64bit_installer.zip](https://github.com/pit-ray/win-vind/releases/download/v5.13.0/win-vind_5.13.0_64bit_installer.zip) ### Portable Zip -- [win-vind_5.12.0_32bit_portable.zip](https://github.com/pit-ray/win-vind/releases/download/v5.12.0/win-vind_5.12.0_32bit_portable.zip) -- [win-vind_5.12.0_64bit_portable.zip](https://github.com/pit-ray/win-vind/releases/download/v5.12.0/win-vind_5.12.0_64bit_portable.zip) +- [win-vind_5.13.0_32bit_portable.zip](https://github.com/pit-ray/win-vind/releases/download/v5.13.0/win-vind_5.13.0_32bit_portable.zip) +- [win-vind_5.13.0_64bit_portable.zip](https://github.com/pit-ray/win-vind/releases/download/v5.13.0/win-vind_5.13.0_64bit_portable.zip) ## Usage diff --git a/docs/_config.yml b/docs/_config.yml index bf1b0a83..fff7c569 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -13,7 +13,7 @@ translations: # label: 日本語 project: - version: 5.12.0 + version: 5.13.0 download_url: downloads download_text: Download @@ -43,10 +43,10 @@ links: icon: comments url: https://github.com/pit-ray/win-vind/discussions -dl_ins_32: https://github.com/pit-ray/win-vind/releases/download/v5.12.0/win-vind_5.12.0_32bit_installer.zip -dl_zip_32: https://github.com/pit-ray/win-vind/releases/download/v5.12.0/win-vind_5.12.0_32bit_portable.zip -dl_ins_64: https://github.com/pit-ray/win-vind/releases/download/v5.12.0/win-vind_5.12.0_64bit_installer.zip -dl_zip_64: https://github.com/pit-ray/win-vind/releases/download/v5.12.0/win-vind_5.12.0_64bit_portable.zip +dl_ins_32: https://github.com/pit-ray/win-vind/releases/download/v5.13.0/win-vind_5.13.0_32bit_installer.zip +dl_zip_32: https://github.com/pit-ray/win-vind/releases/download/v5.13.0/win-vind_5.13.0_32bit_portable.zip +dl_ins_64: https://github.com/pit-ray/win-vind/releases/download/v5.13.0/win-vind_5.13.0_64bit_installer.zip +dl_zip_64: https://github.com/pit-ray/win-vind/releases/download/v5.13.0/win-vind_5.13.0_64bit_portable.zip ui: mode: 'light' # 'auto', 'dark', 'light' diff --git a/src/core/entry.cpp b/src/core/entry.cpp index a5444dd4..435035b0 100644 --- a/src/core/entry.cpp +++ b/src/core/entry.cpp @@ -374,9 +374,11 @@ namespace vind CmdUnit::SPtr input ; std::uint16_t count = 0 ; if(!ihub.pull_input(input, count)) { - if(count > 0) { - opt::VCmdLine::reset() ; - opt::VCmdLine::print(opt::StaticMessage(std::to_string(count))) ; + if(settable.get("showcmd").get()) { + if(count > 0) { + opt::VCmdLine::reset() ; + opt::VCmdLine::print(opt::StaticMessage(std::to_string(count))) ; + } } continue ; } diff --git a/src/core/version.hpp b/src/core/version.hpp index c95a7939..b63522c3 100644 --- a/src/core/version.hpp +++ b/src/core/version.hpp @@ -1,6 +1,6 @@ #ifndef _VERSION_HPP #define _VERSION_HPP -#define WIN_VIND_VERSION "5.13.0.1" +#define WIN_VIND_VERSION "5.13.0.0" #endif From b68bc03c5992519dba5a7ee86c124f0cf44afca9 Mon Sep 17 00:00:00 2001 From: pit-ray Date: Mon, 20 May 2024 22:30:34 +0900 Subject: [PATCH 3/5] fix vs version --- tools/build.bat | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/build.bat b/tools/build.bat index 3987251b..f6a85922 100644 --- a/tools/build.bat +++ b/tools/build.bat @@ -39,11 +39,11 @@ @if %compiler% == -msvc ( if %3 == 32 ( - cmake -B release_32 -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 17 2022" -A win32 . + cmake -B release_32 -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 16 2019" -A win32 . cmake --build release_32 --config Release xcopy /E /Y release_32\Release\*.exe release_32 ) else ( - cmake -B release_64 -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 17 2022" -A x64 . + cmake -B release_64 -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 16 2019" -A x64 . cmake --build release_64 --config Release xcopy /E /Y release_64\Release\*.exe release_64 ) @@ -62,10 +62,10 @@ Del /q "debug/Debug" if "%3" == "32" ( - cmake -B debug -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 17 2022" -A win32 . + cmake -B debug -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 16 2019" -A win32 . cmake --build debug --config Debug ) else ( - INTERNALcmake -B debug -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 17 2022" -A x64 . + INTERNALcmake -B debug -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 16 2019" -A x64 . cmake --build debug --config Debug ) @@ -80,7 +80,7 @@ @set covdir=build_cov @if %compiler% == -msvc ( "cov_tools/bin/cov-configure" --config %covdir%/covtest/cov.xml --msvc --template --xml-option=skip_file:".*/libs.*" - cmake -B %covdir% -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 17 2022" -A x64 . + cmake -B %covdir% -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 16 2019" -A x64 . xcopy /e /Y %covdir%\Debug\*.exe %covdir% ) else ( @@ -97,7 +97,7 @@ :test cd tests @if %compiler% == -msvc ( - cmake -B build_msvc -G "Visual Studio 17 2022" unit + cmake -B build_msvc -G "Visual Studio 16 2019" unit cmake --build build_msvc ctest -C Debug --test-dir build_msvc --output-on-failure ) else ( From 965a86a175a9a795aa5a424f88a0011f7d473037 Mon Sep 17 00:00:00 2001 From: pit-ray <42631247+pit-ray@users.noreply.github.com> Date: Sun, 16 Jun 2024 00:35:22 +0900 Subject: [PATCH 4/5] Fixed crash problem when computer is locked (#253) * update patch version * fix crash problem when computer is locked. --- CMakeLists.txt | 2 +- libs/fluent_tray/fluent_tray.hpp | 39 ++++++++++++++++---------------- src/bind/emu/motion.cpp | 12 +++++++--- src/bind/emu/replacetext.cpp | 4 +++- src/bind/mode/command_mode.cpp | 4 +++- src/bind/mode/instant_mode.cpp | 4 +++- src/bind/mouse/hinter.cpp | 4 +++- src/bind/mouse/jump_keybrd.cpp | 4 +++- src/bind/window/switch_win.cpp | 4 +++- src/bind/window/winresizer.cpp | 4 +++- src/core/background.cpp | 33 +++++++++++++++++++++++---- src/core/background.hpp | 3 ++- src/core/entry.cpp | 6 +++-- src/core/version.hpp | 2 +- 14 files changed, 86 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56f9e6ec..a1e802ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.6.0) -project(win-vind VERSION 5.13.0) +project(win-vind VERSION 5.13.1) set(INTERNAL_VERSION ${PROJECT_VERSION}.0) if(NOT CMAKE_BUILD_TYPE) diff --git a/libs/fluent_tray/fluent_tray.hpp b/libs/fluent_tray/fluent_tray.hpp index a608c92a..234f2d4d 100644 --- a/libs/fluent_tray/fluent_tray.hpp +++ b/libs/fluent_tray/fluent_tray.hpp @@ -937,26 +937,24 @@ namespace fluent_tray } POINT pos ; - if(!GetCursorPos(&pos)) { - return false ; - } - - if(pos.x != previous_mouse_pos_.x || pos.y != previous_mouse_pos_.y) { - // The mouse cursor is moved, so switch to the mouse-mode. - for(int i = 0 ; i < static_cast(menus_.size()) ; i ++) { - auto& menu = menus_[i] ; - auto detected_hwnd = WindowFromPoint(pos) ; - if(!detected_hwnd) { - return false ; - } - // Checks whether the mouse cursor is over the menu or not. - if(detected_hwnd == menu.window_handle()) { - // Start selection by key from the currently selected menu. - select_index_ = i ; - break ; + if(GetCursorPos(&pos)) { + if(pos.x != previous_mouse_pos_.x || pos.y != previous_mouse_pos_.y) { + // The mouse cursor is moved, so switch to the mouse-mode. + for(int i = 0 ; i < static_cast(menus_.size()) ; i ++) { + auto& menu = menus_[i] ; + auto detected_hwnd = WindowFromPoint(pos) ; + if(!detected_hwnd) { + return false ; + } + // Checks whether the mouse cursor is over the menu or not. + if(detected_hwnd == menu.window_handle()) { + // Start selection by key from the currently selected menu. + select_index_ = i ; + break ; + } } + previous_mouse_pos_ = pos ; } - previous_mouse_pos_ = pos ; } if(select_index_ < 0) { @@ -1422,7 +1420,10 @@ namespace fluent_tray if(!Shell_NotifyIconW(NIM_ADD, &icon_data_)) { return false ; } - hide_menu_window() ; + + if(!hide_menu_window()) { + return false ; + } return true ; } diff --git a/src/bind/emu/motion.cpp b/src/bind/emu/motion.cpp index 5a71cffc..252f33f5 100644 --- a/src/bind/emu/motion.cpp +++ b/src/bind/emu/motion.cpp @@ -56,7 +56,9 @@ namespace vind auto solver = ihub.get_solver(Mode::EDI_NORMAL) ; while(true) { - pimpl->bg_.update() ; + if(!pimpl->bg_.update()) { + continue ; + } core::CmdUnit::SPtr input ; std::uint16_t in_count ; @@ -118,7 +120,9 @@ namespace vind auto solver = ihub.get_solver(Mode::EDI_NORMAL) ; while(true) { - pimpl->bg_.update() ; + if(!pimpl->bg_.update()) { + continue ; + } core::CmdUnit::SPtr input ; std::uint16_t in_count ; @@ -178,7 +182,9 @@ namespace vind auto solver = ihub.get_solver(Mode::EDI_NORMAL) ; while(true) { - pimpl->bg_.update() ; + if(!pimpl->bg_.update()) { + continue ; + } core::CmdUnit::SPtr input ; std::uint16_t in_count ; diff --git a/src/bind/emu/replacetext.cpp b/src/bind/emu/replacetext.cpp index 98189e7b..247495f5 100644 --- a/src/bind/emu/replacetext.cpp +++ b/src/bind/emu/replacetext.cpp @@ -66,7 +66,9 @@ namespace } while(true) { - bg_.update() ; + if(!bg_.update()) { + continue ; + } if(igate.is_pressed(KEYCODE_ESC)) { return ; diff --git a/src/bind/mode/command_mode.cpp b/src/bind/mode/command_mode.cpp index df012e44..553020e9 100644 --- a/src/bind/mode/command_mode.cpp +++ b/src/bind/mode/command_mode.cpp @@ -355,7 +355,9 @@ namespace vind auto result = SystemCall::SUCCEEDED ; ac.apply(core::get_enter_event(core::Mode::COMMAND)) ; while(true) { - pimpl->bg_.update() ; + if(!pimpl->bg_.update()) { + continue ; + } bool break_flag = false ; do { diff --git a/src/bind/mode/instant_mode.cpp b/src/bind/mode/instant_mode.cpp index 6ab75ec3..4edad75d 100644 --- a/src/bind/mode/instant_mode.cpp +++ b/src/bind/mode/instant_mode.cpp @@ -58,7 +58,9 @@ namespace vind auto res = SystemCall::SUCCEEDED ; while(true) { - pimpl->bg_.update() ; + if(!pimpl->bg_.update()) { + continue ; + } std::vector inputs ; std::vector in_counts ; diff --git a/src/bind/mouse/hinter.cpp b/src/bind/mouse/hinter.cpp index 2b644a42..aa9b9a9f 100644 --- a/src/bind/mouse/hinter.cpp +++ b/src/bind/mouse/hinter.cpp @@ -182,7 +182,9 @@ namespace vind points, hint_texts, start_indices, mtxes) ; while(true) { - pimpl->bg_.update() ; + if(!pimpl->bg_.update()) { + continue ; + } // To use combined macros like , // get the keys from the input queue rather than the mapped queue. diff --git a/src/bind/mouse/jump_keybrd.cpp b/src/bind/mouse/jump_keybrd.cpp index 80c4edfe..fca78a5a 100644 --- a/src/bind/mouse/jump_keybrd.cpp +++ b/src/bind/mouse/jump_keybrd.cpp @@ -70,7 +70,9 @@ namespace vind auto toggle_keys = igate.pressed_list() ; while(true) { - pimpl->bg_.update() ; + if(!pimpl->bg_.update()) { + continue ; + } core::CmdUnit::SPtr inputs ; std::uint16_t count ; diff --git a/src/bind/window/switch_win.cpp b/src/bind/window/switch_win.cpp index 288a131b..9f1bd633 100644 --- a/src/bind/window/switch_win.cpp +++ b/src/bind/window/switch_win.cpp @@ -60,7 +60,9 @@ namespace vind auto mode = core::get_global_mode() ; while(true) { - pimpl->bg_.update() ; + if(!pimpl->bg_.update()) { + continue ; + } bool break_flag = false ; do { diff --git a/src/bind/window/winresizer.cpp b/src/bind/window/winresizer.cpp index bc4e51b2..587bc421 100644 --- a/src/bind/window/winresizer.cpp +++ b/src/bind/window/winresizer.cpp @@ -234,7 +234,9 @@ namespace vind core::InstantKeyAbsorber ika ; while(true) { - pimpl->bg_.update() ; + if(!pimpl->bg_.update()) { + continue ; + } bool break_flag = false ; do { diff --git a/src/core/background.cpp b/src/core/background.cpp index ca923227..5c529a3a 100644 --- a/src/core/background.cpp +++ b/src/core/background.cpp @@ -14,11 +14,19 @@ namespace vind { struct Background::Impl { std::vector opts_ ; + bool screen_is_locked_ ; template Impl(T&& opts) - : opts_(std::forward(opts)) + : opts_(std::forward(opts)), + screen_is_locked_(false) {} + + bool is_screen_locked() { + // GetCursorPos fails when the screen is locked. + POINT pos ; + return GetCursorPos(&pos) == 0 ; + } } ; Background::Background() @@ -35,22 +43,37 @@ namespace vind Background::~Background() noexcept = default ; - void Background::update() { - util::get_win_message() ; - + bool Background::update() { + auto& igate = InputGate::get_instance() ; Sleep(5) ; + if(pimpl->is_screen_locked()) { + if(!pimpl->screen_is_locked_) { + // Release all keys when the screen is locked. + for(auto& key : igate.pressed_list()) { + igate.release_virtually(key) ; + } + pimpl->screen_is_locked_ = true ; + } + return false ; + } + else if(pimpl->screen_is_locked_) { + pimpl->screen_is_locked_ = false ; + } + + util::get_win_message() ; + for(const auto& op : pimpl->opts_) { op->process() ; } - auto& igate = InputGate::get_instance() ; igate.refresh_toggle_state() ; if(igate.is_really_pressed(KEYCODE_F8) && \ igate.is_really_pressed(KEYCODE_F9)) { throw SafeForcedTermination() ; } + return true ; } } } diff --git a/src/core/background.hpp b/src/core/background.hpp index d5d648a3..c01a7287 100644 --- a/src/core/background.hpp +++ b/src/core/background.hpp @@ -28,7 +28,8 @@ namespace vind // If you make some loop functions, the function is needed to call. // It includes Sleep(). - void update() ; + // If this function returns false, should skip an iteration. + bool update() ; Background(const Background&) = delete ; Background& operator=(const Background&) = delete ; diff --git a/src/core/entry.cpp b/src/core/entry.cpp index 435035b0..ef9b6dc8 100644 --- a/src/core/entry.cpp +++ b/src/core/entry.cpp @@ -324,6 +324,10 @@ namespace vind static const auto desktop_hwnd = GetDesktopWindow() ; static const auto taskbar_hwnd = FindWindowA("Shell_TrayWnd", NULL) ; + if(!pimpl->bg_.update()) { + return ; + } + auto& ac = AutoCmd::get_instance() ; auto hwnd = util::get_foreground_window() ; auto procid = static_cast(0) ; @@ -343,8 +347,6 @@ namespace vind } } - pimpl->bg_.update() ; - // TODO: It is necessary to add exclusive handling when // write and read operations are performed at the same // time by multiple processes. However, these are extremely diff --git a/src/core/version.hpp b/src/core/version.hpp index b63522c3..b1a7e9c2 100644 --- a/src/core/version.hpp +++ b/src/core/version.hpp @@ -1,6 +1,6 @@ #ifndef _VERSION_HPP #define _VERSION_HPP -#define WIN_VIND_VERSION "5.13.0.0" +#define WIN_VIND_VERSION "5.13.1.0" #endif From f3c485a179994b7619e2f1a46257028ecc6ef7b2 Mon Sep 17 00:00:00 2001 From: pit-ray Date: Sun, 16 Jun 2024 00:36:43 +0900 Subject: [PATCH 5/5] update version --- CMakeLists.txt | 2 +- README.md | 8 ++++---- docs/_config.yml | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56f9e6ec..a1e802ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.6.0) -project(win-vind VERSION 5.13.0) +project(win-vind VERSION 5.13.1) set(INTERNAL_VERSION ${PROJECT_VERSION}.0) if(NOT CMAKE_BUILD_TYPE) diff --git a/README.md b/README.md index f2ba5256..a895b45d 100644 --- a/README.md +++ b/README.md @@ -64,12 +64,12 @@ $ scoop install win-vind ``` ### Executable Installer -- [win-vind_5.13.0_32bit_installer.zip](https://github.com/pit-ray/win-vind/releases/download/v5.13.0/win-vind_5.13.0_32bit_installer.zip) -- [win-vind_5.13.0_64bit_installer.zip](https://github.com/pit-ray/win-vind/releases/download/v5.13.0/win-vind_5.13.0_64bit_installer.zip) +- [win-vind_5.13.1_32bit_installer.zip](https://github.com/pit-ray/win-vind/releases/download/v5.13.1/win-vind_5.13.1_32bit_installer.zip) +- [win-vind_5.13.1_64bit_installer.zip](https://github.com/pit-ray/win-vind/releases/download/v5.13.1/win-vind_5.13.1_64bit_installer.zip) ### Portable Zip -- [win-vind_5.13.0_32bit_portable.zip](https://github.com/pit-ray/win-vind/releases/download/v5.13.0/win-vind_5.13.0_32bit_portable.zip) -- [win-vind_5.13.0_64bit_portable.zip](https://github.com/pit-ray/win-vind/releases/download/v5.13.0/win-vind_5.13.0_64bit_portable.zip) +- [win-vind_5.13.1_32bit_portable.zip](https://github.com/pit-ray/win-vind/releases/download/v5.13.1/win-vind_5.13.1_32bit_portable.zip) +- [win-vind_5.13.1_64bit_portable.zip](https://github.com/pit-ray/win-vind/releases/download/v5.13.1/win-vind_5.13.1_64bit_portable.zip) ## Usage diff --git a/docs/_config.yml b/docs/_config.yml index fff7c569..e2c0c155 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -13,7 +13,7 @@ translations: # label: 日本語 project: - version: 5.13.0 + version: 5.13.1 download_url: downloads download_text: Download @@ -43,10 +43,10 @@ links: icon: comments url: https://github.com/pit-ray/win-vind/discussions -dl_ins_32: https://github.com/pit-ray/win-vind/releases/download/v5.13.0/win-vind_5.13.0_32bit_installer.zip -dl_zip_32: https://github.com/pit-ray/win-vind/releases/download/v5.13.0/win-vind_5.13.0_32bit_portable.zip -dl_ins_64: https://github.com/pit-ray/win-vind/releases/download/v5.13.0/win-vind_5.13.0_64bit_installer.zip -dl_zip_64: https://github.com/pit-ray/win-vind/releases/download/v5.13.0/win-vind_5.13.0_64bit_portable.zip +dl_ins_32: https://github.com/pit-ray/win-vind/releases/download/v5.13.1/win-vind_5.13.1_32bit_installer.zip +dl_zip_32: https://github.com/pit-ray/win-vind/releases/download/v5.13.1/win-vind_5.13.1_32bit_portable.zip +dl_ins_64: https://github.com/pit-ray/win-vind/releases/download/v5.13.1/win-vind_5.13.1_64bit_installer.zip +dl_zip_64: https://github.com/pit-ray/win-vind/releases/download/v5.13.1/win-vind_5.13.1_64bit_portable.zip ui: mode: 'light' # 'auto', 'dark', 'light'