Allow double-clicks in main browser and middle button double-clicks in treeview

svn path=/trunk/netsurf/; revision=11083
This commit is contained in:
Chris Young 2010-12-16 23:28:33 +00:00
parent ddd677e72a
commit 96cb4b40e7
3 changed files with 79 additions and 5 deletions

View File

@ -863,6 +863,7 @@ void ami_handle_msg(void)
struct Node *tabnode;
int i, nskey;
struct browser_window *closedbw;
struct timeval curtime;
if(IsMinListEmpty(window_list))
{
@ -1138,22 +1139,71 @@ void ami_handle_msg(void)
case SELECTUP:
if(gwin->mouse_state & BROWSER_MOUSE_PRESS_1)
{
browser_window_mouse_click(gwin->bw,BROWSER_MOUSE_CLICK_1 | gwin->key_state,x,y);
CurrentTime(&curtime.tv_sec, &curtime.tv_usec);
gwin->mouse_state = BROWSER_MOUSE_CLICK_1;
if(gwin->lastclick.tv_sec)
{
if(DoubleClick(gwin->lastclick.tv_sec,
gwin->lastclick.tv_usec,
curtime.tv_sec, curtime.tv_usec))
gwin->mouse_state |= BROWSER_MOUSE_DOUBLE_CLICK;
}
browser_window_mouse_click(gwin->bw,
gwin->mouse_state | gwin->key_state,x,y);
if(gwin->mouse_state & BROWSER_MOUSE_DOUBLE_CLICK)
{
gwin->lastclick.tv_sec = 0;
gwin->lastclick.tv_usec = 0;
}
else
{
gwin->lastclick.tv_sec = curtime.tv_sec;
gwin->lastclick.tv_usec = curtime.tv_usec;
}
}
else
{
browser_window_mouse_drag_end(gwin->bw,0,x,y);
browser_window_mouse_drag_end(gwin->bw, 0, x, y);
}
gwin->mouse_state=0;
break;
case MIDDLEUP:
if(gwin->mouse_state & BROWSER_MOUSE_PRESS_2)
{
browser_window_mouse_click(gwin->bw,BROWSER_MOUSE_CLICK_2 | gwin->key_state,x,y);
CurrentTime(&curtime.tv_sec, &curtime.tv_usec);
gwin->mouse_state = BROWSER_MOUSE_CLICK_2;
if(gwin->lastclick.tv_sec)
{
if(DoubleClick(gwin->lastclick.tv_sec,
gwin->lastclick.tv_usec,
curtime.tv_sec, curtime.tv_usec))
gwin->mouse_state |= BROWSER_MOUSE_DOUBLE_CLICK;
}
browser_window_mouse_click(gwin->bw,
gwin->mouse_state | gwin->key_state,x,y);
if(gwin->mouse_state & BROWSER_MOUSE_DOUBLE_CLICK)
{
gwin->lastclick.tv_sec = 0;
gwin->lastclick.tv_usec = 0;
}
else
{
gwin->lastclick.tv_sec = curtime.tv_sec;
gwin->lastclick.tv_usec = curtime.tv_usec;
}
}
else
{
browser_window_mouse_drag_end(gwin->bw,0,x,y);
browser_window_mouse_drag_end(gwin->bw, 0, x, y);
}
gwin->mouse_state=0;
break;

View File

@ -105,6 +105,7 @@ struct gui_window_2 {
char *status;
char *wintitle;
char *helphints[GID_LAST];
struct timeval lastclick;
};
struct gui_window

View File

@ -840,11 +840,34 @@ BOOL ami_tree_event(struct treeview_window *twin)
twin->drag_x = 0;
twin->drag_y = 0;
break;
case MIDDLEUP:
if(twin->mouse_state & BROWSER_MOUSE_PRESS_2)
{
CurrentTime(&curtime.tv_sec,&curtime.tv_usec);
twin->mouse_state = BROWSER_MOUSE_CLICK_2;
if(twin->lastclick.tv_sec)
{
if(DoubleClick(twin->lastclick.tv_sec,
twin->lastclick.tv_usec,
curtime.tv_sec, curtime.tv_usec))
twin->mouse_state |= BROWSER_MOUSE_DOUBLE_CLICK;
}
tree_mouse_action(twin->tree,
BROWSER_MOUSE_CLICK_2 | twin->key_state, x, y);
twin->mouse_state | twin->key_state, x, y);
if(twin->mouse_state & BROWSER_MOUSE_DOUBLE_CLICK)
{
twin->lastclick.tv_sec = 0;
twin->lastclick.tv_usec = 0;
}
else
{
twin->lastclick.tv_sec = curtime.tv_sec;
twin->lastclick.tv_usec = curtime.tv_usec;
}
}
else ami_tree_drag_end(twin, x, y);