clickCounter -> uiprivClickCounter.
This commit is contained in:
parent
f5be05f143
commit
0dddf4a490
|
@ -1,21 +1,4 @@
|
|||
|
||||
// areaevents.c
|
||||
typedef struct clickCounter clickCounter;
|
||||
// you should call Reset() to zero-initialize a new instance
|
||||
// it doesn't matter that all the non-count fields are zero: the first click will fail the curButton test straightaway, so it'll return 1 and set the rest of the structure accordingly
|
||||
struct clickCounter {
|
||||
int curButton;
|
||||
int rectX0;
|
||||
int rectY0;
|
||||
int rectX1;
|
||||
int rectY1;
|
||||
uintptr_t prevTime;
|
||||
int count;
|
||||
};
|
||||
int clickCounterClick(clickCounter *c, int button, int x, int y, uintptr_t time, uintptr_t maxTime, int32_t xdist, int32_t ydist);
|
||||
extern void clickCounterReset(clickCounter *);
|
||||
extern int fromScancode(uintptr_t, uiAreaKeyEvent *);
|
||||
|
||||
// matrix.c
|
||||
extern void fallbackSkew(uiDrawMatrix *, double, double, double, double);
|
||||
extern void scaleCenter(double, double, double *, double *);
|
||||
|
|
|
@ -16,7 +16,7 @@ TODO note the bits about asymmetry and g_rcClick initial value not mattering in
|
|||
|
||||
// x, y, xdist, ydist, and c.rect must have the same units
|
||||
// so must time, maxTime, and c.prevTime
|
||||
int clickCounterClick(clickCounter *c, int button, int x, int y, uintptr_t time, uintptr_t maxTime, int32_t xdist, int32_t ydist)
|
||||
int uiprivClickCounterClick(uiprivClickCounter *c, int button, int x, int y, uintptr_t time, uintptr_t maxTime, int32_t xdist, int32_t ydist)
|
||||
{
|
||||
// different button than before? if so, don't count
|
||||
if (button != c->curButton)
|
||||
|
@ -50,7 +50,7 @@ int clickCounterClick(clickCounter *c, int button, int x, int y, uintptr_t time,
|
|||
return c->count;
|
||||
}
|
||||
|
||||
void clickCounterReset(clickCounter *c)
|
||||
void uiprivClickCounterReset(uiprivClickCounter *c)
|
||||
{
|
||||
c->curButton = 0;
|
||||
c->rectX0 = 0;
|
||||
|
|
|
@ -37,10 +37,10 @@ extern void uiprivDoUserBug(const char *file, const char *line, const char *func
|
|||
extern int uiprivShouldQuit(void);
|
||||
|
||||
// areaevents.c
|
||||
typedef struct clickCounter clickCounter;
|
||||
typedef struct uiprivClickCounter uiprivClickCounter;
|
||||
// you should call Reset() to zero-initialize a new instance
|
||||
// it doesn't matter that all the non-count fields are zero: the first click will fail the curButton test straightaway, so it'll return 1 and set the rest of the structure accordingly
|
||||
struct clickCounter {
|
||||
struct uiprivClickCounter {
|
||||
int curButton;
|
||||
int rectX0;
|
||||
int rectY0;
|
||||
|
@ -49,8 +49,8 @@ struct clickCounter {
|
|||
uintptr_t prevTime;
|
||||
int count;
|
||||
};
|
||||
int clickCounterClick(clickCounter *c, int button, int x, int y, uintptr_t time, uintptr_t maxTime, int32_t xdist, int32_t ydist);
|
||||
extern void clickCounterReset(clickCounter *);
|
||||
extern int uiprivClickCounterClick(uiprivClickCounter *c, int button, int x, int y, uintptr_t time, uintptr_t maxTime, int32_t xdist, int32_t ydist);
|
||||
extern void uiprivClickCounterReset(uiprivClickCounter *);
|
||||
extern int fromScancode(uintptr_t, uiAreaKeyEvent *);
|
||||
|
||||
// matrix.c
|
||||
|
|
10
unix/area.c
10
unix/area.c
|
@ -19,7 +19,7 @@ struct areaWidget {
|
|||
// construct-only parameters aare not set until after the init() function has returned
|
||||
// we need this particular object available during init(), so put it here instead of in uiArea
|
||||
// keep a pointer in uiArea for convenience, though
|
||||
clickCounter cc;
|
||||
uiprivClickCounter cc;
|
||||
};
|
||||
|
||||
struct areaWidgetClass {
|
||||
|
@ -45,7 +45,7 @@ struct uiArea {
|
|||
int scrollHeight;
|
||||
|
||||
// note that this is a pointer; see above
|
||||
clickCounter *cc;
|
||||
uiprivClickCounter *cc;
|
||||
|
||||
// for user window drags
|
||||
GdkEventButton *dragevent;
|
||||
|
@ -68,7 +68,7 @@ static void areaWidget_init(areaWidget *aw)
|
|||
|
||||
gtk_widget_set_can_focus(GTK_WIDGET(aw), TRUE);
|
||||
|
||||
clickCounterReset(&(aw->cc));
|
||||
uiprivClickCounterReset(&(aw->cc));
|
||||
}
|
||||
|
||||
static void areaWidget_dispose(GObject *obj)
|
||||
|
@ -261,7 +261,7 @@ static gboolean areaWidget_button_press_event(GtkWidget *w, GdkEventButton *e)
|
|||
// e->time is guint32
|
||||
// e->x and e->y are floating-point; just make them 32-bit integers
|
||||
// maxTime and maxDistance... are gint, which *should* fit, hopefully...
|
||||
me.Count = clickCounterClick(a->cc, me.Down,
|
||||
me.Count = uiprivClickCounterClick(a->cc, me.Down,
|
||||
e->x, e->y,
|
||||
e->time, maxTime,
|
||||
maxDistance, maxDistance);
|
||||
|
@ -309,7 +309,7 @@ static gboolean onCrossing(areaWidget *aw, int left)
|
|||
uiArea *a = aw->a;
|
||||
|
||||
(*(a->ah->MouseCrossed))(a->ah, a, left);
|
||||
clickCounterReset(a->cc);
|
||||
uiprivClickCounterReset(a->cc);
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ uiArea *uiNewArea(uiAreaHandler *ah)
|
|||
|
||||
a->ah = ah;
|
||||
a->scrolling = FALSE;
|
||||
clickCounterReset(&(a->cc));
|
||||
uiprivClickCounterReset(&(a->cc));
|
||||
|
||||
// a->hwnd is assigned in areaWndProc()
|
||||
uiWindowsEnsureCreateControlHWND(0,
|
||||
|
@ -190,7 +190,7 @@ uiArea *uiNewScrollingArea(uiAreaHandler *ah, int width, int height)
|
|||
a->scrolling = TRUE;
|
||||
a->scrollWidth = width;
|
||||
a->scrollHeight = height;
|
||||
clickCounterReset(&(a->cc));
|
||||
uiprivClickCounterReset(&(a->cc));
|
||||
|
||||
// a->hwnd is assigned in areaWndProc()
|
||||
uiWindowsEnsureCreateControlHWND(0,
|
||||
|
|
|
@ -18,7 +18,7 @@ struct uiArea {
|
|||
int hwheelCarry;
|
||||
int vwheelCarry;
|
||||
|
||||
clickCounter cc;
|
||||
uiprivClickCounter cc;
|
||||
BOOL capturing;
|
||||
|
||||
BOOL inside;
|
||||
|
|
|
@ -92,11 +92,11 @@ static void areaMouseEvent(uiArea *a, int down, int up, WPARAM wParam, LPARAM l
|
|||
if (inClient && !a->inside) {
|
||||
a->inside = TRUE;
|
||||
(*(a->ah->MouseCrossed))(a->ah, a, 0);
|
||||
clickCounterReset(&(a->cc));
|
||||
uiprivClickCounterReset(&(a->cc));
|
||||
} else if (!inClient && a->inside) {
|
||||
a->inside = FALSE;
|
||||
(*(a->ah->MouseCrossed))(a->ah, a, 1);
|
||||
clickCounterReset(&(a->cc));
|
||||
uiprivClickCounterReset(&(a->cc));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ static void areaMouseEvent(uiArea *a, int down, int up, WPARAM wParam, LPARAM l
|
|||
// GetMessageTime() returns LONG and GetDoubleClckTime() returns UINT, which are int32 and uint32, respectively, but we don't need to worry about the signedness because for the same bit widths and two's complement arithmetic, s1-s2 == u1-u2 if bits(s1)==bits(s2) and bits(u1)==bits(u2) (and Windows requires two's complement: http://blogs.msdn.com/b/oldnewthing/archive/2005/05/27/422551.aspx)
|
||||
// signedness isn't much of an issue for these calls anyway because http://stackoverflow.com/questions/24022225/what-are-the-sign-extension-rules-for-calling-windows-api-functions-stdcall-t and that we're only using unsigned values (think back to how you (didn't) handle signedness in assembly language) AND because of the above AND because the statistics below (time interval and width/height) really don't make sense if negative
|
||||
// GetSystemMetrics() returns int, which is int32
|
||||
me.Count = clickCounterClick(&(a->cc), me.Down,
|
||||
me.Count = uiprivClickCounterClick(&(a->cc), me.Down,
|
||||
me.X, me.Y,
|
||||
GetMessageTime(), GetDoubleClickTime(),
|
||||
GetSystemMetrics(SM_CXDOUBLECLK) / 2,
|
||||
|
@ -164,7 +164,7 @@ static void onMouseEntered(uiArea *a)
|
|||
track(a, TRUE);
|
||||
(*(a->ah->MouseCrossed))(a->ah, a, 0);
|
||||
// TODO figure out why we did this to begin with; either we do it on both GTK+ and Windows or not at all
|
||||
clickCounterReset(&(a->cc));
|
||||
uiprivClickCounterReset(&(a->cc));
|
||||
}
|
||||
|
||||
// TODO genericize it so that it can be called above
|
||||
|
@ -174,7 +174,7 @@ static void onMouseLeft(uiArea *a)
|
|||
a->inside = FALSE;
|
||||
(*(a->ah->MouseCrossed))(a->ah, a, 1);
|
||||
// TODO figure out why we did this to begin with; either we do it on both GTK+ and Windows or not at all
|
||||
clickCounterReset(&(a->cc));
|
||||
uiprivClickCounterReset(&(a->cc));
|
||||
}
|
||||
|
||||
// we use VK_SNAPSHOT as a sentinel because libui will never support the print screen key; that key belongs to the user
|
||||
|
@ -325,7 +325,7 @@ BOOL areaDoEvents(uiArea *a, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *l
|
|||
switch (uMsg) {
|
||||
case WM_ACTIVATE:
|
||||
// don't keep the double-click timer running if the user switched programs in between clicks
|
||||
clickCounterReset(&(a->cc));
|
||||
uiprivClickCounterReset(&(a->cc));
|
||||
*lResult = 0;
|
||||
return TRUE;
|
||||
case WM_MOUSEMOVE:
|
||||
|
|
Loading…
Reference in New Issue