[gnumeric] Event handling: peek less into GdkEvent.



commit 400413d9832a3ccb6b32d9dd435835ce36c461e1
Author: Morten Welinder <terra gnome org>
Date:   Wed Dec 11 22:18:36 2013 -0500

    Event handling: peek less into GdkEvent.

 ChangeLog                            |    7 +++
 src/dialogs/dialog-cell-sort.c       |    2 +-
 src/dialogs/dialog-stf-fixed-page.c  |    3 +-
 src/dialogs/dialog-stf-format-page.c |   10 ++--
 src/gnm-pane.c                       |   95 ++++++++++++++++++----------------
 src/gui-util.c                       |   14 +++---
 src/gui-util.h                       |    4 +-
 src/item-bar.c                       |   15 +++--
 src/item-cursor.c                    |   35 ++++++------
 src/item-grid.c                      |   26 +++++-----
 src/sheet-control-gui.c              |    2 +-
 src/sheet-control-gui.h              |    2 +-
 src/sheet-object.c                   |    3 +-
 src/wbc-gtk.c                        |   28 +++++-----
 14 files changed, 134 insertions(+), 112 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d67abd2..782cf05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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>
 
        * src/application.c (gnm_app_init): Don't allocate a
diff --git a/src/dialogs/dialog-cell-sort.c b/src/dialogs/dialog-cell-sort.c
index c13b28e..f931853 100644
--- a/src/dialogs/dialog-cell-sort.c
+++ b/src/dialogs/dialog-cell-sort.c
@@ -851,7 +851,7 @@ cb_treeview_button_press(G_GNUC_UNUSED GtkWidget *w, GdkEvent *event, SortFlowSt
        if ((event->type == GDK_BUTTON_PRESS) &&
            (event->button.button == 3)) {
                gnumeric_popup_menu (build_sort_field_base_menu(state),
-                                    &(event->button));
+                                    event);
                return TRUE;
        }
 
diff --git a/src/dialogs/dialog-stf-fixed-page.c b/src/dialogs/dialog-stf-fixed-page.c
index b9445c2..4042f77 100644
--- a/src/dialogs/dialog-stf-fixed-page.c
+++ b/src/dialogs/dialog-stf-fixed-page.c
@@ -262,7 +262,8 @@ fixed_context_menu (StfDialogData *pagedata, GdkEventButton *event,
        select_column (pagedata, col);
        gnumeric_create_popup_menu (popup_elements, &fixed_context_menu_handler,
                                    pagedata, 0,
-                                   sensitivity_filter, event);
+                                   sensitivity_filter,
+                                   (GdkEvent*)event);
 }
 
 static gint
diff --git a/src/dialogs/dialog-stf-format-page.c b/src/dialogs/dialog-stf-format-page.c
index cab05db..7719162 100644
--- a/src/dialogs/dialog-stf-format-page.c
+++ b/src/dialogs/dialog-stf-format-page.c
@@ -369,7 +369,7 @@ cb_popup_menu_extend_format (GtkWidget *widget, gpointer data)
 
 static void
 format_context_menu (StfDialogData *pagedata,
-                    GdkEventButton *event_button,
+                    GdkEvent *event,
                     int col)
 {
        enum {
@@ -421,7 +421,7 @@ format_context_menu (StfDialogData *pagedata,
                                  pagedata);
        }
 
-       gnumeric_popup_menu (GTK_MENU (menu), event_button);
+       gnumeric_popup_menu (GTK_MENU (menu), event);
 }
 
 
@@ -429,7 +429,7 @@ static gint
 cb_col_event (GtkWidget *widget, GdkEvent *event, gpointer _col)
 {
        if (event->type == GDK_BUTTON_PRESS) {
-               GdkEventButton *event_button = (GdkEventButton *) event;
+               GdkEventButton *event_button = &event->button;
                StfDialogData *pagedata =
                        g_object_get_data (G_OBJECT (widget), "pagedata");
                int col = GPOINTER_TO_INT (_col);
@@ -455,7 +455,7 @@ cb_col_event (GtkWidget *widget, GdkEvent *event, gpointer _col)
                        if (event_button->x <= xmax)
                                gtk_button_clicked (GTK_BUTTON (check));
                } else if (event_button->button == 3) {
-                       format_context_menu (pagedata, event_button, col);
+                       format_context_menu (pagedata, event, col);
                }
                return TRUE;
        }
@@ -477,7 +477,7 @@ cb_treeview_button_press (GtkWidget *treeview,
                int dx, col;
                stf_preview_find_column (pagedata->format.renderdata, (int)event->x, &col, &dx);
                activate_column (pagedata, col);
-               format_context_menu (pagedata, event, col);
+               format_context_menu (pagedata, (GdkEvent*)event, col);
                return TRUE;
        }
 
