Fix recent console click quirks.

This commit is contained in:
Shpoike 2023-03-27 13:56:03 +01:00
parent 505061a8d2
commit 226c1cf6b4
3 changed files with 66 additions and 7 deletions

View file

@ -3294,7 +3294,7 @@ void Con_DrawConsole (int lines, qboolean noback)
}
selactive = Key_GetConsoleSelectionBox(con_current, &selsx, &selsy, &selex, &seley);
if ((con_current->flags & CONF_KEEPSELECTION) && con_current->selstartline && con_current->selendline && con_current->buttonsdown != CB_SELECTED)
if ((con_current->flags & CONF_KEEPSELECTION) && con_current->selstartline && con_current->selendline && con_current->buttonsdown != CB_SELECTED && con_current->buttonsdown != CB_TAPPED)
selactive = -1;
Font_BeginString(font_console, x, y, &x, &y);
@ -3329,14 +3329,18 @@ void Con_DrawConsole (int lines, qboolean noback)
mouseconsole = con_mouseover?con_mouseover:con_current;
if (con_current->buttonsdown == CB_SELECTED)
if (con_current->buttonsdown == CB_SELECTED || con_current->buttonsdown == CB_TAPPED)
{ //select was released...
console_t *con = con_current;
char *buffer;
qboolean tapped = con->buttonsdown==CB_TAPPED;
con->buttonsdown = CB_NONE;
if (con->selstartline)
{
con->flags |= CONF_KEEPSELECTION;
if (tapped)
con->flags &= ~CONF_KEEPSELECTION;
else
con->flags |= CONF_KEEPSELECTION;
if (con->userline)
{
if (con->flags & CONF_BACKSELECTION)
@ -3427,6 +3431,57 @@ void Con_DrawOneConsole(console_t *con, qboolean focused, struct font_s *font, f
con->display = con->current;
Con_DrawConsoleLines(con, con->display, con->displayscroll, x, sx, sy, y, selactive, selsx, selex, selsy, seley, lineagelimit);
if (con->buttonsdown == CB_SELECTED || con->buttonsdown == CB_TAPPED)
{ //select was released...
char *buffer;
qboolean tapped = con->buttonsdown==CB_TAPPED;
con->buttonsdown = CB_NONE;
if (con->selstartline)
{
if (tapped)
con->flags &= ~CONF_KEEPSELECTION;
else
con->flags |= CONF_KEEPSELECTION;
if (con->userline)
{
if (con->flags & CONF_BACKSELECTION)
{
con->userline = con->selendline;
con->useroffset = con->selendoffset;
}
else
{
con->userline = con->selstartline;
con->useroffset = con->selstartoffset;
}
}
if (con->selstartline == con->selendline && con->selendoffset <= con->selstartoffset+1)
{
if (keydown[K_LSHIFT] || keydown[K_RSHIFT])
;
else
{
buffer = Con_CopyConsole(con, false, true, false);
if (buffer)
{
Key_HandleConsoleLink(con, buffer);
Z_Free(buffer);
}
}
}
else
{
buffer = Con_CopyConsole(con, true, false, true); //don't keep markup if we're copying to the clipboard
if (buffer)
{
Sys_SaveClipboard(CBT_SELECTION, buffer);
Z_Free(buffer);
}
}
}
}
Font_EndString(font);
}

View file

@ -761,7 +761,7 @@ qboolean Key_GetConsoleSelectionBox(console_t *con, int *sx, int *sy, int *ex, i
*ey = con->mousecursor[1];
return true;
}
else if (con->buttonsdown == CB_SELECT || con->buttonsdown == CB_SELECTED)
else if (con->buttonsdown == CB_SELECT || con->buttonsdown == CB_SELECTED || con->buttonsdown == CB_TAPPED)
{
//right-mouse
//select. copy-to-clipboard on release.
@ -1219,7 +1219,10 @@ void Key_ConsoleRelease(console_t *con, int key, unsigned int unicode)
if ((key == K_TOUCHTAP || key == K_MOUSE1) && con->buttonsdown == CB_SELECT)
{
con->buttonsdown = CB_SELECTED;
if (fabs(con->mousedown[0] - con->mousecursor[0]) < 5 && fabs(con->mousedown[1] - con->mousecursor[1]) < 5 && realtime < con->mousedowntime + 0.4)
con->buttonsdown = CB_TAPPED; //don't leave it selected.
else
con->buttonsdown = CB_SELECTED;
return;
}
if ((key == K_TOUCHSLIDE || key == K_MOUSE1) && con->buttonsdown == CB_SCROLL)// || (key == K_MOUSE2 && con->buttonsdown == CB_SCROLL_R))
@ -1276,7 +1279,7 @@ void Key_ConsoleRelease(console_t *con, int key, unsigned int unicode)
return;
}
}
if (con->buttonsdown == CB_SELECTED)
if (con->buttonsdown == CB_SELECTED || con->buttonsdown == CB_TAPPED)
; //will time out in the drawing code.
else
// if (con->buttonsdown == CB_MOVE) //window title(move)

View file

@ -124,7 +124,8 @@ enum
CB_MOVE = 4,
CB_ACTIONBAR = 5,
CB_SELECT = 6,
CB_SELECTED = 7,
CB_SELECTED = 7, //selection ended (deferred until drawing to ensure selections happen properly)
CB_TAPPED = 8, //quick-tap ended (deferred until drawing to ensure selections happen properly)
//the flags part
CB_STALE = (1u<<28), //WAS held last frame - to make sure we still do stuff when released on the same frame.