Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
elfmz committed Nov 11, 2024
1 parent d1fed9a commit 6ef2a4e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 26 deletions.
27 changes: 17 additions & 10 deletions WinPort/src/APITime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,11 @@ WINPORT_DECL(DosDateTimeToFileTime, BOOL, ( WORD fatdate, WORD fattime, LPFILETI

static unsigned s_time_failmask = 0;

WINPORT_DECL(GetTickCount, DWORD, ())
static DWORD64 GetTickCountInner()
{
(void)s_time_failmask;
#ifdef _WIN32
return ::GetTickCount();
return ::GetTickCount64();
#elif defined(__APPLE__)
static mach_timebase_info_data_t g_timebase_info;
if (g_timebase_info.denom == 0)
Expand All @@ -397,9 +397,9 @@ WINPORT_DECL(GetTickCount, DWORD, ())
# else
if (LIKELY(clock_gettime(CLOCK_REALTIME_COARSE, &spec) == 0)) {
# endif
DWORD rv = spec.tv_sec;
DWORD64 rv = spec.tv_sec;
rv*= 1000;
rv+= (DWORD)(spec.tv_nsec / 1000000);
rv+= (DWORD64)(spec.tv_nsec / 1000000);
return rv;
}
fprintf(stderr, "%s: clock_gettime error %u\n", __FUNCTION__, errno);
Expand All @@ -409,19 +409,25 @@ WINPORT_DECL(GetTickCount, DWORD, ())
if (LIKELY((s_time_failmask & 2) == 0)) {
struct timeval tv{};
if (LIKELY(gettimeofday(&tv, NULL) == 0)) {
DWORD rv = tv.tv_sec;
DWORD64 rv = tv.tv_sec;
rv*= 1000;
rv+= (DWORD)(tv.tv_usec / 1000);
rv+= (DWORD64)(tv.tv_usec / 1000);
return rv;
}
fprintf(stderr, "%s: gettimeofday error %u\n", __FUNCTION__, errno);
s_time_failmask|= 2;
}

return DWORD(time(NULL) * 1000);
return DWORD64(time(NULL) * 1000);
#endif
}

WINPORT_DECL(GetTickCount, DWORD, ())
{
DWORD out = (DWORD)GetTickCountInner();
return LIKELY(out != 0) ? out : 1;
}

WINPORT_DECL(Sleep, VOID, (DWORD dwMilliseconds))
{
#ifdef _WIN32
Expand All @@ -436,10 +442,11 @@ WINPORT_DECL(Sleep, VOID, (DWORD dwMilliseconds))
#endif
}

static clock_t g_process_start_stamp = WINPORT(GetTickCount)();
static DWORD64 g_process_start_stamp = GetTickCountInner();

SHAREDSYMBOL clock_t GetProcessUptimeMSec()
{
clock_t now = WINPORT(GetTickCount)();
return (now - g_process_start_stamp);
clock_t out = (clock_t)(GetTickCountInner() - g_process_start_stamp);
return LIKELY(out != 0) ? out : 1;
}

9 changes: 3 additions & 6 deletions WinPort/src/Backend/WX/wxMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// If time between adhoc text copy and mouse button release less then this value then text will not be copied. Used to protect against unwanted copy-paste-s
#define QEDIT_COPY_MINIMAL_DELAY 150

// This defines muh much time UI remain frozen after user released qedit, that
// This defines how much time UI remain frozen after user released qedit, that
// allows user to quickly select another location before all shadowed output changes applied
#define QEDIT_UNFREEZE_DELAY 1000

Expand Down Expand Up @@ -870,11 +870,11 @@ void WinPortPanel::OnConsoleOutputUpdated(const SMALL_RECT *areas, size_t count)
if (_refresh_rects.empty()) {
action = A_QUEUE;
#ifndef __APPLE__
} else if (_refresh_rects_throttle != (DWORD)-1 &&
} else if (_refresh_rects_throttle != 0 &&
WINPORT(GetTickCount)() - _refresh_rects_throttle > 500 &&
!wxIsMainThread()) {
action = A_THROTTLE;
_refresh_rects_throttle = (DWORD)-1;
_refresh_rects_throttle = 0;
#else
//TODO: fix stuck
#endif
Expand Down Expand Up @@ -958,8 +958,6 @@ void WinPortPanel::OnConsoleOutputUpdated(const SMALL_RECT *areas, size_t count)
CallInMain<int>(fn);
std::lock_guard<std::mutex> lock(_refresh_rects);
_refresh_rects_throttle = WINPORT(GetTickCount)();
if (_refresh_rects_throttle == (DWORD)-1)
_refresh_rects_throttle = 0;
} break;

case A_NOTHING: break;
Expand Down Expand Up @@ -1812,7 +1810,6 @@ void WinPortPanel::OnMouseQEdit( wxMouseEvent &event, COORD pos_char )
} else {
_qedit_unfreeze_start_ticks = 0;
}
_qedit_out_state = QOS_FROZEN_BUSY;
DamageAreaBetween(_mouse_qedit_start, _mouse_qedit_last);

} else if (_mouse_qedit_start_ticks != 0) {
Expand Down
7 changes: 0 additions & 7 deletions WinPort/src/Backend/WX/wxMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,6 @@ class WinPortPanel: public wxPanel, protected IConsoleOutputBackend
RP_DEFER,
RP_INSTANT
} _resize_pending{RP_NONE};
enum
{
QOS_NOT_FROZEN,
QOS_FROZEN_BUSY,
QOS_UNFREEZE_PENDING,
QOS_UNFREEZE_PENDING2,
} _qedit_out_state{QOS_NOT_FROZEN};
DWORD _qedit_unfreeze_start_ticks{0};
DWORD _mouse_state{0}, _mouse_qedit_start_ticks{0}, _mouse_qedit_moved{0};
COORD _mouse_qedit_start{}, _mouse_qedit_last{};
Expand Down
3 changes: 0 additions & 3 deletions far2l/src/cmdline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vtcompletor.h"
#include <limits>

#include "clipboard.hpp"
#include "farversion.h"

CommandLine::CommandLine()
:
CmdStr(CtrlObject->Cp(), 0, true, CtrlObject->CmdHistory, 0,
Expand Down

0 comments on commit 6ef2a4e

Please sign in to comment.