diff --git a/src/gnm-pane.c b/src/gnm-pane.c
index 2605a52..89e4ada 100644
--- a/src/gnm-pane.c
+++ b/src/gnm-pane.c
@@ -68,7 +68,7 @@ static GtkTargetEntry const drag_types_out[] = {
 };
 
 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);
 
@@ -76,7 +76,7 @@ gnm_pane_guru_key (WBCGtk const *wbcg, GdkEventKey *event)
                return FALSE;
 
        entry = wbcg_get_entry_underlying (wbcg);
-       gtk_widget_event ((entry != NULL) ? entry : guru, (GdkEvent *) event);
+       gtk_widget_event (entry ? entry : guru, event);
        return TRUE;
 }
 
@@ -141,9 +141,10 @@ gnm_pane_object_key_press (GnmPane *pane, GdkEventKey *ev)
 }
 
 static gboolean
-gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
+gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *kevent,
                         gboolean allow_rangesel)
 {
+       GdkEvent *event = (GdkEvent *)kevent;
        SheetControlGUI *scg = pane->simple.scg;
        SheetControl *sc = (SheetControl *) scg;
        SheetView *sv = sc->view;
@@ -152,38 +153,42 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
        WorkbookControl * wbc = scg_wbc(scg);
        Workbook * wb = wb_control_get_workbook(wbc);
        gboolean delayed_movement = FALSE;
-       gboolean jump_to_bounds = event->state & GDK_CONTROL_MASK;
+       gboolean jump_to_bounds;
        gboolean is_enter = FALSE;
        int first_tab_col;
-       int state = gnumeric_filter_modifiers (event->state);
+       int state;
        void (*movefn) (SheetControlGUI *, int n, gboolean jump, gboolean horiz);
-
        gboolean transition_keys = gnm_conf_get_core_gui_editing_transitionkeys ();
        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. */
-       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);
 
        if (allow_rangesel)
-               movefn = (event->state & GDK_SHIFT_MASK)
+               movefn = (event_state & GDK_SHIFT_MASK)
                        ? scg_rangesel_extend
                        : scg_rangesel_move;
        else
-               movefn = (event->state & GDK_SHIFT_MASK)
+               movefn = (event_state & GDK_SHIFT_MASK)
                        ? scg_cursor_extend
                        : scg_cursor_move;
 
