Pass mouse buttons to core correctly.

svn path=/trunk/netsurf/; revision=10192
This commit is contained in:
Michael Drake 2010-03-28 19:21:47 +00:00
parent 974f42f8cf
commit dd2b9e4b19

View File

@ -39,10 +39,10 @@
struct gui_window { struct gui_window {
/* All gui_window objects have an ultimate scaffold */ /* All gui_window objects have an ultimate scaffold */
nsgtk_scaffolding *scaffold; nsgtk_scaffolding *scaffold;
/**< the gtk object containing menu, buttons, url bar, [tabs], /**< the gtk object containing menu, buttons, url bar, [tabs],
* drawing area, etc that may contain 1 -> several gui_windows */ * drawing area, etc that may contain 1 -> several gui_windows */
struct browser_window *bw; struct browser_window *bw;
/**< the 'content' window that is rendered in the gui_window*/ /**< the 'content' window that is rendered in the gui_window*/
struct browser_mouse *mouse; /**< contains mouse state / events */ struct browser_mouse *mouse; /**< contains mouse state / events */
@ -53,10 +53,10 @@ struct gui_window {
int last_x, last_y; int last_x, last_y;
/**< storage caret location for rendering */ /**< storage caret location for rendering */
GtkScrolledWindow *scrolledwindow; GtkScrolledWindow *scrolledwindow;
/**< optional; for frames that need it; top level of gtk structure of /**< optional; for frames that need it; top level of gtk structure of
* gui_window */ * gui_window */
GtkViewport *viewport; GtkViewport *viewport;
/**< contained in a scrolled window */ /**< contained in a scrolled window */
GtkFixed *fixed; /**< contained in a viewport */ GtkFixed *fixed; /**< contained in a viewport */
GtkDrawingArea *drawing_area; /**< contained in a gtkfixed */ GtkDrawingArea *drawing_area; /**< contained in a gtkfixed */
@ -188,7 +188,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
g->next = window_list; g->next = window_list;
g->prev = NULL; g->prev = NULL;
window_list = g; window_list = g;
/* Construct our primary elements */ /* Construct our primary elements */
g->fixed = GTK_FIXED(gtk_fixed_new()); g->fixed = GTK_FIXED(gtk_fixed_new());
g->drawing_area = GTK_DRAWING_AREA(gtk_drawing_area_new()); g->drawing_area = GTK_DRAWING_AREA(gtk_drawing_area_new());
@ -291,12 +291,12 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
#define CONNECT(obj, sig, callback, ptr) \ #define CONNECT(obj, sig, callback, ptr) \
g_signal_connect(G_OBJECT(obj), (sig), G_CALLBACK(callback), (ptr)) g_signal_connect(G_OBJECT(obj), (sig), G_CALLBACK(callback), (ptr))
g->signalhandler[NSGTK_WINDOW_SIGNAL_REDRAW] = g->signalhandler[NSGTK_WINDOW_SIGNAL_REDRAW] =
CONNECT(g->drawing_area, "expose_event", CONNECT(g->drawing_area, "expose_event",
nsgtk_window_expose_event, g); nsgtk_window_expose_event, g);
CONNECT(g->drawing_area, "motion_notify_event", CONNECT(g->drawing_area, "motion_notify_event",
nsgtk_window_motion_notify_event, g); nsgtk_window_motion_notify_event, g);
g->signalhandler[NSGTK_WINDOW_SIGNAL_CLICK] = g->signalhandler[NSGTK_WINDOW_SIGNAL_CLICK] =
CONNECT(g->drawing_area, "button_press_event", CONNECT(g->drawing_area, "button_press_event",
nsgtk_window_button_press_event, g); nsgtk_window_button_press_event, g);
CONNECT(g->drawing_area, "button_release_event", CONNECT(g->drawing_area, "button_release_event",
@ -380,7 +380,7 @@ gboolean nsgtk_window_expose_event(GtkWidget *widget,
plot = nsgtk_plotters; plot = nsgtk_plotters;
nsgtk_plot_set_scale(g->bw->scale); nsgtk_plot_set_scale(g->bw->scale);
current_redraw_browser = g->bw; current_redraw_browser = g->bw;
content_redraw(c, 0, 0, content_redraw(c, 0, 0,
widget->allocation.width * scale, widget->allocation.width * scale,
widget->allocation.height * scale, widget->allocation.height * scale,
@ -459,14 +459,23 @@ gboolean nsgtk_window_button_press_event(GtkWidget *widget,
switch (event->button) { switch (event->button) {
case 1: case 1:
/* Left button, usually.
* Pass to core as BUTTON 1. */
g->mouse->state = BROWSER_MOUSE_PRESS_1; g->mouse->state = BROWSER_MOUSE_PRESS_1;
break; break;
case 3: case 2:
/* Middle button, usually.
* Pass to core as BUTTON 2 */
g->mouse->state = BROWSER_MOUSE_PRESS_2;
break;
case 3:
/* Right button, usually.
* Front end action button -- context menu. */
browser_window_remove_caret(g->bw); browser_window_remove_caret(g->bw);
nsgtk_scaffolding_popup_menu(g->scaffold, g->mouse->pressed_x, nsgtk_scaffolding_popup_menu(g->scaffold, g->mouse->pressed_x,
g->mouse->pressed_y); g->mouse->pressed_y);
g->mouse->state = BROWSER_MOUSE_PRESS_2; g->mouse->state = BROWSER_MOUSE_PRESS_2;
break; return TRUE;
default: default:
return FALSE; return FALSE;
} }