Skip to content

Commit

Permalink
on suppressed focus-click event, also suppress the mouse release (#782);
Browse files Browse the repository at this point in the history
also avoid subsequent false double-click
  • Loading branch information
mintty committed Jul 9, 2018
1 parent c84b1c0 commit 0e49afd
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/wininput.c
Expand Up @@ -742,6 +742,7 @@ static mouse_button last_button = -1;
static mod_keys last_mods;
static pos last_click_pos;
static bool last_skipped = false;
static mouse_button skip_release_token = -1;
static uint last_skipped_time;
static bool mouse_state = false;

Expand All @@ -766,9 +767,10 @@ win_mouse_click(mouse_button b, LPARAM lp)
pos p = get_mouse_pos(lp);

uint t = GetMessageTime();
if (b != last_button ||
p.x != last_click_pos.x || p.y != last_click_pos.y ||
t - last_time > GetDoubleClickTime() || ++count > 3)
bool dblclick = b == last_button
&& p.x == last_click_pos.x && p.y == last_click_pos.y
&& t - last_time <= GetDoubleClickTime();
if (!dblclick || ++count > 3)
count = 1;
//printf("mouse %d (focus %d skipped %d) ×%d\n", b, click_focus, last_skipped, count);

Expand All @@ -780,17 +782,14 @@ win_mouse_click(mouse_button b, LPARAM lp)
cfg.clicks_target_app ^ ((mods & cfg.click_target_mod) != 0)
)
) {
//printf("suppressing focus-click selection\n");
//printf("suppressing focus-click selection, t %d\n", t);
// prevent accidental selection when focus-clicking into the window (#717)
last_skipped = true;
last_skipped_time = t;
//printf("last_skipped_time = %d\n", t);
skip_release_token = b;
}
else {
if (last_skipped && b == last_button
&& p.x == last_click_pos.x && p.y == last_click_pos.y
)
{
if (last_skipped && dblclick) {
// recognize double click also in application mouse modes
term_mouse_click(b, mods, p, 1);
}
Expand Down Expand Up @@ -822,6 +821,12 @@ void
win_mouse_release(mouse_button b, LPARAM lp)
{
mouse_state = false;

if (b == skip_release_token) {
skip_release_token = -1;
return;
}

term_mouse_release(b, get_mods(), get_mouse_pos(lp));
ReleaseCapture();
switch (b) {
Expand Down

0 comments on commit 0e49afd

Please sign in to comment.