Commit 400413d9 authored by Morten Welinder's avatar Morten Welinder

Event handling: peek less into GdkEvent.

parent 5e2d1228
2013-12-11 Morten Welinder <terra@gnome.org>
* src/gui-util.c (gnumeric_popup_menu): Use the screen from
gdk_event_get_screen, not from ->screen. This might fix #720182.
* src/*.c: Use accessor function for GdkEvent when convenient.
2013-12-07 Morten Welinder <terra@gnome.org> 2013-12-07 Morten Welinder <terra@gnome.org>
* src/application.c (gnm_app_init): Don't allocate a * src/application.c (gnm_app_init): Don't allocate a
......
...@@ -851,7 +851,7 @@ cb_treeview_button_press(G_GNUC_UNUSED GtkWidget *w, GdkEvent *event, SortFlowSt ...@@ -851,7 +851,7 @@ cb_treeview_button_press(G_GNUC_UNUSED GtkWidget *w, GdkEvent *event, SortFlowSt
if ((event->type == GDK_BUTTON_PRESS) && if ((event->type == GDK_BUTTON_PRESS) &&
(event->button.button == 3)) { (event->button.button == 3)) {
gnumeric_popup_menu (build_sort_field_base_menu(state), gnumeric_popup_menu (build_sort_field_base_menu(state),
&(event->button)); event);
return TRUE; return TRUE;
} }
......
...@@ -262,7 +262,8 @@ fixed_context_menu (StfDialogData *pagedata, GdkEventButton *event, ...@@ -262,7 +262,8 @@ fixed_context_menu (StfDialogData *pagedata, GdkEventButton *event,
select_column (pagedata, col); select_column (pagedata, col);
gnumeric_create_popup_menu (popup_elements, &fixed_context_menu_handler, gnumeric_create_popup_menu (popup_elements, &fixed_context_menu_handler,
pagedata, 0, pagedata, 0,
sensitivity_filter, event); sensitivity_filter,
(GdkEvent*)event);
} }
static gint static gint
......
...@@ -369,7 +369,7 @@ cb_popup_menu_extend_format (GtkWidget *widget, gpointer data) ...@@ -369,7 +369,7 @@ cb_popup_menu_extend_format (GtkWidget *widget, gpointer data)
static void static void
format_context_menu (StfDialogData *pagedata, format_context_menu (StfDialogData *pagedata,
GdkEventButton *event_button, GdkEvent *event,
int col) int col)
{ {
enum { enum {
...@@ -421,7 +421,7 @@ format_context_menu (StfDialogData *pagedata, ...@@ -421,7 +421,7 @@ format_context_menu (StfDialogData *pagedata,
pagedata); pagedata);
} }
gnumeric_popup_menu (GTK_MENU (menu), event_button); gnumeric_popup_menu (GTK_MENU (menu), event);
} }
...@@ -429,7 +429,7 @@ static gint ...@@ -429,7 +429,7 @@ static gint
cb_col_event (GtkWidget *widget, GdkEvent *event, gpointer _col) cb_col_event (GtkWidget *widget, GdkEvent *event, gpointer _col)
{ {
if (event->type == GDK_BUTTON_PRESS) { if (event->type == GDK_BUTTON_PRESS) {
GdkEventButton *event_button = (GdkEventButton *) event; GdkEventButton *event_button = &event->button;
StfDialogData *pagedata = StfDialogData *pagedata =
g_object_get_data (G_OBJECT (widget), "pagedata"); g_object_get_data (G_OBJECT (widget), "pagedata");
int col = GPOINTER_TO_INT (_col); int col = GPOINTER_TO_INT (_col);
...@@ -455,7 +455,7 @@ cb_col_event (GtkWidget *widget, GdkEvent *event, gpointer _col) ...@@ -455,7 +455,7 @@ cb_col_event (GtkWidget *widget, GdkEvent *event, gpointer _col)
if (event_button->x <= xmax) if (event_button->x <= xmax)
gtk_button_clicked (GTK_BUTTON (check)); gtk_button_clicked (GTK_BUTTON (check));
} else if (event_button->button == 3) { } else if (event_button->button == 3) {
format_context_menu (pagedata, event_button, col); format_context_menu (pagedata, event, col);
} }
return TRUE; return TRUE;
} }
...@@ -477,7 +477,7 @@ cb_treeview_button_press (GtkWidget *treeview, ...@@ -477,7 +477,7 @@ cb_treeview_button_press (GtkWidget *treeview,
int dx, col; int dx, col;
stf_preview_find_column (pagedata->format.renderdata, (int)event->x, &col, &dx); stf_preview_find_column (pagedata->format.renderdata, (int)event->x, &col, &dx);
activate_column (pagedata, col); activate_column (pagedata, col);
format_context_menu (pagedata, event, col); format_context_menu (pagedata, (GdkEvent*)event, col);
return TRUE; return TRUE;
} }
......
...@@ -68,7 +68,7 @@ static GtkTargetEntry const drag_types_out[] = { ...@@ -68,7 +68,7 @@ static GtkTargetEntry const drag_types_out[] = {
}; };
static gboolean static gboolean
gnm_pane_guru_key (WBCGtk const *wbcg, GdkEventKey *event) gnm_pane_guru_key (WBCGtk const *wbcg, GdkEvent *event)
{ {
GtkWidget *entry, *guru = wbc_gtk_get_guru (wbcg); GtkWidget *entry, *guru = wbc_gtk_get_guru (wbcg);
...@@ -76,7 +76,7 @@ gnm_pane_guru_key (WBCGtk const *wbcg, GdkEventKey *event) ...@@ -76,7 +76,7 @@ gnm_pane_guru_key (WBCGtk const *wbcg, GdkEventKey *event)
return FALSE; return FALSE;
entry = wbcg_get_entry_underlying (wbcg); entry = wbcg_get_entry_underlying (wbcg);
gtk_widget_event ((entry != NULL) ? entry : guru, (GdkEvent *) event); gtk_widget_event (entry ? entry : guru, event);
return TRUE; return TRUE;
} }
...@@ -141,9 +141,10 @@ gnm_pane_object_key_press (GnmPane *pane, GdkEventKey *ev) ...@@ -141,9 +141,10 @@ gnm_pane_object_key_press (GnmPane *pane, GdkEventKey *ev)
} }
static gboolean static gboolean
gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event, gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *kevent,
gboolean allow_rangesel) gboolean allow_rangesel)
{ {
GdkEvent *event = (GdkEvent *)kevent;
SheetControlGUI *scg = pane->simple.scg; SheetControlGUI *scg = pane->simple.scg;
SheetControl *sc = (SheetControl *) scg; SheetControl *sc = (SheetControl *) scg;
SheetView *sv = sc->view; SheetView *sv = sc->view;
...@@ -152,38 +153,42 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event, ...@@ -152,38 +153,42 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
WorkbookControl * wbc = scg_wbc(scg); WorkbookControl * wbc = scg_wbc(scg);
Workbook * wb = wb_control_get_workbook(wbc); Workbook * wb = wb_control_get_workbook(wbc);
gboolean delayed_movement = FALSE; gboolean delayed_movement = FALSE;
gboolean jump_to_bounds = event->state & GDK_CONTROL_MASK; gboolean jump_to_bounds;
gboolean is_enter = FALSE; gboolean is_enter = FALSE;
int first_tab_col; int first_tab_col;
int state = gnumeric_filter_modifiers (event->state); int state;
void (*movefn) (SheetControlGUI *, int n, gboolean jump, gboolean horiz); void (*movefn) (SheetControlGUI *, int n, gboolean jump, gboolean horiz);
gboolean transition_keys = gnm_conf_get_core_gui_editing_transitionkeys (); gboolean transition_keys = gnm_conf_get_core_gui_editing_transitionkeys ();
gboolean const end_mode = wbcg->last_key_was_end; gboolean const end_mode = wbcg->last_key_was_end;
GdkModifierType event_state;
(void)gdk_event_get_state (event, &event_state);
state = gnumeric_filter_modifiers (event_state);
jump_to_bounds = (event_state & GDK_CONTROL_MASK) != 0;
/* Update end-mode for magic end key stuff. */ /* Update end-mode for magic end key stuff. */
if (event->keyval != GDK_KEY_End && event->keyval != GDK_KEY_KP_End) if (kevent->keyval != GDK_KEY_End && kevent->keyval != GDK_KEY_KP_End)
wbcg_set_end_mode (wbcg, FALSE); wbcg_set_end_mode (wbcg, FALSE);
if (allow_rangesel) if (allow_rangesel)
movefn = (event->state & GDK_SHIFT_MASK) movefn = (event_state & GDK_SHIFT_MASK)
? scg_rangesel_extend ? scg_rangesel_extend
: scg_rangesel_move; : scg_rangesel_move;
else else
movefn = (event->state & GDK_SHIFT_MASK) movefn = (event_state & GDK_SHIFT_MASK)
? scg_cursor_extend ? scg_cursor_extend
: scg_cursor_move; : scg_cursor_move;
switch (event->keyval) { switch (kevent->keyval) {
case GDK_KEY_a: case GDK_KEY_a:
scg_select_all (scg); scg_select_all (scg);
break; break;
case GDK_KEY_KP_Left: case GDK_KEY_KP_Left:
case GDK_KEY_Left: case GDK_KEY_Left:
if (event->state & GDK_MOD1_MASK) if (event_state & GDK_MOD1_MASK)
return TRUE; /* Alt is used for accelerators */ return TRUE; /* Alt is used for accelerators */
if (event->state & SCROLL_LOCK_MASK) if (event_state & SCROLL_LOCK_MASK)
scg_set_left_col (scg, pane->first.col - 1); scg_set_left_col (scg, pane->first.col - 1);
else if (transition_keys && jump_to_bounds) { else if (transition_keys && jump_to_bounds) {
delayed_movement = TRUE; delayed_movement = TRUE;
...@@ -197,10 +202,10 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event, ...@@ -197,10 +202,10 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
case GDK_KEY_KP_Right: case GDK_KEY_KP_Right:
case GDK_KEY_Right: case GDK_KEY_Right:
if (event->state & GDK_MOD1_MASK) if (event_state & GDK_MOD1_MASK)
return TRUE; /* Alt is used for accelerators */ return TRUE; /* Alt is used for accelerators */
if (event->state & SCROLL_LOCK_MASK) if (event_state & SCROLL_LOCK_MASK)
scg_set_left_col (scg, pane->first.col + 1); scg_set_left_col (scg, pane->first.col + 1);
else if (transition_keys && jump_to_bounds) { else if (transition_keys && jump_to_bounds) {
delayed_movement = TRUE; delayed_movement = TRUE;
...@@ -214,7 +219,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event, ...@@ -214,7 +219,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
case GDK_KEY_KP_Up: case GDK_KEY_KP_Up:
case GDK_KEY_Up: case GDK_KEY_Up:
if (event->state & SCROLL_LOCK_MASK) if (event_state & SCROLL_LOCK_MASK)
scg_set_top_row (scg, pane->first.row - 1); scg_set_top_row (scg, pane->first.row - 1);
else if (transition_keys && jump_to_bounds) { else if (transition_keys && jump_to_bounds) {
delayed_movement = TRUE; delayed_movement = TRUE;
...@@ -227,7 +232,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event, ...@@ -227,7 +232,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
case GDK_KEY_KP_Down: case GDK_KEY_KP_Down:
case GDK_KEY_Down: case GDK_KEY_Down:
if (gnumeric_filter_modifiers (event->state) == GDK_MOD1_MASK) { if (gnumeric_filter_modifiers (event_state) == GDK_MOD1_MASK) {
/* 1) Any in cell combos ? */ /* 1) Any in cell combos ? */
SheetObject *so = sv_wbv (sv)->in_cell_combo; SheetObject *so = sv_wbv (sv)->in_cell_combo;
...@@ -244,12 +249,14 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event, ...@@ -244,12 +249,14 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
if (NULL != so) { if (NULL != so) {
SheetObjectView *sov = sheet_object_get_view (so, SheetObjectView *sov = sheet_object_get_view (so,
(SheetObjectViewContainer *)pane); (SheetObjectViewContainer *)pane);
gnm_cell_combo_view_popdown (sov, event->time); gnm_cell_combo_view_popdown
(sov,
gdk_event_get_time (event));
break; break;
} }
} }
if (event->state & SCROLL_LOCK_MASK) if (event_state & SCROLL_LOCK_MASK)
scg_set_top_row (scg, pane->first.row + 1); scg_set_top_row (scg, pane->first.row + 1);
else if (transition_keys && jump_to_bounds) { else if (transition_keys && jump_to_bounds) {
delayed_movement = TRUE; delayed_movement = TRUE;
...@@ -262,8 +269,8 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event, ...@@ -262,8 +269,8 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
case GDK_KEY_KP_Page_Up: case GDK_KEY_KP_Page_Up:
case GDK_KEY_Page_Up: case GDK_KEY_Page_Up:
if ((event->state & GDK_CONTROL_MASK) != 0){ if (event_state & GDK_CONTROL_MASK) {
if ((event->state & GDK_SHIFT_MASK) != 0){ if (event_state & GDK_SHIFT_MASK) {
WorkbookSheetState * old_state = workbook_sheet_state_new(wb); WorkbookSheetState * old_state = workbook_sheet_state_new(wb);
int old_pos = sheet->index_in_wb; int old_pos = sheet->index_in_wb;
...@@ -274,7 +281,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event, ...@@ -274,7 +281,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
} else { } else {
gnm_notebook_prev_page (wbcg->bnotebook); gnm_notebook_prev_page (wbcg->bnotebook);
} }
} else if ((event->state & GDK_MOD1_MASK) == 0) { } else if ((event_state & GDK_MOD1_MASK) == 0) {
delayed_movement = TRUE; delayed_movement = TRUE;
scg_queue_movement (scg, movefn, scg_queue_movement (scg, movefn,
-(pane->last_visible.row - pane->first.row), -(pane->last_visible.row - pane->first.row),
...@@ -290,8 +297,8 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event, ...@@ -290,8 +297,8 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
case GDK_KEY_KP_Page_Down: case GDK_KEY_KP_Page_Down:
case GDK_KEY_Page_Down: case GDK_KEY_Page_Down:
if ((event->state & GDK_CONTROL_MASK) != 0){ if ((event_state & GDK_CONTROL_MASK) != 0){
if ((event->state & GDK_SHIFT_MASK) != 0){ if ((event_state & GDK_SHIFT_MASK) != 0){
WorkbookSheetState * old_state = workbook_sheet_state_new(wb); WorkbookSheetState * old_state = workbook_sheet_state_new(wb);
int num_sheets = workbook_sheet_count(wb); int num_sheets = workbook_sheet_count(wb);
gint old_pos = sheet->index_in_wb; gint old_pos = sheet->index_in_wb;
...@@ -303,7 +310,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event, ...@@ -303,7 +310,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
} else { } else {
gnm_notebook_next_page (wbcg->bnotebook); gnm_notebook_next_page (wbcg->bnotebook);
} }
} else if ((event->state & GDK_MOD1_MASK) == 0) { } else if ((event_state & GDK_MOD1_MASK) == 0) {
delayed_movement = TRUE; delayed_movement = TRUE;
scg_queue_movement (scg, movefn, scg_queue_movement (scg, movefn,
pane->last_visible.row - pane->first.row, pane->last_visible.row - pane->first.row,
...@@ -318,7 +325,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event, ...@@ -318,7 +325,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
case GDK_KEY_KP_Home: case GDK_KEY_KP_Home:
case GDK_KEY_Home: case GDK_KEY_Home:
if (event->state & SCROLL_LOCK_MASK) { if (event_state & SCROLL_LOCK_MASK) {
scg_set_left_col (scg, sv->edit_pos.col); scg_set_left_col (scg, sv->edit_pos.col);
scg_set_top_row (scg, sv->edit_pos.row); scg_set_top_row (scg, sv->edit_pos.row);
} else if (end_mode) { } else if (end_mode) {
...@@ -329,19 +336,19 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event, ...@@ -329,19 +336,19 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
} else { } else {
/* do the ctrl-home jump to A1 in 2 steps */ /* do the ctrl-home jump to A1 in 2 steps */
(*movefn)(scg, -gnm_sheet_get_max_cols (sheet), FALSE, TRUE); (*movefn)(scg, -gnm_sheet_get_max_cols (sheet), FALSE, TRUE);
if ((event->state & GDK_CONTROL_MASK) || transition_keys) if ((event_state & GDK_CONTROL_MASK) || transition_keys)
(*movefn)(scg, -gnm_sheet_get_max_rows (sheet), FALSE, FALSE); (*movefn)(scg, -gnm_sheet_get_max_rows (sheet), FALSE, FALSE);
} }
break; break;
case GDK_KEY_KP_End: case GDK_KEY_KP_End:
case GDK_KEY_End: case GDK_KEY_End:
if (event->state & SCROLL_LOCK_MASK) { if (event_state & SCROLL_LOCK_MASK) {
int new_col = sv->edit_pos.col - (pane->last_full.col - pane->first.col); int new_col = sv->edit_pos.col - (pane->last_full.col - pane->first.col);
int new_row = sv->edit_pos.row - (pane->last_full.row - pane->first.row); int new_row = sv->edit_pos.row - (pane->last_full.row - pane->first.row);
scg_set_left_col (scg, new_col); scg_set_left_col (scg, new_col);
scg_set_top_row (scg, new_row); scg_set_top_row (scg, new_row);
} else if ((event->state & GDK_CONTROL_MASK)) { } else if ((event_state & GDK_CONTROL_MASK)) {
GnmRange r = sheet_get_extent (sheet, FALSE, TRUE); GnmRange r = sheet_get_extent (sheet, FALSE, TRUE);
/* do the ctrl-end jump to the extent in 2 steps */ /* do the ctrl-end jump to the extent in 2 steps */
...@@ -364,7 +371,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event, ...@@ -364,7 +371,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
case GDK_KEY_BackSpace: case GDK_KEY_BackSpace:
if (wbcg_is_editing (wbcg)) if (wbcg_is_editing (wbcg))
goto forward; goto forward;
else if (!wbcg_is_editing (wbcg) && (event->state & GDK_CONTROL_MASK) != 0) { else if (!wbcg_is_editing (wbcg) && (event_state & GDK_CONTROL_MASK) != 0) {
/* Re-center the view on the active cell */ /* Re-center the view on the active cell */
scg_make_cell_visible (scg, sv->edit_pos.col, scg_make_cell_visible (scg, sv->edit_pos.col,
sv->edit_pos.row, FALSE, TRUE); sv->edit_pos.row, FALSE, TRUE);
...@@ -401,7 +408,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event, ...@@ -401,7 +408,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
if (wbcg_is_editing (wbcg) && if (wbcg_is_editing (wbcg) &&
(state == GDK_CONTROL_MASK || (state == GDK_CONTROL_MASK ||
state == (GDK_CONTROL_MASK|GDK_SHIFT_MASK) || state == (GDK_CONTROL_MASK|GDK_SHIFT_MASK) ||
gnumeric_filter_modifiers (event->state) == GDK_MOD1_MASK)) gnumeric_filter_modifiers (event_state) == GDK_MOD1_MASK))
/* Forward the keystroke to the input line */ /* Forward the keystroke to the input line */
return gtk_widget_event ( return gtk_widget_event (
wbcg_get_entry_underlying (wbcg), (GdkEvent *) event); wbcg_get_entry_underlying (wbcg), (GdkEvent *) event);
...@@ -426,10 +433,10 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event, ...@@ -426,10 +433,10 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
sv->first_tab_col = first_tab_col; sv->first_tab_col = first_tab_col;
if ((event->state & GDK_MOD1_MASK) && if ((event_state & GDK_MOD1_MASK) &&
(event->state & GDK_CONTROL_MASK) && (event_state & GDK_CONTROL_MASK) &&
!is_enter) { !is_enter) {
if (event->state & GDK_SHIFT_MASK) if (event_state & GDK_SHIFT_MASK)
workbook_cmd_dec_indent (sc->wbc); workbook_cmd_dec_indent (sc->wbc);
else else
workbook_cmd_inc_indent (sc->wbc); workbook_cmd_inc_indent (sc->wbc);
...@@ -439,14 +446,14 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event, ...@@ -439,14 +446,14 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
if (is_enter) { if (is_enter) {
horizontal = go_direction_is_horizontal (dir); horizontal = go_direction_is_horizontal (dir);
forward = go_direction_is_forward (dir); forward = go_direction_is_forward (dir);
} else if ((event->state & GDK_CONTROL_MASK) && } else if ((event_state & GDK_CONTROL_MASK) &&
((sc_sheet (sc))->sheet_objects != NULL)) { ((sc_sheet (sc))->sheet_objects != NULL)) {
scg_object_select_next scg_object_select_next
(scg, (event->state & GDK_SHIFT_MASK) != 0); (scg, (event_state & GDK_SHIFT_MASK) != 0);
break; break;
} }
if (event->state & GDK_SHIFT_MASK) if (event_state & GDK_SHIFT_MASK)
forward = !forward; forward = !forward;
sv_selection_walk_step (sv, forward, horizontal); sv_selection_walk_step (sv, forward, horizontal);
...@@ -487,11 +494,11 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event, ...@@ -487,11 +494,11 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
default: default:
if (!wbcg_is_editing (wbcg)) { if (!wbcg_is_editing (wbcg)) {
if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) if ((event_state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0)
return FALSE; return FALSE;
/* If the character is not printable do not start editing */ /* If the character is not printable do not start editing */
if (event->length == 0) if (kevent->length == 0)
return FALSE; return FALSE;
if (!wbcg_edit_start (wbcg, TRUE, TRUE)) if (!wbcg_edit_start (wbcg, TRUE, TRUE))
...@@ -2426,7 +2433,7 @@ gnm_pane_display_object_menu (GnmPane *pane, SheetObject *so, GdkEvent *event) ...@@ -2426,7 +2433,7 @@ gnm_pane_display_object_menu (GnmPane *pane, SheetObject *so, GdkEvent *event)
g_object_set_data_full (G_OBJECT (menu), "actions", actions, g_object_set_data_full (G_OBJECT (menu), "actions", actions,
(GDestroyNotify)cb_ptr_array_free); (GDestroyNotify)cb_ptr_array_free);
gtk_widget_show_all (menu); gtk_widget_show_all (menu);
gnumeric_popup_menu (GTK_MENU (menu), &event->button); gnumeric_popup_menu (GTK_MENU (menu), event);
} }
static void static void
...@@ -2603,13 +2610,13 @@ gnm_pane_object_start_resize (GnmPane *pane, int button, guint64 x, gint64 y, ...@@ -2603,13 +2610,13 @@ gnm_pane_object_start_resize (GnmPane *pane, int button, guint64 x, gint64 y,
SheetObject *so, int drag_type, gboolean is_creation) SheetObject *so, int drag_type, gboolean is_creation)
{ {
GocItem **ctrl_pts; GocItem **ctrl_pts;
GdkEventButton *event; GdkEvent *event;
g_return_if_fail (IS_SHEET_OBJECT (so)); g_return_if_fail (IS_SHEET_OBJECT (so));
g_return_if_fail (0 <= drag_type); g_return_if_fail (0 <= drag_type);
g_return_if_fail (drag_type < 9); g_return_if_fail (drag_type < 9);
event = (GdkEventButton *) goc_canvas_get_cur_event (GOC_CANVAS (pane)); event = goc_canvas_get_cur_event (GOC_CANVAS (pane));
ctrl_pts = g_hash_table_lookup (pane->drag.ctrl_pts, so); ctrl_pts = g_hash_table_lookup (pane->drag.ctrl_pts, so);
g_return_if_fail (NULL != ctrl_pts); g_return_if_fail (NULL != ctrl_pts);
...@@ -2623,7 +2630,7 @@ gnm_pane_object_start_resize (GnmPane *pane, int button, guint64 x, gint64 y, ...@@ -2623,7 +2630,7 @@ gnm_pane_object_start_resize (GnmPane *pane, int button, guint64 x, gint64 y,
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK, GDK_BUTTON_RELEASE_MASK,
NULL, event->time); NULL, gdk_event_get_time (event));
pane->drag.created_objects = is_creation; pane->drag.created_objects = is_creation;
pane->drag.button = button; pane->drag.button = button;
pane->drag.last_x = pane->drag.origin_x = x; pane->drag.last_x = pane->drag.origin_x = x;
...@@ -2676,7 +2683,7 @@ static gboolean ...@@ -2676,7 +2683,7 @@ static gboolean
control_point_button_released (GocItem *item, int button, G_GNUC_UNUSED double x, G_GNUC_UNUSED double y) control_point_button_released (GocItem *item, int button, G_GNUC_UNUSED double x, G_GNUC_UNUSED double y)
{ {
GnmPane *pane = GNM_PANE (item->canvas); GnmPane *pane = GNM_PANE (item->canvas);
GdkEventButton *event = (GdkEventButton *) goc_canvas_get_cur_event (item->canvas); GdkEvent *event = goc_canvas_get_cur_event (item->canvas);
SheetControlGUI *scg = pane->simple.scg; SheetControlGUI *scg = pane->simple.scg;
SheetObject *so; SheetObject *so;
int idx; int idx;
...@@ -2686,7 +2693,7 @@ control_point_button_released (GocItem *item, int button, G_GNUC_UNUSED double x ...@@ -2686,7 +2693,7 @@ control_point_button_released (GocItem *item, int button, G_GNUC_UNUSED double x
so = g_object_get_data (G_OBJECT (item), "so"); so = g_object_get_data (G_OBJECT (item), "so");
idx = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "index")); idx = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "index"));
pane->drag.button = 0; pane->drag.button = 0;
gnm_simple_canvas_ungrab (item, event->time); gnm_simple_canvas_ungrab (item, gdk_event_get_time (event));
gnm_pane_slide_stop (pane); gnm_pane_slide_stop (pane);
control_point_set_cursor (scg, item); control_point_set_cursor (scg, item);
if (idx == 8) if (idx == 8)
......
...@@ -455,13 +455,13 @@ kill_popup_menu (G_GNUC_UNUSED GtkWidget *widget, GtkMenu *menu) ...@@ -455,13 +455,13 @@ kill_popup_menu (G_GNUC_UNUSED GtkWidget *widget, GtkMenu *menu)
/** /**
* gnumeric_popup_menu : * gnumeric_popup_menu :
* @menu: #GtkMenu * @menu: #GtkMenu
* @event: #GdkEventButton optionally NULL * @event: #GdkEvent optionally NULL
* *
* Bring up a popup and if @event is non-NULL ensure that the popup is on the * Bring up a popup and if @event is non-NULL ensure that the popup is on the
* right screen. * right screen.
**/ **/
void void
gnumeric_popup_menu (GtkMenu *menu, GdkEventButton *event) gnumeric_popup_menu (GtkMenu *menu, GdkEvent *event)
{ {
g_return_if_fail (menu != NULL); g_return_if_fail (menu != NULL);
g_return_if_fail (GTK_IS_MENU (menu)); g_return_if_fail (GTK_IS_MENU (menu));
...@@ -469,8 +469,7 @@ gnumeric_popup_menu (GtkMenu *menu, GdkEventButton *event) ...@@ -469,8 +469,7 @@ gnumeric_popup_menu (GtkMenu *menu, GdkEventButton *event)
g_object_ref_sink (menu); g_object_ref_sink (menu);
if (event) if (event)
gtk_menu_set_screen (menu, gtk_menu_set_screen (menu, gdk_event_get_screen (event));
gdk_window_get_screen (event->window));
g_signal_connect (G_OBJECT (menu), g_signal_connect (G_OBJECT (menu),
"hide", "hide",
...@@ -481,8 +480,9 @@ gnumeric_popup_menu (GtkMenu *menu, GdkEventButton *event) ...@@ -481,8 +480,9 @@ gnumeric_popup_menu (GtkMenu *menu, GdkEventButton *event)
* the right button will disable clicking on the menu with the left. * the right button will disable clicking on the menu with the left.
*/ */
gtk_menu_popup (menu, NULL, NULL, NULL, NULL, 0, gtk_menu_popup (menu, NULL, NULL, NULL, NULL, 0,
(event != NULL) ? event->time (event
: gtk_get_current_event_time()); ? gdk_event_get_time (event)
: gtk_get_current_event_time()));
} }
static void static void
...@@ -620,7 +620,7 @@ gnumeric_create_popup_menu (GnumericPopupMenuElement const *elements, ...@@ -620,7 +620,7 @@ gnumeric_create_popup_menu (GnumericPopupMenuElement const *elements,
GnumericPopupMenuHandler handler, GnumericPopupMenuHandler handler,
gpointer user_data, gpointer user_data,
int display_filter, int sensitive_filter, int display_filter, int sensitive_filter,
GdkEventButton *event) GdkEvent *event)
{ {
char const *trans; char const *trans;
GSList *menu_stack = NULL; GSList *menu_stack = NULL;
......
...@@ -33,7 +33,7 @@ int gnm_gtk_radio_group_get_selected (GSList *radio_group); ...@@ -33,7 +33,7 @@ int gnm_gtk_radio_group_get_selected (GSList *radio_group);
int gnm_gui_group_value (gpointer gui, char const * const group[]); int gnm_gui_group_value (gpointer gui, char const * const group[]);
/* Use this on menus that are popped up */ /* Use this on menus that are popped up */
void gnumeric_popup_menu (GtkMenu *menu, GdkEventButton *event); void gnumeric_popup_menu (GtkMenu *menu, GdkEvent *event);
/* /*
* Pseudo-tooltip support code. * Pseudo-tooltip support code.
...@@ -66,7 +66,7 @@ void gnumeric_create_popup_menu (GnumericPopupMenuElement const *elements, ...@@ -66,7 +66,7 @@ void gnumeric_create_popup_menu (GnumericPopupMenuElement const *elements,
gpointer user_data, gpointer user_data,
int display_filter, int display_filter,
int sensitive_filter, int sensitive_filter,
GdkEventButton *event); GdkEvent *event);
#define gnumeric_filter_modifiers(a) ((a) &(~(GDK_LOCK_MASK|GDK_MOD2_MASK|GDK_MOD5_MASK))) #define gnumeric_filter_modifiers(a) ((a) &(~(GDK_LOCK_MASK|GDK_MOD2_MASK|GDK_MOD5_MASK)))
......
...@@ -899,7 +899,8 @@ item_bar_button_pressed (GocItem *item, int button, double x_, double y_) ...@@ -899,7 +899,8 @@ item_bar_button_pressed (GocItem *item, int button, double x_, double y_)
gboolean const is_cols = ib->is_col_header; gboolean const is_cols = ib->is_col_header;
gint64 minor_pos, start; gint64 minor_pos, start;
int element; int element;
GdkEventButton *event = (GdkEventButton *) goc_canvas_get_cur_event (item->canvas); GdkEvent *event = goc_canvas_get_cur_event (item->canvas);
GdkEventButton *bevent = &event->button;
gint64 x = x_ * item->canvas->pixels_per_unit, y = y_ * item->canvas->pixels_per_unit; gint64 x = x_ * item->canvas->pixels_per_unit, y = y_ * item->canvas->pixels_per_unit;
if (button > 3) if (button > 3)
...@@ -923,7 +924,7 @@ item_bar_button_pressed (GocItem *item, int button, double x_, double y_) ...@@ -923,7 +924,7 @@ item_bar_button_pressed (GocItem *item, int button, double x_, double y_)
*/ */
if (!sv_is_colrow_selected (sc_view (sc), element, is_cols)) if (!sv_is_colrow_selected (sc_view (sc), element, is_cols))
scg_colrow_select (scg, is_cols, scg_colrow_select (scg, is_cols,
element, event->state); element, bevent->state);
scg_context_menu (scg, event, is_cols, !is_cols); scg_context_menu (scg, event, is_cols, !is_cols);
return TRUE; return TRUE;
...@@ -963,15 +964,17 @@ item_bar_button_pressed (GocItem *item, int button, double x_, double y_) ...@@ -963,15 +964,17 @@ item_bar_button_pressed (GocItem *item, int button, double x_, double y_)
return TRUE; return TRUE;
/* If we're editing it is possible for this to fail */ /* If we're editing it is possible for this to fail */
if (!scg_colrow_select (scg, is_cols, element, event->state)) if (!scg_colrow_select (scg, is_cols, element, bevent->state))
return TRUE; return TRUE;
ib->start_selection = element; ib->start_selection = element;
gnm_pane_slide_init (pane); gnm_pane_slide_init (pane);
} }
gnm_simple_canvas_grab (item, gnm_simple_canvas_grab
GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, (item,
ib->change_cursor, event->time); GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
ib->change_cursor,
gdk_event_get_time (event));
return TRUE; return TRUE;
} }
......
...@@ -608,7 +608,7 @@ item_cursor_selection_motion (GocItem *item, double x_, double y_) ...@@ -608,7 +608,7 @@ item_cursor_selection_motion (GocItem *item, double x_, double y_)
int style, button; int style, button;
gint64 x = x_ * canvas->pixels_per_unit, y = y_ * canvas->pixels_per_unit; gint64 x = x_ * canvas->pixels_per_unit, y = y_ * canvas->pixels_per_unit;
GnmItemCursor *special_cursor; GnmItemCursor *special_cursor;
GdkEventMotion *event = (GdkEventMotion *) goc_canvas_get_cur_event (item->canvas); GdkEvent *event = goc_canvas_get_cur_event (item->canvas);
if (ic->drag_button < 0) { if (ic->drag_button < 0) {