-       switch (event->keyval) {
+       switch (kevent->keyval) {
        case GDK_KEY_a:
                scg_select_all (scg);
                break;
        case GDK_KEY_KP_Left:
        case GDK_KEY_Left:
-               if (event->state & GDK_MOD1_MASK)
+               if (event_state & GDK_MOD1_MASK)
                        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);
                else if (transition_keys && jump_to_bounds) {
                        delayed_movement = TRUE;
@@ -197,10 +202,10 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
 
        case GDK_KEY_KP_Right:
        case GDK_KEY_Right:
-               if (event->state & GDK_MOD1_MASK)
+               if (event_state & GDK_MOD1_MASK)
                        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);
                else if (transition_keys && jump_to_bounds) {
                        delayed_movement = TRUE;
@@ -214,7 +219,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
 
        case GDK_KEY_KP_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);
                else if (transition_keys && jump_to_bounds) {
                        delayed_movement = TRUE;
@@ -227,7 +232,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
 
        case GDK_KEY_KP_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 ? */
                        SheetObject *so = sv_wbv (sv)->in_cell_combo;
 
@@ -244,12 +249,14 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
                        if (NULL != so) {
                                SheetObjectView *sov = sheet_object_get_view (so,
                                        (SheetObjectViewContainer *)pane);
-                               gnm_cell_combo_view_popdown (sov, event->time);
+                               gnm_cell_combo_view_popdown
+                                       (sov,
+                                        gdk_event_get_time (event));
                                break;
                        }
                }
 
-               if (event->state & SCROLL_LOCK_MASK)
+               if (event_state & SCROLL_LOCK_MASK)
                        scg_set_top_row (scg, pane->first.row + 1);
                else if (transition_keys && jump_to_bounds) {
                        delayed_movement = TRUE;
@@ -262,8 +269,8 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
 
        case GDK_KEY_KP_Page_Up:
        case GDK_KEY_Page_Up:
-               if ((event->state & GDK_CONTROL_MASK) != 0){
-                       if ((event->state & GDK_SHIFT_MASK) != 0){
+               if (event_state & GDK_CONTROL_MASK) {
+                       if (event_state & GDK_SHIFT_MASK) {
                                WorkbookSheetState * old_state = workbook_sheet_state_new(wb);
                                int old_pos = sheet->index_in_wb;
 
@@ -274,7 +281,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
                        } else {
                                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;
                        scg_queue_movement (scg, movefn,
                                            -(pane->last_visible.row - pane->first.row),
@@ -290,8 +297,8 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
        case GDK_KEY_KP_Page_Down:
        case GDK_KEY_Page_Down:
 
-               if ((event->state & GDK_CONTROL_MASK) != 0){
-                       if ((event->state & GDK_SHIFT_MASK) != 0){
+               if ((event_state & GDK_CONTROL_MASK) != 0){
+                       if ((event_state & GDK_SHIFT_MASK) != 0){
                                WorkbookSheetState * old_state = workbook_sheet_state_new(wb);
                                int num_sheets = workbook_sheet_count(wb);
                                gint old_pos = sheet->index_in_wb;
@@ -303,7 +310,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
                        } else {
                                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;
                        scg_queue_movement (scg, movefn,
                                            pane->last_visible.row - pane->first.row,
@@ -318,7 +325,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
 
        case GDK_KEY_KP_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_top_row (scg, sv->edit_pos.row);
                } else if (end_mode) {
@@ -329,19 +336,19 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
                } else {
                        /* do the ctrl-home jump to A1 in 2 steps */
                        (*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);
                }
                break;
 
        case GDK_KEY_KP_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_row = sv->edit_pos.row - (pane->last_full.row - pane->first.row);
                        scg_set_left_col (scg, new_col);
                        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);
 
                        /* do the ctrl-end jump to the extent in 2 steps */
@@ -364,7 +371,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
        case GDK_KEY_BackSpace:
                if (wbcg_is_editing (wbcg))
                        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 */
                        scg_make_cell_visible (scg, sv->edit_pos.col,
                                               sv->edit_pos.row, FALSE, TRUE);
@@ -401,7 +408,7 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
                if (wbcg_is_editing (wbcg) &&
                    (state == GDK_CONTROL_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 */
                        return gtk_widget_event (
                                wbcg_get_entry_underlying (wbcg), (GdkEvent *) event);
@@ -426,10 +433,10 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
 
                        sv->first_tab_col = first_tab_col;
 
-                       if ((event->state & GDK_MOD1_MASK) &&
-                           (event->state & GDK_CONTROL_MASK) &&
+                       if ((event_state & GDK_MOD1_MASK) &&
+                           (event_state & GDK_CONTROL_MASK) &&
                            !is_enter) {
-                               if (event->state & GDK_SHIFT_MASK)
+                               if (event_state & GDK_SHIFT_MASK)
                                        workbook_cmd_dec_indent (sc->wbc);
                                else
                                        workbook_cmd_inc_indent (sc->wbc);
@@ -439,14 +446,14 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
                                if (is_enter) {
                                        horizontal = go_direction_is_horizontal (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)) {
                                        scg_object_select_next
-                                               (scg, (event->state & GDK_SHIFT_MASK) != 0);
+                                               (scg, (event_state & GDK_SHIFT_MASK) != 0);
                                        break;
                                }
 
-                               if (event->state & GDK_SHIFT_MASK)
+                               if (event_state & GDK_SHIFT_MASK)
                                        forward = !forward;
 
                                sv_selection_walk_step (sv, forward, horizontal);
@@ -487,11 +494,11 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
 
        default:
                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;
 
                        /* If the character is not printable do not start editing */
-                       if (event->length == 0)
+                       if (kevent->length == 0)
                                return FALSE;
 
                        if (!wbcg_edit_start (wbcg, TRUE, TRUE))
@@ -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,
                (GDestroyNotify)cb_ptr_array_free);
        gtk_widget_show_all (menu);
-       gnumeric_popup_menu (GTK_MENU (menu), &event->button);
+       gnumeric_popup_menu (GTK_MENU (menu), event);
 }
 
 static void
@@ -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)
 {
        GocItem **ctrl_pts;
-       GdkEventButton *event;
+       GdkEvent *event;
 
        g_return_if_fail (IS_SHEET_OBJECT (so));
        g_return_if_fail (0 <= drag_type);
        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);
 
        g_return_if_fail (NULL != ctrl_pts);
@@ -2623,7 +2630,7 @@ gnm_pane_object_start_resize (GnmPane *pane, int button, guint64 x, gint64 y,
                GDK_POINTER_MOTION_MASK |
                GDK_BUTTON_PRESS_MASK |
                GDK_BUTTON_RELEASE_MASK,
-               NULL, event->time);
+               NULL, gdk_event_get_time (event));
        pane->drag.created_objects = is_creation;
        pane->drag.button = button;
        pane->drag.last_x = pane->drag.origin_x = x;
@@ -2676,7 +2683,7 @@ static gboolean
 control_point_button_released (GocItem *item, int button, G_GNUC_UNUSED double x, G_GNUC_UNUSED double y)
 {
        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;
        SheetObject *so;
        int idx;
@@ -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");
        idx = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "index"));
        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);
        control_point_set_cursor (scg, item);
        if (idx == 8)
diff --git a/src/gui-util.c b/src/gui-util.c
index 35dc3d7..9229d9a 100644
--- a/src/gui-util.c
+++ b/src/gui-util.c
@@ -455,13 +455,13 @@ kill_popup_menu (G_GNUC_UNUSED GtkWidget *widget, GtkMenu *menu)
 /**
  * gnumeric_popup_menu :
  * @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
  * right screen.
  **/
 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 (GTK_IS_MENU (menu));
@@ -469,8 +469,7 @@ gnumeric_popup_menu (GtkMenu *menu, GdkEventButton *event)
        g_object_ref_sink (menu);
 
        if (event)
-               gtk_menu_set_screen (menu,
-                                    gdk_window_get_screen (event->window));
+               gtk_menu_set_screen (menu, gdk_event_get_screen (event));
 
        g_signal_connect (G_OBJECT (menu),
                "hide",
@@ -481,8 +480,9 @@ gnumeric_popup_menu (GtkMenu *menu, GdkEventButton *event)
         * the right button will disable clicking on the menu with the left.
         */
        gtk_menu_popup (menu, NULL, NULL, NULL, NULL, 0,
-                       (event != NULL) ? event->time
-                       : gtk_get_current_event_time());
+                       (event
+                        ? gdk_event_get_time (event)
+                        : gtk_get_current_event_time()));
 }
 
 static void
@@ -620,7 +620,7 @@ gnumeric_create_popup_menu (GnumericPopupMenuElement const *elements,
                            GnumericPopupMenuHandler handler,
                            gpointer user_data,
                            int display_filter, int sensitive_filter,
-                           GdkEventButton *event)
+                           GdkEvent *event)
 {
        char const *trans;
        GSList *menu_stack = NULL;
diff --git a/src/gui-util.h b/src/gui-util.h
index da14707..d3f8ecc 100644
--- a/src/gui-util.h
+++ b/src/gui-util.h
@@ -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[]);
 
 /* 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.
@@ -66,7 +66,7 @@ void gnumeric_create_popup_menu (GnumericPopupMenuElement const *elements,
                                 gpointer user_data,
                                 int display_filter,
                                 int sensitive_filter,
-                                GdkEventButton *event);
+                                GdkEvent *event);
 
 #define gnumeric_filter_modifiers(a) ((a) &(~(GDK_LOCK_MASK|GDK_MOD2_MASK|GDK_MOD5_MASK)))
 
diff --git a/src/item-bar.c b/src/item-bar.c
index dbf4a94..79f786c 100644
--- a/src/item-bar.c
+++ b/src/item-bar.c
@@ -899,7 +899,8 @@ item_bar_button_pressed (GocItem *item, int button, double x_, double y_)
        gboolean const is_cols = ib->is_col_header;
        gint64 minor_pos, start;
        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;
 
        if (button > 3)
@@ -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))
                        scg_colrow_select (scg, is_cols,
-                                          element, event->state);
+                                          element, bevent->state);
 
                scg_context_menu (scg, event, is_cols, !is_cols);
                return TRUE;
@@ -963,15 +964,17 @@ item_bar_button_pressed (GocItem *item, int button, double x_, double y_)
                        return TRUE;
 
                /* 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;
 
                ib->start_selection = element;
                gnm_pane_slide_init (pane);
        }
-       gnm_simple_canvas_grab (item,
-               GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
-               ib->change_cursor, event->time);
+       gnm_simple_canvas_grab
+               (item,
+                GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
+                ib->change_cursor,
+                gdk_event_get_time (event));
        return TRUE;
 }
 
diff --git a/src/item-cursor.c b/src/item-cursor.c
index a47da27..6be64a7 100644
--- a/src/item-cursor.c
+++ b/src/item-cursor.c
@@ -608,7 +608,7 @@ item_cursor_selection_motion (GocItem *item, double x_, double y_)
        int style, button;
        gint64 x = x_ * canvas->pixels_per_unit, y = y_ * canvas->pixels_per_unit;
        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) {
                item_cursor_set_cursor (canvas, ic, x, y);
@@ -626,7 +626,7 @@ item_cursor_selection_motion (GocItem *item, double x_, double y_)
 
        button = ic->drag_button;
        ic->drag_button = -1;
-       gnm_simple_canvas_ungrab (item, event->time);
+       gnm_simple_canvas_ungrab (item, gdk_event_get_time (event));
 
        scg_special_cursor_start (ic->scg, style, button);
        special_cursor = pane->cursor.special;
@@ -673,7 +673,7 @@ item_cursor_selection_motion (GocItem *item, double x_, double y_)
 
        gnm_simple_canvas_grab (GOC_ITEM (special_cursor),
                GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK,
-               NULL, event->time);
+               NULL, gdk_event_get_time (event));
        gnm_pane_slide_init (pane);
 
        goc_item_bounds_changed (GOC_ITEM (ic));
@@ -777,7 +777,7 @@ context_menu_hander (GnumericPopupMenuElement const *element,
 }
 
 static void
-item_cursor_popup_menu (GnmItemCursor *ic, GdkEventButton *event)
+item_cursor_popup_menu (GnmItemCursor *ic, GdkEvent *event)
 {
        static GnumericPopupMenuElement const popup_elements[] = {
                { N_("_Move"),          NULL,
@@ -816,7 +816,7 @@ item_cursor_popup_menu (GnmItemCursor *ic, GdkEventButton *event)
 }
 
 static void
-item_cursor_do_drop (GnmItemCursor *ic, GdkEventButton *event)
+item_cursor_do_drop (GnmItemCursor *ic, GdkEvent *event)
 {
        /* Only do the operation if something moved */
        SheetView const *sv = scg_view (ic->scg);
@@ -828,10 +828,10 @@ item_cursor_do_drop (GnmItemCursor *ic, GdkEventButton *event)
                return;
        }
 
-       if (event->button == 3)
+       if (event->button.button == 3)
                item_cursor_popup_menu (ic, event);
        else
-               item_cursor_do_action (ic, (event->state & GDK_CONTROL_MASK)
+               item_cursor_do_action (ic, (event->button.state & GDK_CONTROL_MASK)
                                       ? ACTION_COPY_CELLS
                                       : ACTION_MOVE_CELLS);
 }
@@ -1033,7 +1033,8 @@ item_cursor_button_pressed (GocItem *item, int button, double x_, double y_)
 {
        GnmItemCursor *ic = GNM_ITEM_CURSOR (item);
        gint64 x = x_ * item->canvas->pixels_per_unit, y = y_ * item->canvas->pixels_per_unit;
-       GdkEventButton *event = (GdkEventButton *) goc_canvas_get_cur_event (item->canvas);
+       GdkEvent *event = goc_canvas_get_cur_event (item->canvas);
+       GdkEventButton *bevent = &event->button;
        if (ic->style == GNM_ITEM_CURSOR_EXPR_RANGE)
                return FALSE;
 
@@ -1077,10 +1078,10 @@ item_cursor_button_pressed (GocItem *item, int button, double x_, double y_)
                                                                     _("Drag to move"));
 
                        ic->drag_button = button;
-                       ic->drag_button_state = event->state;
+                       ic->drag_button_state = bevent->state;
                        gnm_simple_canvas_grab (item,
                                GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK,
-                               NULL, event->time);
+                               NULL, gdk_event_get_time (event));
                } else
                        scg_context_menu (ic->scg, event, FALSE, FALSE);
                return TRUE;
@@ -1103,7 +1104,7 @@ static gboolean
 item_cursor_button2_pressed (GocItem *item, int button, double x_, double y_)
 {
        GnmItemCursor *ic = GNM_ITEM_CURSOR (item);
-       GdkEventButton *event = (GdkEventButton *) goc_canvas_get_cur_event (item->canvas);
+       GdkEvent *event = goc_canvas_get_cur_event (item->canvas);
 
        switch (ic->style) {
 
@@ -1116,7 +1117,7 @@ item_cursor_button2_pressed (GocItem *item, int button, double x_, double y_)
                        return TRUE;
 
                ic->drag_button = -1;
-               gnm_simple_canvas_ungrab (item, event->time);
+               gnm_simple_canvas_ungrab (item, gdk_event_get_time (event));
 
                if (sheet_is_region_empty (sheet, &ic->pos))
                        return TRUE;
@@ -1134,7 +1135,7 @@ item_cursor_button2_pressed (GocItem *item, int button, double x_, double y_)
                 * find the boundary of the region being filled.
                 */
 
-               if (event->state & GDK_MOD1_MASK) {
+               if (event->button.state & GDK_MOD1_MASK) {
                        int template_col = ic->pos.end.col + 1;
                        int template_row = ic->pos.start.row - 1;
                        int boundary_col_for_target;
@@ -1309,7 +1310,7 @@ static gboolean
 item_cursor_button_released (GocItem *item, int button, G_GNUC_UNUSED double x, G_GNUC_UNUSED double y)
 {
        GnmItemCursor *ic = GNM_ITEM_CURSOR (item);
-       GdkEventButton *event = (GdkEventButton *) goc_canvas_get_cur_event (item->canvas);
+       GdkEvent *event = goc_canvas_get_cur_event (item->canvas);
        WBCGtk *wbcg = scg_wbcg (ic->scg);
 
        if (ic->style == GNM_ITEM_CURSOR_EXPR_RANGE)
@@ -1331,7 +1332,7 @@ item_cursor_button_released (GocItem *item, int button, G_GNUC_UNUSED double x,
 
                /* Double clicks may have already released the drag prep */
                if (ic->drag_button >= 0) {
-                       gnm_simple_canvas_ungrab (item, event->time);
+                       gnm_simple_canvas_ungrab (item, gdk_event_get_time (event));
                        ic->drag_button = -1;
                }
                go_cmd_context_progress_message_set (GO_CMD_CONTEXT (wbcg),
@@ -1343,7 +1344,7 @@ item_cursor_button_released (GocItem *item, int button, G_GNUC_UNUSED double x,
                        return TRUE;
 
                gnm_pane_slide_stop (GNM_PANE (item->canvas));
-               gnm_simple_canvas_ungrab (item, event->time);
+               gnm_simple_canvas_ungrab (item, gdk_event_get_time (event));
                item_cursor_do_drop (ic, event);
 
                go_cmd_context_progress_message_set (GO_CMD_CONTEXT (wbcg),
@@ -1359,7 +1360,7 @@ item_cursor_button_released (GocItem *item, int button, G_GNUC_UNUSED double x,
                SheetControlGUI *scg = ic->scg;
 
                gnm_pane_slide_stop (GNM_PANE (item->canvas));
-               gnm_simple_canvas_ungrab (item, event->time);
+               gnm_simple_canvas_ungrab (item, gdk_event_get_time (event));
 
                cmd_autofill (scg_wbc (scg), scg_sheet (scg), default_increment,
                              ic->pos.start.col, ic->pos.start.row,
diff --git a/src/item-grid.c b/src/item-grid.c
index 5254c81..7dbaa72 100644
--- a/src/item-grid.c
+++ b/src/item-grid.c
@@ -898,7 +898,7 @@ item_grid_button_pressed (GocItem *item, int button, double x_, double y_)
        GnmCellPos      pos;
        gboolean edit_showed_dialog;
        gboolean already_selected;
-       GdkEventButton *event = (GdkEventButton *) goc_canvas_get_cur_event (item->canvas);
+       GdkEvent *event = goc_canvas_get_cur_event (item->canvas);
        gint64 x = x_ * canvas->pixels_per_unit, y = y_ * canvas->pixels_per_unit;
 
        gnm_pane_slide_stop (pane);
@@ -928,14 +928,14 @@ item_grid_button_pressed (GocItem *item, int button, double x_, double y_)
         */
        if (button == 1 && scg->rangesel.active) {
                ig->selecting = GNM_ITEM_GRID_SELECTING_FORMULA_RANGE;
-               if (event->state & GDK_SHIFT_MASK)
+               if (event->button.state & GDK_SHIFT_MASK)
                        scg_rangesel_extend_to (scg, pos.col, pos.row);
                else
                        scg_rangesel_bound (scg, pos.col, pos.row, pos.col, pos.row);
                gnm_pane_slide_init (pane);
                gnm_simple_canvas_grab (item,
                        GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
-                       NULL, event->time);
+                       NULL, gdk_event_get_time (event));
                return TRUE;
        }
 
@@ -948,7 +948,7 @@ item_grid_button_pressed (GocItem *item, int button, double x_, double y_)
                gnm_pane_slide_init (pane);
                gnm_simple_canvas_grab (item,
                        GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
-                       NULL, event->time);
+                       NULL, gdk_event_get_time (event));
                return TRUE;
        }
 
@@ -972,14 +972,14 @@ item_grid_button_pressed (GocItem *item, int button, double x_, double y_)
         * only effect things if the target is not already selected.  */
        already_selected = sv_is_pos_selected (sv, pos.col, pos.row);
        if (button == 1 || button == 2 || !already_selected) {
-               if (!(event->state & (GDK_CONTROL_MASK|GDK_SHIFT_MASK)))
+               if (!(event->button.state & (GDK_CONTROL_MASK|GDK_SHIFT_MASK)))
                        sv_selection_reset (sv);
 
-               if ((event->button != 1 && event->button != 2) 
-                   || !(event->state & GDK_SHIFT_MASK) ||
+               if ((event->button.button != 1 && event->button.button != 2) 
+                   || !(event->button.state & GDK_SHIFT_MASK) ||
                    sv->selections == NULL) {
                        sv_selection_add_pos (sv, pos.col, pos.row,
-                                             (already_selected && (event->state & GDK_CONTROL_MASK)) ?
+                                             (already_selected && (event->button.state & GDK_CONTROL_MASK)) ?
                                              GNM_SELECTION_MODE_REMOVE :
                                              GNM_SELECTION_MODE_ADD);
                        sv_make_cell_visible (sv, pos.col, pos.row, FALSE);
@@ -1004,18 +1004,18 @@ item_grid_button_pressed (GocItem *item, int button, double x_, double y_)
                                      "gtk-double-click-time", &double_click_time,
                                      NULL);
 
-                       if ((ig->last_click_time + double_click_time) > event->time &&
+                       if ((ig->last_click_time + double_click_time) > gdk_event_get_time (event) &&
                            wbcg_edit_start (wbcg, FALSE, FALSE)) {
                                break;
                        }
                }
 
-               ig->last_click_time = event->time;
+               ig->last_click_time = gdk_event_get_time (event);
                ig->selecting = GNM_ITEM_GRID_SELECTING_CELL_RANGE;
                gnm_pane_slide_init (pane);
                gnm_simple_canvas_grab (item,
                        GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
-                       NULL, event->time);
+                       NULL, gdk_event_get_time (event));
                break;
        }
 
@@ -1130,7 +1130,7 @@ item_grid_button_released (GocItem *item, int button, G_GNUC_UNUSED double x_, G
        SheetControlGUI *scg = ig->scg;
        Sheet *sheet = scg_sheet (scg);
        ItemGridSelectionType selecting = ig->selecting;
-       GdkEventButton *event = (GdkEventButton *) goc_canvas_get_cur_event (item->canvas);
+       GdkEvent *event = goc_canvas_get_cur_event (item->canvas);
 
        if (button != 1 && button != 2)
                return FALSE;
@@ -1158,7 +1158,7 @@ item_grid_button_released (GocItem *item, int button, G_GNUC_UNUSED double x_, G
        }
 
        ig->selecting = GNM_ITEM_GRID_NO_SELECTION;
-       gnm_simple_canvas_ungrab (item, event->time);
+       gnm_simple_canvas_ungrab (item, gdk_event_get_time (event));
 
        if (selecting == GNM_ITEM_GRID_SELECTING_FORMULA_RANGE)
                gnm_expr_entry_signal_update (
diff --git a/src/sheet-control-gui.c b/src/sheet-control-gui.c
index 542976b..3c1a257 100644
--- a/src/sheet-control-gui.c
+++ b/src/sheet-control-gui.c
@@ -2074,7 +2074,7 @@ context_menu_handler (GnumericPopupMenuElement const *element,
 }
 
 void
-scg_context_menu (SheetControlGUI *scg, GdkEventButton *event,
+scg_context_menu (SheetControlGUI *scg, GdkEvent *event,
                  gboolean is_col, gboolean is_row)
 {
        SheetView *sv    = scg_view (scg);
diff --git a/src/sheet-control-gui.h b/src/sheet-control-gui.h
index 093160f..19e8673 100644
--- a/src/sheet-control-gui.h
+++ b/src/sheet-control-gui.h
@@ -18,7 +18,7 @@ SheetControlGUI *sheet_control_gui_new            (SheetView *sv, WBCGtk *wbcg);
 
 void scg_take_focus             (SheetControlGUI *scg);
 
-void scg_context_menu          (SheetControlGUI *scg, GdkEventButton *event,
+void scg_context_menu          (SheetControlGUI *scg, GdkEvent *event,
                                 gboolean is_col, gboolean is_row);
 
 void scg_object_anchor_to_coords (SheetControlGUI const *scg,
diff --git a/src/sheet-object.c b/src/sheet-object.c
index 1100c9f..0d3b536 100644
--- a/src/sheet-object.c
+++ b/src/sheet-object.c
@@ -1445,7 +1445,8 @@ sheet_object_view_button_pressed (GocItem *item, int button, double x, double y)
                        g_object_set_data_full (G_OBJECT (menu), "actions", actions,
                                (GDestroyNotify) cb_ptr_array_free);
                        gtk_widget_show_all (menu);
-                       gnumeric_popup_menu (GTK_MENU (menu), &goc_canvas_get_cur_event 
(item->canvas)->button);
+                       gnumeric_popup_menu (GTK_MENU (menu),
+                                            goc_canvas_get_cur_event (item->canvas));
                }
        }
        return TRUE;
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index 18d2e74..04751ec 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -492,7 +492,7 @@ cb_by_scg_sheet_name (gconstpointer a_, gconstpointer b_)
 
 
 static void
-sheet_menu_label_run (SheetControlGUI *scg, GdkEventButton *event)
+sheet_menu_label_run (SheetControlGUI *scg, GdkEvent *event)
 {
        enum { CM_MULTIPLE = 1, CM_DATA_SHEET = 2 };
        struct SheetTabMenu {
@@ -577,7 +577,7 @@ sheet_menu_label_run (SheetControlGUI *scg, GdkEventButton *event)
  * This takes care of switching to the notebook that contains the label
  */
 static gboolean
-cb_sheet_label_button_press (GtkWidget *widget, GdkEventButton *event,
+cb_sheet_label_button_press (GtkWidget *widget, GdkEvent *event,
                             SheetControlGUI *scg)
 {
        WBCGtk *wbcg = scg->wbcg;
@@ -590,10 +590,10 @@ cb_sheet_label_button_press (GtkWidget *widget, GdkEventButton *event,
                                             GTK_WIDGET (scg->grid));
        gnm_notebook_set_current_page (wbcg->bnotebook, page_number);
 
-       if (event->button == 1 || NULL != wbcg->rangesel)
+       if (event->button.button == 1 || NULL != wbcg->rangesel)
                return FALSE;
 
-       if (event->button == 3) {
+       if (event->button.button == 3) {
                if ((scg_wbcg (scg))->edit_line.guru == NULL)
                        scg_object_unselect (scg, NULL);
                if (g_object_get_data (G_OBJECT (widget), "editable")) {
@@ -2730,7 +2730,7 @@ wbc_gtk_cell_selector_popup (G_GNUC_UNUSED GtkEntry *entry,
                        gtk_widget_show (item);
                }
 
-               gnumeric_popup_menu (GTK_MENU (menu), &event->button);
+               gnumeric_popup_menu (GTK_MENU (menu), event);
        }
 }
 
@@ -4168,7 +4168,7 @@ cb_tcm_hide (GtkWidget *widget, GtkWidget *box)
 }
 
 static void
-toolbar_context_menu (GtkToolbar *tb, WBCGtk *gtk, GdkEventButton *event_button)
+toolbar_context_menu (GtkToolbar *tb, WBCGtk *gtk, GdkEvent *event)
 {
        GtkWidget *box = gtk_widget_get_parent (GTK_WIDGET (tb));
        GtkWidget *zone = gtk_widget_get_parent (GTK_WIDGET (box));
@@ -4234,13 +4234,14 @@ toolbar_context_menu (GtkToolbar *tb, WBCGtk *gtk, GdkEventButton *event_button)
                          box);
 
        gtk_widget_show_all (menu);
-       gnumeric_popup_menu (GTK_MENU (menu), event_button);
+       gnumeric_popup_menu (GTK_MENU (menu), event);
 }
 
 static gboolean
-cb_toolbar_button_press (GtkToolbar *tb, GdkEventButton *event, WBCGtk *gtk)
+cb_toolbar_button_press (GtkToolbar *tb, GdkEvent *event, WBCGtk *gtk)
 {
-       if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
+       if (event->type == GDK_BUTTON_PRESS &&
+           event->button.button == 3) {
                toolbar_context_menu (tb, gtk, event);
                return TRUE;
        }
@@ -4249,9 +4250,10 @@ cb_toolbar_button_press (GtkToolbar *tb, GdkEventButton *event, WBCGtk *gtk)
 }
 
 static gboolean
-cb_handlebox_button_press (GtkHandleBox *hdlbox, GdkEventButton *event, WBCGtk *gtk)
+cb_handlebox_button_press (GtkHandleBox *hdlbox, GdkEvent *event, WBCGtk *gtk)
 {
-       if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
+       if (event->type == GDK_BUTTON_PRESS &&
+           event->button.button == 3) {
                GtkToolbar *tb = GTK_TOOLBAR (gtk_bin_get_child (GTK_BIN (hdlbox)));
                toolbar_context_menu (tb, gtk, event);
                return TRUE;
@@ -4640,7 +4642,7 @@ cb_auto_expr_insert_formula_to_side (G_GNUC_UNUSED GtkWidget *item, WBCGtk *wbcg
 
 
 static gboolean
-cb_select_auto_expr (GtkWidget *widget, GdkEventButton *event, WBCGtk *wbcg)
+cb_select_auto_expr (GtkWidget *widget, GdkEvent *event, WBCGtk *wbcg)
 {
        /*
         * WARNING * WARNING * WARNING
@@ -4676,7 +4678,7 @@ cb_select_auto_expr (GtkWidget *widget, GdkEventButton *event, WBCGtk *wbcg)
        GnmCellPos const *pos;
        GnmEvalPos ep;
 
-       if (event->button != 3)
+       if (event->button.button != 3)
                return FALSE;
 
        menu = gtk_menu_new ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]