1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-25 01:02:24 +00:00

Handle deprecation of gtk_menu_popup

GTK+ 3.22 deprecates gtk_menu_popup in favour of various
gtk_menu_popup_at_* functions.  gtk_menu_popup_at_pointer seems most
appropriate, but that requires being able to pass it a GdkEvent rather
than just some elements of it.  In order to achieve that, I've
rearranged the scroll_event shim to construct a real GdkEventButton and
pass that down to button_internal.
This commit is contained in:
Colin Watson 2017-03-05 21:41:21 +00:00 committed by Simon Tatham
parent 2d0b2e97d0
commit 64221972c0

View File

@ -1817,56 +1817,58 @@ gboolean scroll_internal(struct gui_data *inst, gdouble delta, guint state,
}
#endif
gboolean button_internal(struct gui_data *inst, guint32 timestamp,
GdkEventType type, guint ebutton, guint state,
gdouble ex, gdouble ey)
static gboolean button_internal(struct gui_data *inst, GdkEventButton *event)
{
int shift, ctrl, alt, x, y, button, act, raw_mouse_mode;
/* Remember the timestamp. */
inst->input_event_time = timestamp;
inst->input_event_time = event->time;
show_mouseptr(inst, 1);
shift = state & GDK_SHIFT_MASK;
ctrl = state & GDK_CONTROL_MASK;
alt = state & inst->meta_mod_mask;
shift = event->state & GDK_SHIFT_MASK;
ctrl = event->state & GDK_CONTROL_MASK;
alt = event->state & inst->meta_mod_mask;
raw_mouse_mode =
send_raw_mouse && !(shift && conf_get_int(inst->conf,
CONF_mouse_override));
if (!raw_mouse_mode) {
if (ebutton == 4 && type == GDK_BUTTON_PRESS) {
if (event->button == 4 && event->type == GDK_BUTTON_PRESS) {
term_scroll(inst->term, 0, -SCROLL_INCREMENT_LINES);
return TRUE;
}
if (ebutton == 5 && type == GDK_BUTTON_PRESS) {
if (event->button == 5 && event->type == GDK_BUTTON_PRESS) {
term_scroll(inst->term, 0, +SCROLL_INCREMENT_LINES);
return TRUE;
}
}
if (ebutton == 3 && ctrl) {
if (event->button == 3 && ctrl) {
#if GTK_CHECK_VERSION(3,22,0)
gtk_menu_popup_at_pointer(GTK_MENU(inst->menu), (GdkEvent *)event);
#else
gtk_menu_popup(GTK_MENU(inst->menu), NULL, NULL, NULL, NULL,
ebutton, timestamp);
event->button, event->time);
#endif
return TRUE;
}
if (ebutton == 1)
if (event->button == 1)
button = MBT_LEFT;
else if (ebutton == 2)
else if (event->button == 2)
button = MBT_MIDDLE;
else if (ebutton == 3)
else if (event->button == 3)
button = MBT_RIGHT;
else if (ebutton == 4)
else if (event->button == 4)
button = MBT_WHEEL_UP;
else if (ebutton == 5)
else if (event->button == 5)
button = MBT_WHEEL_DOWN;
else
return FALSE; /* don't even know what button! */
switch (type) {
switch (event->type) {
case GDK_BUTTON_PRESS: act = MA_CLICK; break;
case GDK_BUTTON_RELEASE: act = MA_RELEASE; break;
case GDK_2BUTTON_PRESS: act = MA_2CLK; break;
@ -1877,8 +1879,8 @@ gboolean button_internal(struct gui_data *inst, guint32 timestamp,
if (raw_mouse_mode && act != MA_CLICK && act != MA_RELEASE)
return TRUE; /* we ignore these in raw mouse mode */
x = (ex - inst->window_border) / inst->font_width;
y = (ey - inst->window_border) / inst->font_height;
x = (event->x - inst->window_border) / inst->font_width;
y = (event->y - inst->window_border) / inst->font_height;
term_mouse(inst->term, button, translate_button(button), act,
x, y, shift, ctrl, alt);
@ -1889,8 +1891,7 @@ gboolean button_internal(struct gui_data *inst, guint32 timestamp,
gboolean button_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
struct gui_data *inst = (struct gui_data *)data;
return button_internal(inst, event->time, event->type, event->button,
event->state, event->x, event->y);
return button_internal(inst, event);
}
#if GTK_CHECK_VERSION(2,0,0)
@ -1911,6 +1912,9 @@ gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer data)
return FALSE;
#else
guint button;
GdkEventButton *event_button;
gboolean ret;
if (event->direction == GDK_SCROLL_UP)
button = 4;
else if (event->direction == GDK_SCROLL_DOWN)
@ -1918,8 +1922,21 @@ gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer data)
else
return FALSE;
return button_internal(inst, event->time, GDK_BUTTON_PRESS,
button, event->state, event->x, event->y);
event_button = (GdkEventButton *)gdk_event_new(GDK_BUTTON_PRESS);
event_button->window = event->window;
event_button->send_event = event->send_event;
event_button->time = event->time;
event_button->x = event->x;
event_button->y = event->y;
event_button->axes = NULL;
event_button->state = event->state;
event_button->button = button;
event_button->device = event->device;
event_button->x_root = event->x_root;
event_button->y_root = event->y_root;
ret = button_internal(inst, event_button);
gdk_event_free(event_button);
return ret;
#endif
}
#endif