diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2012-11-30 02:12:41 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2012-11-30 02:24:24 +0800 |
commit | d2fb5ee1a86539e49f02c1fe9ea10cf55b0b351a (patch) | |
tree | 0a0da6f348d8c41ac3e7712a5c18abe78e23d891 /calendar | |
parent | 67024e23ee07266a7b9854648454739e1824f91c (diff) | |
download | gsoc2013-evolution-d2fb5ee1a86539e49f02c1fe9ea10cf55b0b351a.tar.gz gsoc2013-evolution-d2fb5ee1a86539e49f02c1fe9ea10cf55b0b351a.tar.zst gsoc2013-evolution-d2fb5ee1a86539e49f02c1fe9ea10cf55b0b351a.zip |
Avoid using GdkEventButton directly in certain places.
Prefer dealing with GdkEvent pointers and using accessor functions like
gdk_event_get_button().
This is complicated by the fact that some GtkWidget method declarations
still use GdkEventButton pointers, and synthesizing button events pretty
much requires direct GdkEventButton access. But GDK seems to be nudging
itself toward sealing the GdkEvent union. Likely to happen in GDK4.
Mainly clean up signal handlers and leave method overrides alone for now.
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/alarm-notify/alarm-queue.c | 8 | ||||
-rw-r--r-- | calendar/gui/e-cal-list-view.c | 7 | ||||
-rw-r--r-- | calendar/gui/e-calendar-view.c | 6 | ||||
-rw-r--r-- | calendar/gui/e-calendar-view.h | 4 | ||||
-rw-r--r-- | calendar/gui/e-day-view.c | 264 | ||||
-rw-r--r-- | calendar/gui/e-week-view-event-item.c | 24 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 128 | ||||
-rw-r--r-- | calendar/gui/e-week-view.h | 2 |
8 files changed, 295 insertions, 148 deletions
diff --git a/calendar/alarm-notify/alarm-queue.c b/calendar/alarm-notify/alarm-queue.c index f24a17b135..360a95edf2 100644 --- a/calendar/alarm-notify/alarm-queue.c +++ b/calendar/alarm-notify/alarm-queue.c @@ -1476,12 +1476,16 @@ open_alarm_dialog (TrayIconData *tray_data) static gint tray_icon_clicked_cb (GtkWidget *widget, - GdkEventButton *event, + GdkEvent *event, gpointer user_data) { if (event->type == GDK_BUTTON_PRESS) { + guint event_button = 0; + debug (("left click and %d alarms", g_list_length (tray_icons_list))); - if (event->button == 1 && g_list_length (tray_icons_list) > 0) { + + gdk_event_get_button (event, &event_button); + if (event_button == 1 && g_list_length (tray_icons_list) > 0) { GList *tmp; for (tmp = tray_icons_list; tmp; tmp = tmp->next) { open_alarm_dialog (tmp->data); diff --git a/calendar/gui/e-cal-list-view.c b/calendar/gui/e-cal-list-view.c index 6427002904..55280ce79c 100644 --- a/calendar/gui/e-cal-list-view.c +++ b/calendar/gui/e-cal-list-view.c @@ -68,7 +68,7 @@ static gboolean e_cal_list_view_get_visible_time_range (ECalendarView *cal_view static gboolean e_cal_list_view_popup_menu (GtkWidget *widget); static void e_cal_list_view_show_popup_menu (ECalListView *cal_list_view, gint row, - GdkEventButton *event); + GdkEvent *event); static gboolean e_cal_list_view_on_table_double_click (GtkWidget *table, gint row, gint col, GdkEvent *event, gpointer data); static gboolean e_cal_list_view_on_table_right_click (GtkWidget *table, gint row, gint col, @@ -359,7 +359,7 @@ e_cal_list_view_dispose (GObject *object) static void e_cal_list_view_show_popup_menu (ECalListView *cal_list_view, gint row, - GdkEventButton *event) + GdkEvent *event) { e_calendar_view_popup_event (E_CALENDAR_VIEW (cal_list_view), event); } @@ -398,7 +398,8 @@ e_cal_list_view_on_table_right_click (GtkWidget *table, { ECalListView *cal_list_view = E_CAL_LIST_VIEW (data); - e_cal_list_view_show_popup_menu (cal_list_view, row, (GdkEventButton *) event); + e_cal_list_view_show_popup_menu (cal_list_view, row, event); + return TRUE; } diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index 88f8abc86c..bbf890af59 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -998,12 +998,12 @@ calendar_view_selectable_init (ESelectableInterface *interface) void e_calendar_view_popup_event (ECalendarView *calendar_view, - GdkEventButton *event) + GdkEvent *button_event) { g_return_if_fail (E_IS_CALENDAR_VIEW (calendar_view)); - g_return_if_fail (event != NULL); + g_return_if_fail (button_event != NULL); - g_signal_emit (calendar_view, signals[POPUP_EVENT], 0, event); + g_signal_emit (calendar_view, signals[POPUP_EVENT], 0, button_event); } gboolean diff --git a/calendar/gui/e-calendar-view.h b/calendar/gui/e-calendar-view.h index ab4d4e3778..9ed1173533 100644 --- a/calendar/gui/e-calendar-view.h +++ b/calendar/gui/e-calendar-view.h @@ -133,7 +133,7 @@ struct _ECalendarViewClass { /* Notification signals */ void (*popup_event) (ECalendarView *cal_view, - GdkEventButton *event); + GdkEvent *button_event); void (*selection_changed) (ECalendarView *cal_view); void (*selected_time_changed)(ECalendarView *cal_view); void (*timezone_changed) (ECalendarView *cal_view, @@ -217,7 +217,7 @@ CompEditor * e_calendar_view_open_event_with_flags guint32 flags); void e_calendar_view_popup_event (ECalendarView *cal_view, - GdkEventButton *event); + GdkEvent *button_event); gboolean e_calendar_view_add_event (ECalendarView *cal_view, ECalClient *client, diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index 59d558078d..5c3b4f2202 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -175,20 +175,20 @@ static void e_day_view_on_canvas_realized (GtkWidget *widget, EDayView *day_view); static gboolean e_day_view_on_top_canvas_button_press (GtkWidget *widget, - GdkEventButton *event, + GdkEvent *button_event, EDayView *day_view); static gboolean e_day_view_on_top_canvas_button_release (GtkWidget *widget, - GdkEventButton *event, + GdkEvent *button_event, EDayView *day_view); static gboolean e_day_view_on_top_canvas_motion (GtkWidget *widget, GdkEventMotion *event, EDayView *day_view); static gboolean e_day_view_on_main_canvas_button_press (GtkWidget *widget, - GdkEventButton *event, + GdkEvent *button_event, EDayView *day_view); static gboolean e_day_view_on_main_canvas_button_release (GtkWidget *widget, - GdkEventButton *event, + GdkEvent *button_event, EDayView *day_view); static gboolean e_day_view_on_top_canvas_scroll (GtkWidget *widget, @@ -219,27 +219,27 @@ static void e_day_view_abort_resize (EDayView *day_view); static gboolean e_day_view_on_long_event_button_press (EDayView *day_view, gint event_num, - GdkEventButton *event, + GdkEvent *button_event, ECalendarViewPosition pos, gint event_x, gint event_y); static gboolean e_day_view_on_event_button_press (EDayView *day_view, gint day, gint event_num, - GdkEventButton *event, + GdkEvent *button_event, ECalendarViewPosition pos, gint event_x, gint event_y); static void e_day_view_on_long_event_click (EDayView *day_view, gint event_num, - GdkEventButton *bevent, + GdkEvent *button_event, ECalendarViewPosition pos, gint event_x, gint event_y); static void e_day_view_on_event_click (EDayView *day_view, gint day, gint event_num, - GdkEventButton *event, + GdkEvent *button_event, ECalendarViewPosition pos, gint event_x, gint event_y); @@ -247,11 +247,11 @@ static void e_day_view_on_event_double_click (EDayView *day_view, gint day, gint event_num); static void e_day_view_on_event_right_click (EDayView *day_view, - GdkEventButton *bevent, + GdkEvent *button_event, gint day, gint event_num); static void e_day_view_show_popup_menu (EDayView *day_view, - GdkEventButton *event, + GdkEvent *button_event, gint day, gint event_num); @@ -3098,17 +3098,24 @@ e_day_view_convert_time_to_position (EDayView *day_view, static gboolean e_day_view_on_top_canvas_button_press (GtkWidget *widget, - GdkEventButton *event, + GdkEvent *button_event, EDayView *day_view) { gint event_x, event_y, day, event_num; ECalendarViewPosition pos; GtkLayout *layout; GdkWindow *window; + GdkDevice *event_device; + guint event_button = 0; + guint32 event_time; layout = GTK_LAYOUT (widget); window = gtk_layout_get_bin_window (layout); + gdk_event_get_button (button_event, &event_button); + event_device = gdk_event_get_device (button_event); + event_time = gdk_event_get_time (button_event); + if (day_view->resize_event_num != -1) day_view->resize_event_num = -1; @@ -3118,7 +3125,7 @@ e_day_view_on_top_canvas_button_press (GtkWidget *widget, /* Convert the coords to the main canvas window, or return if the * window is not found. */ if (!e_day_view_convert_event_coords ( - day_view, (GdkEvent *) event, window, &event_x, &event_y)) + day_view, button_event, window, &event_x, &event_y)) return FALSE; pos = e_day_view_convert_position_in_top_canvas ( @@ -3133,14 +3140,17 @@ e_day_view_on_top_canvas_button_press (GtkWidget *widget, return e_day_view_on_long_event_button_press ( day_view, event_num, - event, pos, + button_event, + pos, event_x, event_y); e_day_view_stop_editing_event (day_view); - if (event->button == 1) { - if (event->type == GDK_2BUTTON_PRESS) { + if (event_button == 1) { + GdkGrabStatus grab_status; + + if (button_event->type == GDK_2BUTTON_PRESS) { time_t dtstart, dtend; e_day_view_get_selected_time_range ((ECalendarView *) day_view, &dtstart, &dtend); @@ -3150,25 +3160,36 @@ e_day_view_on_top_canvas_button_press (GtkWidget *widget, e_day_view_set_selected_time_range ((ECalendarView *) day_view, dtstart, dtend); } - e_calendar_view_new_appointment_for (E_CALENDAR_VIEW (day_view), - dtstart, dtend, - TRUE, calendar_config_get_prefer_meeting ()); + e_calendar_view_new_appointment_for ( + E_CALENDAR_VIEW (day_view), + dtstart, dtend, TRUE, + calendar_config_get_prefer_meeting ()); return TRUE; } if (!gtk_widget_has_focus (GTK_WIDGET (day_view))) gtk_widget_grab_focus (GTK_WIDGET (day_view)); - if (gdk_pointer_grab (window, FALSE, - GDK_POINTER_MOTION_MASK - | GDK_BUTTON_RELEASE_MASK, - NULL, NULL, event->time) == 0) { - if (event->time - day_view->bc_event_time > 250) - e_day_view_get_selected_time_range ((ECalendarView *) day_view, &day_view->before_click_dtstart, &day_view->before_click_dtend); - day_view->bc_event_time = event->time; + grab_status = gdk_device_grab ( + event_device, + window, + GDK_OWNERSHIP_NONE, + FALSE, + GDK_POINTER_MOTION_MASK | + GDK_BUTTON_RELEASE_MASK, + NULL, + event_time); + + if (grab_status == GDK_GRAB_SUCCESS) { + if (event_time - day_view->bc_event_time > 250) + e_day_view_get_selected_time_range ( + E_CALENDAR_VIEW (day_view), + &day_view->before_click_dtstart, + &day_view->before_click_dtend); + day_view->bc_event_time = event_time; e_day_view_start_selection (day_view, day, -1); } - } else if (event->button == 3) { + } else if (event_button == 3) { if (!gtk_widget_has_focus (GTK_WIDGET (day_view))) gtk_widget_grab_focus (GTK_WIDGET (day_view)); @@ -3177,7 +3198,7 @@ e_day_view_on_top_canvas_button_press (GtkWidget *widget, e_day_view_finish_selection (day_view); } - e_day_view_on_event_right_click (day_view, event, -1, -1); + e_day_view_on_event_right_click (day_view, button_event, -1, -1); } return TRUE; @@ -3235,17 +3256,24 @@ e_day_view_convert_event_coords (EDayView *day_view, static gboolean e_day_view_on_main_canvas_button_press (GtkWidget *widget, - GdkEventButton *event, + GdkEvent *button_event, EDayView *day_view) { gint event_x, event_y, row, day, event_num; ECalendarViewPosition pos; GtkLayout *layout; GdkWindow *window; + GdkDevice *event_device; + guint event_button = 0; + guint32 event_time; layout = GTK_LAYOUT (widget); window = gtk_layout_get_bin_window (layout); + gdk_event_get_button (button_event, &event_button); + event_device = gdk_event_get_device (button_event); + event_time = gdk_event_get_time (button_event); + if (day_view->resize_event_num != -1) day_view->resize_event_num = -1; @@ -3255,7 +3283,7 @@ e_day_view_on_main_canvas_button_press (GtkWidget *widget, /* Convert the coords to the main canvas window, or return if the * window is not found. */ if (!e_day_view_convert_event_coords ( - day_view, (GdkEvent *) event, window, &event_x, &event_y)) + day_view, button_event, window, &event_x, &event_y)) return FALSE; /* Find out where the mouse is. */ @@ -3270,15 +3298,21 @@ e_day_view_on_main_canvas_button_press (GtkWidget *widget, if (pos != E_CALENDAR_VIEW_POS_NONE) return e_day_view_on_event_button_press ( - day_view, day, - event_num, event, pos, - event_x, event_y); + day_view, + day, + event_num, + button_event, + pos, + event_x, + event_y); e_day_view_stop_editing_event (day_view); /* Start the selection drag. */ - if (event->button == 1) { - if (event->type == GDK_2BUTTON_PRESS) { + if (event_button == 1) { + GdkGrabStatus grab_status; + + if (button_event->type == GDK_2BUTTON_PRESS) { time_t dtstart, dtend; e_day_view_get_selected_time_range ((ECalendarView *) day_view, &dtstart, &dtend); @@ -3287,26 +3321,37 @@ e_day_view_on_main_canvas_button_press (GtkWidget *widget, dtend = day_view->before_click_dtend; e_day_view_set_selected_time_range ((ECalendarView *) day_view, dtstart, dtend); } - e_calendar_view_new_appointment_for (E_CALENDAR_VIEW (day_view), - dtstart, dtend, - FALSE, calendar_config_get_prefer_meeting ()); + e_calendar_view_new_appointment_for ( + E_CALENDAR_VIEW (day_view), + dtstart, dtend, FALSE, + calendar_config_get_prefer_meeting ()); return TRUE; } if (!gtk_widget_has_focus (GTK_WIDGET (day_view)) && !gtk_widget_has_focus (GTK_WIDGET (day_view->main_canvas))) gtk_widget_grab_focus (GTK_WIDGET (day_view)); - if (gdk_pointer_grab (window, FALSE, - GDK_POINTER_MOTION_MASK - | GDK_BUTTON_RELEASE_MASK, - NULL, NULL, event->time) == 0) { - if (event->time - day_view->bc_event_time > 250) - e_day_view_get_selected_time_range ((ECalendarView *) day_view, &day_view->before_click_dtstart, &day_view->before_click_dtend); - day_view->bc_event_time = event->time; + grab_status = gdk_device_grab ( + event_device, + window, + GDK_OWNERSHIP_NONE, + FALSE, + GDK_POINTER_MOTION_MASK | + GDK_BUTTON_RELEASE_MASK, + NULL, + event_time); + + if (grab_status == GDK_GRAB_SUCCESS) { + if (event_time - day_view->bc_event_time > 250) + e_day_view_get_selected_time_range ( + E_CALENDAR_VIEW (day_view), + &day_view->before_click_dtstart, + &day_view->before_click_dtend); + day_view->bc_event_time = event_time; e_day_view_start_selection (day_view, day, row); g_signal_emit_by_name (day_view, "selected_time_changed"); } - } else if (event->button == 3) { + } else if (event_button == 3) { if (!gtk_widget_has_focus (GTK_WIDGET (day_view))) gtk_widget_grab_focus (GTK_WIDGET (day_view)); @@ -3317,7 +3362,7 @@ e_day_view_on_main_canvas_button_press (GtkWidget *widget, e_day_view_finish_selection (day_view); } - e_day_view_on_event_right_click (day_view, event, -1, -1); + e_day_view_on_event_right_click (day_view, button_event, -1, -1); } return TRUE; @@ -3414,26 +3459,30 @@ e_day_view_on_time_canvas_scroll (GtkWidget *widget, static gboolean e_day_view_on_long_event_button_press (EDayView *day_view, gint event_num, - GdkEventButton *event, + GdkEvent *button_event, ECalendarViewPosition pos, gint event_x, gint event_y) { - if (event->button == 1) { - if (event->type == GDK_BUTTON_PRESS) { + guint event_button = 0; + + gdk_event_get_button (button_event, &event_button); + + if (event_button == 1) { + if (button_event->type == GDK_BUTTON_PRESS) { e_day_view_on_long_event_click ( day_view, event_num, - event, pos, + button_event, pos, event_x, event_y); return TRUE; - } else if (event->type == GDK_2BUTTON_PRESS) { + } else if (button_event->type == GDK_2BUTTON_PRESS) { e_day_view_on_event_double_click ( day_view, -1, event_num); g_signal_stop_emission_by_name (day_view->top_canvas, "button_press_event"); return TRUE; } - } else if (event->button == 3) { + } else if (event_button == 3) { EDayViewEvent *e; if (!is_array_index_in_bounds (day_view->long_events, event_num)) @@ -3444,7 +3493,7 @@ e_day_view_on_long_event_button_press (EDayView *day_view, e_day_view_set_selected_time_range_in_top_visible (day_view, e->start, e->end); e_day_view_on_event_right_click ( - day_view, event, + day_view, button_event, E_DAY_VIEW_LONG_EVENT, event_num); @@ -3457,19 +3506,23 @@ static gboolean e_day_view_on_event_button_press (EDayView *day_view, gint day, gint event_num, - GdkEventButton *event, + GdkEvent *button_event, ECalendarViewPosition pos, gint event_x, gint event_y) { - if (event->button == 1) { - if (event->type == GDK_BUTTON_PRESS) { + guint event_button = 0; + + gdk_event_get_button (button_event, &event_button); + + if (event_button == 1) { + if (button_event->type == GDK_BUTTON_PRESS) { e_day_view_on_event_click ( day_view, day, event_num, - event, pos, + button_event, pos, event_x, event_y); return TRUE; - } else if (event->type == GDK_2BUTTON_PRESS) { + } else if (button_event->type == GDK_2BUTTON_PRESS) { e_day_view_on_event_double_click ( day_view, day, event_num); @@ -3477,7 +3530,7 @@ e_day_view_on_event_button_press (EDayView *day_view, g_signal_stop_emission_by_name (day_view->main_canvas, "button_press_event"); return TRUE; } - } else if (event->button == 3) { + } else if (event_button == 3) { EDayViewEvent *e; if (!is_array_index_in_bounds (day_view->events[day], event_num)) @@ -3488,8 +3541,7 @@ e_day_view_on_event_button_press (EDayView *day_view, e_day_view_set_selected_time_range_visible (day_view, e->start, e->end); e_day_view_on_event_right_click ( - day_view, event, - day, event_num); + day_view, button_event, day, event_num); return TRUE; } @@ -3499,7 +3551,7 @@ e_day_view_on_event_button_press (EDayView *day_view, static void e_day_view_on_long_event_click (EDayView *day_view, gint event_num, - GdkEventButton *bevent, + GdkEvent *button_event, ECalendarViewPosition pos, gint event_x, gint event_y) @@ -3522,7 +3574,8 @@ e_day_view_on_long_event_click (EDayView *day_view, /* Ignore clicks on the EText while editing. */ if (pos == E_CALENDAR_VIEW_POS_EVENT && E_TEXT (event->canvas_item)->editing) { - GNOME_CANVAS_ITEM_GET_CLASS (event->canvas_item)->event (event->canvas_item, (GdkEvent *) bevent); + GNOME_CANVAS_ITEM_GET_CLASS (event->canvas_item)->event ( + event->canvas_item, button_event); return; } @@ -3530,6 +3583,10 @@ e_day_view_on_long_event_click (EDayView *day_view, !e_cal_util_component_has_recurrences (event->comp_data->icalcomp)) && (pos == E_CALENDAR_VIEW_POS_LEFT_EDGE || pos == E_CALENDAR_VIEW_POS_RIGHT_EDGE)) { + GdkGrabStatus grab_status; + GdkDevice *event_device; + guint32 event_time; + if (!e_day_view_find_long_event_days (event, day_view->days_shown, day_view->day_starts, @@ -3544,11 +3601,20 @@ e_day_view_on_long_event_click (EDayView *day_view, layout = GTK_LAYOUT (day_view->top_canvas); window = gtk_layout_get_bin_window (layout); - if (gdk_pointer_grab (window, FALSE, - GDK_POINTER_MOTION_MASK - | GDK_BUTTON_RELEASE_MASK, - NULL, NULL, bevent->time) == 0) { + event_device = gdk_event_get_device (button_event); + event_time = gdk_event_get_time (button_event); + + grab_status = gdk_device_grab ( + event_device, + window, + GDK_OWNERSHIP_NONE, + FALSE, + GDK_POINTER_MOTION_MASK | + GDK_BUTTON_RELEASE_MASK, + NULL, + event_time); + if (grab_status == GDK_GRAB_SUCCESS) { day_view->resize_event_day = E_DAY_VIEW_LONG_EVENT; day_view->resize_event_num = event_num; day_view->resize_drag_pos = pos; @@ -3582,7 +3648,7 @@ static void e_day_view_on_event_click (EDayView *day_view, gint day, gint event_num, - GdkEventButton *bevent, + GdkEvent *button_event, ECalendarViewPosition pos, gint event_x, gint event_y) @@ -3609,7 +3675,8 @@ e_day_view_on_event_click (EDayView *day_view, /* Ignore clicks on the EText while editing. */ if (pos == E_CALENDAR_VIEW_POS_EVENT && E_TEXT (event->canvas_item)->editing) { - GNOME_CANVAS_ITEM_GET_CLASS (event->canvas_item)->event (event->canvas_item, (GdkEvent *) bevent); + GNOME_CANVAS_ITEM_GET_CLASS (event->canvas_item)->event ( + event->canvas_item, button_event); return; } @@ -3617,6 +3684,10 @@ e_day_view_on_event_click (EDayView *day_view, !e_cal_util_component_has_recurrences (event->comp_data->icalcomp)) && (pos == E_CALENDAR_VIEW_POS_TOP_EDGE || pos == E_CALENDAR_VIEW_POS_BOTTOM_EDGE)) { + GdkGrabStatus grab_status; + GdkDevice *event_device; + guint32 event_time; + if (event && (!event->is_editable || e_client_is_readonly (E_CLIENT (event->comp_data->client)))) { return; } @@ -3629,11 +3700,20 @@ e_day_view_on_event_click (EDayView *day_view, layout = GTK_LAYOUT (day_view->main_canvas); window = gtk_layout_get_bin_window (layout); - if (gdk_pointer_grab (window, FALSE, - GDK_POINTER_MOTION_MASK - | GDK_BUTTON_RELEASE_MASK, - NULL, NULL, bevent->time) == 0) { + event_device = gdk_event_get_device (button_event); + event_time = gdk_event_get_time (button_event); + + grab_status = gdk_device_grab ( + event_device, + window, + GDK_OWNERSHIP_NONE, + FALSE, + GDK_POINTER_MOTION_MASK | + GDK_BUTTON_RELEASE_MASK, + NULL, + event_time); + if (grab_status != GDK_GRAB_SUCCESS) { day_view->resize_event_day = day; day_view->resize_event_num = event_num; day_view->resize_drag_pos = pos; @@ -3699,7 +3779,7 @@ e_day_view_on_event_double_click (EDayView *day_view, static void e_day_view_show_popup_menu (EDayView *day_view, - GdkEventButton *event, + GdkEvent *button_event, gint day, gint event_num) { @@ -3708,7 +3788,7 @@ e_day_view_show_popup_menu (EDayView *day_view, day_view->popup_event_day = day; day_view->popup_event_num = event_num; - e_calendar_view_popup_event (E_CALENDAR_VIEW (day_view), event); + e_calendar_view_popup_event (E_CALENDAR_VIEW (day_view), button_event); } static gboolean @@ -3806,23 +3886,29 @@ e_day_view_update_query (EDayView *day_view) static void e_day_view_on_event_right_click (EDayView *day_view, - GdkEventButton *bevent, + GdkEvent *button_event, gint day, gint event_num) { - e_day_view_show_popup_menu (day_view, bevent, day, event_num); + e_day_view_show_popup_menu (day_view, button_event, day, event_num); } static gboolean e_day_view_on_top_canvas_button_release (GtkWidget *widget, - GdkEventButton *event, + GdkEvent *button_event, EDayView *day_view) { + GdkDevice *event_device; + guint32 event_time; + + event_device = gdk_event_get_device (button_event); + event_time = gdk_event_get_time (button_event); + if (day_view->selection_is_being_dragged) { - gdk_pointer_ungrab (event->time); + gdk_device_ungrab (event_device, event_time); e_day_view_finish_selection (day_view); } else if (day_view->resize_drag_pos != E_CALENDAR_VIEW_POS_NONE) { - gdk_pointer_ungrab (event->time); + gdk_device_ungrab (event_device, event_time); e_day_view_finish_long_event_resize (day_view); } else if (day_view->pressed_event_day != -1) { e_day_view_start_editing_event ( @@ -3839,23 +3925,29 @@ e_day_view_on_top_canvas_button_release (GtkWidget *widget, static gboolean e_day_view_on_main_canvas_button_release (GtkWidget *widget, - GdkEventButton *event, + GdkEvent *button_event, EDayView *day_view) { + GdkDevice *event_device; + guint32 event_time; + + event_device = gdk_event_get_device (button_event); + event_time = gdk_event_get_time (button_event); + if (day_view->selection_is_being_dragged) { - gdk_pointer_ungrab (event->time); + gdk_device_ungrab (event_device, event_time); e_day_view_finish_selection (day_view); e_day_view_stop_auto_scroll (day_view); } else if (day_view->resize_drag_pos != E_CALENDAR_VIEW_POS_NONE) { - gdk_pointer_ungrab (event->time); + gdk_device_ungrab (event_device, event_time); e_day_view_finish_resize (day_view); e_day_view_stop_auto_scroll (day_view); } else if (day_view->pressed_event_day != -1) { e_day_view_start_editing_event ( day_view, - day_view->pressed_event_day, - day_view->pressed_event_num, - NULL); + day_view->pressed_event_day, + day_view->pressed_event_num, + NULL); } day_view->pressed_event_day = -1; diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c index 6cd4a9048a..f517159e1b 100644 --- a/calendar/gui/e-week-view-event-item.c +++ b/calendar/gui/e-week-view-event-item.c @@ -120,7 +120,7 @@ week_view_event_item_get_position (EWeekViewEventItem *event_item, static gboolean week_view_event_item_double_click (EWeekViewEventItem *event_item, - GdkEvent *bevent) + GdkEvent *button_event) { EWeekView *week_view; EWeekViewEvent *event; @@ -179,7 +179,7 @@ week_view_event_item_double_click (EWeekViewEventItem *event_item, static gboolean week_view_event_item_button_press (EWeekViewEventItem *event_item, - GdkEvent *bevent) + GdkEvent *button_event) { EWeekView *week_view; ECalendarViewPosition pos; @@ -187,6 +187,12 @@ week_view_event_item_button_press (EWeekViewEventItem *event_item, EWeekViewEventSpan *span; GnomeCanvasItem *item; GtkWidget *parent; + guint event_button = 0; + gdouble event_x_win = 0; + gdouble event_y_win = 0; + + gdk_event_get_button (button_event, &event_button); + gdk_event_get_coords (button_event, &event_x_win, &event_y_win); item = GNOME_CANVAS_ITEM (event_item); @@ -211,12 +217,11 @@ week_view_event_item_button_press (EWeekViewEventItem *event_item, event->spans_index + event_item->priv->span_num); pos = week_view_event_item_get_position ( - event_item, bevent->button.x, - bevent->button.y); + event_item, event_x_win, event_y_win); if (pos == E_CALENDAR_VIEW_POS_NONE) return FALSE; - if (bevent->button.button == 1) { + if (event_button == 1) { week_view->pressed_event_num = event_item->priv->event_num; week_view->pressed_span_num = event_item->priv->span_num; @@ -226,14 +231,15 @@ week_view_event_item_button_press (EWeekViewEventItem *event_item, /* Remember the item clicked and the mouse position, * so we can start a drag if the mouse moves. */ - week_view->drag_event_x = bevent->button.x; - week_view->drag_event_y = bevent->button.y; + week_view->drag_event_x = event_x_win; + week_view->drag_event_y = event_y_win; /* FIXME: Remember the day offset from the start of the event. */ return TRUE; - } else if (bevent->button.button == 3) { + + } else if (event_button == 3) { if (!gtk_widget_has_focus (GTK_WIDGET (week_view))) { gtk_widget_grab_focus (GTK_WIDGET (week_view)); if (week_view->event_destroyed) { @@ -247,7 +253,7 @@ week_view_event_item_button_press (EWeekViewEventItem *event_item, week_view, event->start, event->end); e_week_view_show_popup_menu ( - week_view, (GdkEventButton *) bevent, + week_view, button_event, event_item->priv->event_num); g_signal_stop_emission_by_name ( item->canvas, "button_press_event"); diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index 574b79efab..83c41499cf 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -112,10 +112,10 @@ static void e_week_view_paste_text (ECalendarView *week_view); static void e_week_view_update_query (EWeekView *week_view); static gboolean e_week_view_on_button_press (GtkWidget *widget, - GdkEventButton *event, + GdkEvent *button_event, EWeekView *week_view); static gboolean e_week_view_on_button_release (GtkWidget *widget, - GdkEventButton *event, + GdkEvent *button_event, EWeekView *week_view); static gboolean e_week_view_on_scroll (GtkWidget *widget, GdkEventScroll *scroll, @@ -2416,26 +2416,32 @@ ewv_pass_gdkevent_to_etext (EWeekView *week_view, static gboolean e_week_view_on_button_press (GtkWidget *widget, - GdkEventButton *event, + GdkEvent *button_event, EWeekView *week_view) { + guint event_button = 0; + gdouble event_x_win = 0; + gdouble event_y_win = 0; gint x, y, day; + gdk_event_get_button (button_event, &event_button); + gdk_event_get_coords (button_event, &event_x_win, &event_y_win); + /* Convert the mouse position to a week & day. */ - x = event->x; - y = event->y; + x = (gint) event_x_win; + y = (gint) event_y_win; day = e_week_view_convert_position_to_day (week_view, x, y); if (day == -1) return FALSE; - if (ewv_pass_gdkevent_to_etext (week_view, (GdkEvent *) event)) + if (ewv_pass_gdkevent_to_etext (week_view, button_event)) return TRUE; /* If an event is pressed just return. */ if (week_view->pressed_event_num != -1) return FALSE; - if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { + if (event_button == 1 && button_event->type == GDK_2BUTTON_PRESS) { time_t dtstart, dtend; e_calendar_view_get_selected_time_range ((ECalendarView *) week_view, &dtstart, &dtend); @@ -2446,8 +2452,11 @@ e_week_view_on_button_press (GtkWidget *widget, return TRUE; } - if (event->button == 1) { + if (event_button == 1) { + GdkGrabStatus grab_status; GdkWindow *window; + GdkDevice *event_device; + guint32 event_time; /* Start the selection drag. */ if (!gtk_widget_has_focus (GTK_WIDGET (week_view)) && !gtk_widget_has_focus (GTK_WIDGET (week_view->main_canvas))) @@ -2455,13 +2464,26 @@ e_week_view_on_button_press (GtkWidget *widget, window = gtk_layout_get_bin_window (GTK_LAYOUT (widget)); - if (gdk_pointer_grab (window, FALSE, - GDK_POINTER_MOTION_MASK - | GDK_BUTTON_RELEASE_MASK, - NULL, NULL, event->time) == 0) { - if (event->time - week_view->bc_event_time > 250) - e_calendar_view_get_selected_time_range ((ECalendarView *) week_view, &week_view->before_click_dtstart, &week_view->before_click_dtend); - week_view->bc_event_time = event->time; + event_device = gdk_event_get_device (button_event); + event_time = gdk_event_get_time (button_event); + + grab_status = gdk_device_grab ( + event_device, + window, + GDK_OWNERSHIP_NONE, + FALSE, + GDK_POINTER_MOTION_MASK | + GDK_BUTTON_RELEASE_MASK, + NULL, + event_time); + + if (grab_status == GDK_GRAB_SUCCESS) { + if (event_time - week_view->bc_event_time > 250) + e_calendar_view_get_selected_time_range ( + E_CALENDAR_VIEW (week_view), + &week_view->before_click_dtstart, + &week_view->before_click_dtend); + week_view->bc_event_time = event_time; week_view->selection_start_day = day; week_view->selection_end_day = day; week_view->selection_drag_pos = E_WEEK_VIEW_DRAG_END; @@ -2470,7 +2492,7 @@ e_week_view_on_button_press (GtkWidget *widget, /* FIXME: Optimise? */ gtk_widget_queue_draw (week_view->main_canvas); } - } else if (event->button == 3) { + } else if (event_button == 3) { if (!gtk_widget_has_focus (GTK_WIDGET (week_view))) gtk_widget_grab_focus (GTK_WIDGET (week_view)); @@ -2483,7 +2505,7 @@ e_week_view_on_button_press (GtkWidget *widget, gtk_widget_queue_draw (week_view->main_canvas); } - e_week_view_show_popup_menu (week_view, event, -1); + e_week_view_show_popup_menu (week_view, button_event, -1); } return TRUE; @@ -2491,14 +2513,20 @@ e_week_view_on_button_press (GtkWidget *widget, static gboolean e_week_view_on_button_release (GtkWidget *widget, - GdkEventButton *event, + GdkEvent *button_event, EWeekView *week_view) { + GdkDevice *event_device; + guint32 event_time; + + event_device = gdk_event_get_device (button_event); + event_time = gdk_event_get_time (button_event); + if (week_view->selection_drag_pos != E_WEEK_VIEW_DRAG_NONE) { week_view->selection_drag_pos = E_WEEK_VIEW_DRAG_NONE; - gdk_pointer_ungrab (event->time); + gdk_device_ungrab (event_device, event_time); } else { - ewv_pass_gdkevent_to_etext (week_view, (GdkEvent *) event); + ewv_pass_gdkevent_to_etext (week_view, button_event); } return FALSE; @@ -3530,20 +3558,26 @@ cancel_editing (EWeekView *week_view) static gboolean e_week_view_on_text_item_event (GnomeCanvasItem *item, - GdkEvent *gdkevent, + GdkEvent *gdk_event, EWeekView *week_view) { EWeekViewEvent *event; gint event_num, span_num; gint nevent = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "event-num")); EWeekViewEvent *pevent; + guint event_button = 0; + guint event_keyval = 0; + gdouble event_x_root = 0; + gdouble event_y_root = 0; pevent = tooltip_get_view_event (week_view, -1, nevent); - switch (gdkevent->type) { + switch (gdk_event->type) { case GDK_KEY_PRESS: tooltip_destroy (week_view, item); - if (!E_TEXT (item)->preedit_len && gdkevent && gdkevent->key.keyval == GDK_KEY_Return) { + gdk_event_get_keyval (gdk_event, &event_keyval); + + if (!E_TEXT (item)->preedit_len && event_keyval == GDK_KEY_Return) { /* We set the keyboard focus to the EDayView, so the * EText item loses it and stops the edit. */ gtk_widget_grab_focus (GTK_WIDGET (week_view)); @@ -3552,7 +3586,7 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item, * other events getting to the EText item. */ g_signal_stop_emission_by_name (item, "event"); return TRUE; - } else if (gdkevent->key.keyval == GDK_KEY_Escape) { + } else if (event_keyval == GDK_KEY_Escape) { cancel_editing (week_view); g_signal_stop_emission_by_name (item, "event"); /* focus should go to week view when stop editing */ @@ -3592,7 +3626,8 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item, &event_num, &span_num)) return FALSE; - if (gdkevent->button.button == 3) { + gdk_event_get_button (gdk_event, &event_button); + if (event_button == 3) { EWeekViewEvent *e; if (E_TEXT (item)->editing) { @@ -3612,29 +3647,30 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item, e_week_view_set_selected_time_range_visible (week_view, e->start, e->end); e_week_view_show_popup_menu ( - week_view, - (GdkEventButton *) gdkevent, - event_num); + week_view, gdk_event, event_num); g_signal_stop_emission_by_name ( item->canvas, "button_press_event"); return TRUE; } - if (gdkevent->button.button != 3) { + if (event_button != 3) { week_view->pressed_event_num = event_num; week_view->pressed_span_num = span_num; } /* Only let the EText handle the event while editing. */ if (!E_TEXT (item)->editing) { + gdouble event_x_win = 0; + gdouble event_y_win = 0; + g_signal_stop_emission_by_name (item, "event"); - if (gdkevent) { - week_view->drag_event_x = gdkevent->button.x; - week_view->drag_event_y = gdkevent->button.y; - } else - g_warning ("No GdkEvent"); + gdk_event_get_coords ( + gdk_event, &event_x_win, &event_y_win); + + week_view->drag_event_x = (gint) event_x_win; + week_view->drag_event_y = (gint) event_y_win; /* FIXME: Remember the day offset from the start of * the event, for DnD. */ @@ -3684,8 +3720,11 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item, data = g_malloc (sizeof (ECalendarViewEventData)); - pevent->x = ((GdkEventCrossing *) gdkevent)->x_root; - pevent->y = ((GdkEventCrossing *) gdkevent)->y_root; + gdk_event_get_root_coords ( + gdk_event, &event_x_root, &event_y_root); + + pevent->x = (gint) event_x_root; + pevent->y = (gint) event_y_root; pevent->tooltip = NULL; data->cal_view = (ECalendarView *) week_view; @@ -3705,8 +3744,11 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item, return FALSE; case GDK_MOTION_NOTIFY: - pevent->x = ((GdkEventMotion *) gdkevent)->x_root; - pevent->y = ((GdkEventMotion *) gdkevent)->y_root; + gdk_event_get_root_coords ( + gdk_event, &event_x_root, &event_y_root); + + pevent->x = (gint) event_x_root; + pevent->y = (gint) event_y_root; pevent->tooltip = (GtkWidget *) g_object_get_data (G_OBJECT (week_view), "tooltip-window"); if (pevent->tooltip) { @@ -3714,7 +3756,7 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item, } return TRUE; case GDK_FOCUS_CHANGE: - if (gdkevent->focus_change.in) { + if (gdk_event->focus_change.in) { e_week_view_on_editing_started (week_view, item); } else { e_week_view_on_editing_stopped (week_view, item); @@ -3728,7 +3770,9 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item, return FALSE; } -static gboolean e_week_view_event_move (ECalendarView *cal_view, ECalViewMoveDirection direction) +static gboolean +e_week_view_event_move (ECalendarView *cal_view, + ECalViewMoveDirection direction) { EWeekViewEvent *event; gint event_num, adjust_days, current_start_day, current_end_day; @@ -4584,12 +4628,12 @@ e_week_view_key_press (GtkWidget *widget, void e_week_view_show_popup_menu (EWeekView *week_view, - GdkEventButton *bevent, + GdkEvent *button_event, gint event_num) { week_view->popup_event_num = event_num; - e_calendar_view_popup_event (E_CALENDAR_VIEW (week_view), bevent); + e_calendar_view_popup_event (E_CALENDAR_VIEW (week_view), button_event); } static gboolean diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h index 5a1f2e6d22..bb84e2b8f6 100644 --- a/calendar/gui/e-week-view.h +++ b/calendar/gui/e-week-view.h @@ -438,7 +438,7 @@ gboolean e_week_view_start_editing_event (EWeekView *week_view, void e_week_view_stop_editing_event (EWeekView *week_view); void e_week_view_show_popup_menu (EWeekView *week_view, - GdkEventButton *event, + GdkEvent *button_event, gint event_num); void e_week_view_convert_time_to_display |