aboutsummaryrefslogtreecommitdiff
path: root/ui/gtk.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui/gtk.c')
-rw-r--r--ui/gtk.c192
1 files changed, 14 insertions, 178 deletions
diff --git a/ui/gtk.c b/ui/gtk.c
index 3ddb5fe162..de8efadec3 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -111,49 +111,6 @@
# define VTE_CHECK_VERSION(a, b, c) 0
#endif
-#if defined(CONFIG_VTE) && !GTK_CHECK_VERSION(3, 0, 0)
-/*
- * The gtk2 vte terminal widget seriously messes up the window resize
- * for some reason. You basically can't make the qemu window smaller
- * any more because the toplevel window geoemtry hints are overridden.
- *
- * Workaround that by hiding all vte widgets, except the one in the
- * current tab.
- *
- * Luckily everything works smooth in gtk3.
- */
-# define VTE_RESIZE_HACK 1
-#endif
-
-#if !GTK_CHECK_VERSION(2, 20, 0)
-#define gtk_widget_get_realized(widget) GTK_WIDGET_REALIZED(widget)
-#endif
-
-#ifndef GDK_IS_X11_DISPLAY
-#define GDK_IS_X11_DISPLAY(dpy) (dpy == dpy)
-#endif
-#ifndef GDK_IS_WAYLAND_DISPLAY
-#define GDK_IS_WAYLAND_DISPLAY(dpy) (dpy == dpy)
-#endif
-#ifndef GDK_IS_WIN32_DISPLAY
-#define GDK_IS_WIN32_DISPLAY(dpy) (dpy == dpy)
-#endif
-
-#if !GTK_CHECK_VERSION(2, 22, 0)
-#define GDK_KEY_0 GDK_0
-#define GDK_KEY_1 GDK_1
-#define GDK_KEY_2 GDK_2
-#define GDK_KEY_f GDK_f
-#define GDK_KEY_g GDK_g
-#define GDK_KEY_m GDK_m
-#define GDK_KEY_q GDK_q
-#define GDK_KEY_plus GDK_plus
-#define GDK_KEY_equal GDK_equal
-#define GDK_KEY_minus GDK_minus
-#define GDK_KEY_Pause GDK_Pause
-#define GDK_KEY_Delete GDK_Delete
-#endif
-
/* Some older mingw versions lack this constant or have
* it conditionally defined */
#ifdef _WIN32
@@ -455,7 +412,8 @@ static void gd_update_full_redraw(VirtualConsole *vc)
{
GtkWidget *area = vc->gfx.drawing_area;
int ww, wh;
- gdk_drawable_get_size(gtk_widget_get_window(area), &ww, &wh);
+ ww = gdk_window_get_width(gtk_widget_get_window(area));
+ wh = gdk_window_get_height(gtk_widget_get_window(area));
#if defined(CONFIG_GTK_GL)
if (vc->gfx.gls && gtk_use_gl_area) {
gtk_gl_area_queue_render(GTK_GL_AREA(vc->gfx.drawing_area));
@@ -530,7 +488,8 @@ static void gd_update(DisplayChangeListener *dcl,
if (!win) {
return;
}
- gdk_drawable_get_size(win, &ww, &wh);
+ ww = gdk_window_get_width(win);
+ wh = gdk_window_get_height(win);
mx = my = 0;
if (ww > fbw) {
@@ -549,7 +508,6 @@ static void gd_refresh(DisplayChangeListener *dcl)
graphic_hw_update(dcl->con);
}
-#if GTK_CHECK_VERSION(3, 0, 0)
static GdkDevice *gd_get_pointer(GdkDisplay *dpy)
{
#if GTK_CHECK_VERSION(3, 20, 0)
@@ -580,24 +538,6 @@ static void gd_mouse_set(DisplayChangeListener *dcl,
vc->s->last_x = x;
vc->s->last_y = y;
}
-#else
-static void gd_mouse_set(DisplayChangeListener *dcl,
- int x, int y, int visible)
-{
- VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
- gint x_root, y_root;
-
- if (qemu_input_is_absolute()) {
- return;
- }
-
- gdk_window_get_root_coords(gtk_widget_get_window(vc->gfx.drawing_area),
- x, y, &x_root, &y_root);
- gdk_display_warp_pointer(gtk_widget_get_display(vc->gfx.drawing_area),
- gtk_widget_get_screen(vc->gfx.drawing_area),
- x_root, y_root);
-}
-#endif
static void gd_cursor_define(DisplayChangeListener *dcl,
QEMUCursor *c)
@@ -619,11 +559,7 @@ static void gd_cursor_define(DisplayChangeListener *dcl,
pixbuf, c->hot_x, c->hot_y);
gdk_window_set_cursor(gtk_widget_get_window(vc->gfx.drawing_area), cursor);
g_object_unref(pixbuf);
-#if !GTK_CHECK_VERSION(3, 0, 0)
- gdk_cursor_unref(cursor);
-#else
g_object_unref(cursor);
-#endif
}
static void gd_switch(DisplayChangeListener *dcl,
@@ -863,7 +799,8 @@ static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque)
fbw = surface_width(vc->gfx.ds);
fbh = surface_height(vc->gfx.ds);
- gdk_drawable_get_size(gtk_widget_get_window(widget), &ww, &wh);
+ ww = gdk_window_get_width(gtk_widget_get_window(widget));
+ wh = gdk_window_get_height(gtk_widget_get_window(widget));
if (s->full_screen) {
vc->gfx.scale_x = (double)ww / fbw;
@@ -907,29 +844,6 @@ static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque)
return TRUE;
}
-#if !GTK_CHECK_VERSION(3, 0, 0)
-static gboolean gd_expose_event(GtkWidget *widget, GdkEventExpose *expose,
- void *opaque)
-{
- cairo_t *cr;
- gboolean ret;
-
- cr = gdk_cairo_create(gtk_widget_get_window(widget));
- cairo_rectangle(cr,
- expose->area.x,
- expose->area.y,
- expose->area.width,
- expose->area.height);
- cairo_clip(cr);
-
- ret = gd_draw_event(widget, cr, opaque);
-
- cairo_destroy(cr);
-
- return ret;
-}
-#endif
-
static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
void *opaque)
{
@@ -947,8 +861,8 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
fbw = surface_width(vc->gfx.ds) * vc->gfx.scale_x;
fbh = surface_height(vc->gfx.ds) * vc->gfx.scale_y;
- gdk_drawable_get_size(gtk_widget_get_window(vc->gfx.drawing_area),
- &ww, &wh);
+ ww = gdk_window_get_width(gtk_widget_get_window(vc->gfx.drawing_area));
+ wh = gdk_window_get_height(gtk_widget_get_window(vc->gfx.drawing_area));
mx = my = 0;
if (ww > fbw) {
@@ -1026,13 +940,8 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
}
if (x != (int)motion->x_root || y != (int)motion->y_root) {
-#if GTK_CHECK_VERSION(3, 0, 0)
GdkDevice *dev = gdk_event_get_device((GdkEvent *)motion);
gdk_device_warp(dev, screen, x, y);
-#else
- GdkDisplay *display = gtk_widget_get_display(widget);
- gdk_display_warp_pointer(display, screen, x, y);
-#endif
s->last_set = FALSE;
return FALSE;
}
@@ -1309,10 +1218,6 @@ static void gd_accel_switch_vc(void *opaque)
VirtualConsole *vc = opaque;
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(vc->menu_item), TRUE);
-#if !GTK_CHECK_VERSION(3, 0, 0)
- /* GTK2 sends the accel key to the target console - ignore this until */
- vc->s->ignore_keys = true;
-#endif
}
static void gd_menu_show_tabs(GtkMenuItem *item, void *opaque)
@@ -1539,7 +1444,7 @@ static void gd_grab_update(VirtualConsole *vc, bool kbd, bool ptr)
gdk_seat_ungrab(seat);
}
}
-#elif GTK_CHECK_VERSION(3, 0, 0)
+#else
static void gd_grab_devices(VirtualConsole *vc, bool grab,
GdkInputSource source, GdkEventMask mask,
GdkCursor *cursor)
@@ -1578,14 +1483,10 @@ static void gd_grab_keyboard(VirtualConsole *vc, const char *reason)
#if GTK_CHECK_VERSION(3, 20, 0)
gd_grab_update(vc, true, vc->s->ptr_owner == vc);
-#elif GTK_CHECK_VERSION(3, 0, 0)
+#else
gd_grab_devices(vc, true, GDK_SOURCE_KEYBOARD,
GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
NULL);
-#else
- gdk_keyboard_grab(gtk_widget_get_window(vc->gfx.drawing_area),
- FALSE,
- GDK_CURRENT_TIME);
#endif
vc->s->kbd_owner = vc;
gd_update_caption(vc->s);
@@ -1603,10 +1504,8 @@ static void gd_ungrab_keyboard(GtkDisplayState *s)
#if GTK_CHECK_VERSION(3, 20, 0)
gd_grab_update(vc, false, vc->s->ptr_owner == vc);
-#elif GTK_CHECK_VERSION(3, 0, 0)
- gd_grab_devices(vc, false, GDK_SOURCE_KEYBOARD, 0, NULL);
#else
- gdk_keyboard_ungrab(GDK_CURRENT_TIME);
+ gd_grab_devices(vc, false, GDK_SOURCE_KEYBOARD, 0, NULL);
#endif
gd_update_caption(s);
trace_gd_ungrab(vc->label, "kbd");
@@ -1628,7 +1527,7 @@ static void gd_grab_pointer(VirtualConsole *vc, const char *reason)
gd_grab_update(vc, vc->s->kbd_owner == vc, true);
gdk_device_get_position(gd_get_pointer(display),
NULL, &vc->s->grab_x_root, &vc->s->grab_y_root);
-#elif GTK_CHECK_VERSION(3, 0, 0)
+#else
gd_grab_devices(vc, true, GDK_SOURCE_MOUSE,
GDK_POINTER_MOTION_MASK |
GDK_BUTTON_PRESS_MASK |
@@ -1638,19 +1537,6 @@ static void gd_grab_pointer(VirtualConsole *vc, const char *reason)
vc->s->null_cursor);
gdk_device_get_position(gd_get_pointer(display),
NULL, &vc->s->grab_x_root, &vc->s->grab_y_root);
-#else
- gdk_pointer_grab(gtk_widget_get_window(vc->gfx.drawing_area),
- FALSE, /* All events to come to our window directly */
- GDK_POINTER_MOTION_MASK |
- GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_BUTTON_MOTION_MASK |
- GDK_SCROLL_MASK,
- NULL, /* Allow cursor to move over entire desktop */
- vc->s->null_cursor,
- GDK_CURRENT_TIME);
- gdk_display_get_pointer(display, NULL,
- &vc->s->grab_x_root, &vc->s->grab_y_root, NULL);
#endif
vc->s->ptr_owner = vc;
gd_update_caption(vc->s);
@@ -1673,16 +1559,11 @@ static void gd_ungrab_pointer(GtkDisplayState *s)
gdk_device_warp(gd_get_pointer(display),
gtk_widget_get_screen(vc->gfx.drawing_area),
vc->s->grab_x_root, vc->s->grab_y_root);
-#elif GTK_CHECK_VERSION(3, 0, 0)
+#else
gd_grab_devices(vc, false, GDK_SOURCE_MOUSE, 0, NULL);
gdk_device_warp(gd_get_pointer(display),
gtk_widget_get_screen(vc->gfx.drawing_area),
vc->s->grab_x_root, vc->s->grab_y_root);
-#else
- gdk_pointer_ungrab(GDK_CURRENT_TIME);
- gdk_display_warp_pointer(display,
- gtk_widget_get_screen(vc->gfx.drawing_area),
- vc->s->grab_x_root, vc->s->grab_y_root);
#endif
gd_update_caption(s);
trace_gd_ungrab(vc->label, "ptr");
@@ -1715,21 +1596,10 @@ static void gd_change_page(GtkNotebook *nb, gpointer arg1, guint arg2,
return;
}
-#ifdef VTE_RESIZE_HACK
- vc = gd_vc_find_current(s);
- if (vc && vc->type == GD_VC_VTE) {
- gtk_widget_hide(vc->vte.terminal);
- }
-#endif
vc = gd_vc_find_by_page(s, arg2);
if (!vc) {
return;
}
-#ifdef VTE_RESIZE_HACK
- if (vc->type == GD_VC_VTE) {
- gtk_widget_show(vc->vte.terminal);
- }
-#endif
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(vc->menu_item),
TRUE);
on_vga = (vc->type == GD_VC_GFX &&
@@ -1963,20 +1833,15 @@ static GSList *gd_vc_vte_init(GtkDisplayState *s, VirtualConsole *vc,
vte_terminal_set_size(VTE_TERMINAL(vc->vte.terminal),
VC_TERM_X_MIN, VC_TERM_Y_MIN);
-#if VTE_CHECK_VERSION(0, 28, 0) && GTK_CHECK_VERSION(3, 0, 0)
+#if VTE_CHECK_VERSION(0, 28, 0)
vadjustment = gtk_scrollable_get_vadjustment
(GTK_SCROLLABLE(vc->vte.terminal));
#else
vadjustment = vte_terminal_get_adjustment(VTE_TERMINAL(vc->vte.terminal));
#endif
-#if GTK_CHECK_VERSION(3, 0, 0)
box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
scrollbar = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, vadjustment);
-#else
- box = gtk_hbox_new(false, 2);
- scrollbar = gtk_vscrollbar_new(vadjustment);
-#endif
gtk_box_pack_end(GTK_BOX(box), scrollbar, FALSE, FALSE, 0);
gtk_box_pack_end(GTK_BOX(box), vc->vte.terminal, TRUE, TRUE, 0);
@@ -2015,7 +1880,6 @@ static void gd_vcs_init(GtkDisplayState *s, GSList *group,
static void gd_connect_vc_gfx_signals(VirtualConsole *vc)
{
-#if GTK_CHECK_VERSION(3, 0, 0)
g_signal_connect(vc->gfx.drawing_area, "draw",
G_CALLBACK(gd_draw_event), vc);
#if defined(CONFIG_GTK_GL)
@@ -2027,10 +1891,6 @@ static void gd_connect_vc_gfx_signals(VirtualConsole *vc)
G_CALLBACK(gd_resize_event), vc);
}
#endif
-#else
- g_signal_connect(vc->gfx.drawing_area, "expose-event",
- G_CALLBACK(gd_expose_event), vc);
-#endif
if (qemu_console_is_graphic(vc->gfx.dcl.con)) {
g_signal_connect(vc->gfx.drawing_area, "event",
G_CALLBACK(gd_event), vc);
@@ -2234,11 +2094,9 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState *s)
gtk_accel_group_connect(s->accel_group, GDK_KEY_f, HOTKEY_MODIFIERS, 0,
g_cclosure_new_swap(G_CALLBACK(gd_accel_full_screen), s, NULL));
-#if GTK_CHECK_VERSION(3, 8, 0)
gtk_accel_label_set_accel(
GTK_ACCEL_LABEL(gtk_bin_get_child(GTK_BIN(s->full_screen_item))),
GDK_KEY_f, HOTKEY_MODIFIERS);
-#endif
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->full_screen_item);
separator = gtk_separator_menu_item_new();
@@ -2370,11 +2228,6 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
assert(opts->type == DISPLAY_TYPE_GTK);
s->opts = opts;
-#if !GTK_CHECK_VERSION(3, 0, 0)
- g_printerr("Running QEMU with GTK 2.x is deprecated, and will be removed\n"
- "in a future release. Please switch to GTK 3.x instead\n");
-#endif
-
s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
#if GTK_CHECK_VERSION(3, 2, 0)
s->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
@@ -2431,23 +2284,6 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
gtk_widget_show_all(s->window);
-#ifdef VTE_RESIZE_HACK
- {
- VirtualConsole *cur = gd_vc_find_current(s);
- if (cur) {
- int i;
-
- for (i = 0; i < s->nb_vcs; i++) {
- VirtualConsole *vc = &s->vc[i];
- if (vc && vc->type == GD_VC_VTE && vc != cur) {
- gtk_widget_hide(vc->vte.terminal);
- }
- }
- gd_update_windowsize(cur);
- }
- }
-#endif
-
vc = gd_vc_find_current(s);
gtk_widget_set_sensitive(s->view_menu, vc != NULL);
#ifdef CONFIG_VTE