summaryrefslogtreecommitdiff
path: root/framebuffer
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2016-04-21 13:50:16 +0100
committerVincent Sanders <vince@kyllikki.org>2016-04-21 13:50:16 +0100
commit16dde3c704c36a943d8e36584dc6b52051d156db (patch)
tree3d052e65db4e64afa8b476f1c96ffd8b241e2279 /framebuffer
parent77a1b4b5e01846e2c9684f57fda1bac0d6d854e5 (diff)
downloadnetsurf-16dde3c704c36a943d8e36584dc6b52051d156db.tar.gz
netsurf-16dde3c704c36a943d8e36584dc6b52051d156db.tar.bz2
make framebuffer use nsutils library monotonic times
Diffstat (limited to 'framebuffer')
-rw-r--r--framebuffer/gui.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index 210341b5d..8a29681cc 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -16,12 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdint.h>
#include <limits.h>
#include <getopt.h>
#include <assert.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
+#include <nsutils/time.h>
#include <libnsfb.h>
#include <libnsfb_plot.h>
@@ -611,10 +613,10 @@ fb_browser_window_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
float scale = browser_window_get_scale(gw->bw);
int x = (cbi->x + bwidget->scrollx) / scale;
int y = (cbi->y + bwidget->scrolly) / scale;
- unsigned int time_now;
+ uint64_t time_now;
static struct {
enum { CLICK_SINGLE, CLICK_DOUBLE, CLICK_TRIPLE } type;
- unsigned int time;
+ uint64_t time;
} last_click;
if (cbi->event->type != NSFB_EVENT_KEY_DOWN &&
@@ -667,7 +669,7 @@ fb_browser_window_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
case NSFB_EVENT_KEY_UP:
mouse = 0;
- time_now = wallclock();
+ nsu_getmonotonic_ms(&time_now);
switch (cbi->event->value.keycode) {
case NSFB_KEY_MOUSE_1:
@@ -719,10 +721,11 @@ fb_browser_window_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
}
/* Determine if it's a double or triple click, allowing
- * 0.5 seconds (50cs) between clicks */
- if (time_now < last_click.time + 50 &&
- cbi->event->value.keycode != NSFB_KEY_MOUSE_4 &&
- cbi->event->value.keycode != NSFB_KEY_MOUSE_5) {
+ * 0.5 seconds (500ms) between clicks
+ */
+ if ((time_now < (last_click.time + 500)) &&
+ (cbi->event->value.keycode != NSFB_KEY_MOUSE_4) &&
+ (cbi->event->value.keycode != NSFB_KEY_MOUSE_5)) {
if (last_click.type == CLICK_SINGLE) {
/* Set double click */
mouse |= BROWSER_MOUSE_DOUBLE_CLICK;
@@ -740,8 +743,9 @@ fb_browser_window_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
last_click.type = CLICK_SINGLE;
}
- if (mouse)
+ if (mouse) {
browser_window_mouse_click(gw->bw, mouse, x, y);
+ }
last_click.time = time_now;