2013-02-20 13:43:20 +00:00
|
|
|
/*
|
|
|
|
* GTK UI
|
|
|
|
*
|
|
|
|
* Copyright IBM, Corp. 2012
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Anthony Liguori <aliguori@us.ibm.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*
|
|
|
|
* Portions from gtk-vnc:
|
|
|
|
*
|
|
|
|
* GTK VNC Widget
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws>
|
|
|
|
* Copyright (C) 2009-2010 Daniel P. Berrange <dan@berrange.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.0 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2013-02-20 13:43:24 +00:00
|
|
|
#define GETTEXT_PACKAGE "qemu"
|
|
|
|
#define LOCALEDIR "po"
|
|
|
|
|
2013-12-07 15:25:17 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
# define _WIN32_WINNT 0x0601 /* needed to get definition of MAPVK_VK_TO_VSC */
|
|
|
|
#endif
|
|
|
|
|
2013-02-22 20:08:51 +00:00
|
|
|
#include "qemu-common.h"
|
|
|
|
|
|
|
|
#ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
|
|
|
|
/* Work around an -Wstrict-prototypes warning in GTK headers */
|
2013-04-16 11:51:06 +00:00
|
|
|
#pragma GCC diagnostic push
|
2013-02-22 20:08:51 +00:00
|
|
|
#pragma GCC diagnostic ignored "-Wstrict-prototypes"
|
|
|
|
#endif
|
2013-02-20 13:43:20 +00:00
|
|
|
#include <gtk/gtk.h>
|
2013-02-22 20:08:51 +00:00
|
|
|
#ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
|
2013-04-16 11:51:06 +00:00
|
|
|
#pragma GCC diagnostic pop
|
2013-02-22 20:08:51 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2013-02-20 13:43:20 +00:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
2013-02-20 13:43:24 +00:00
|
|
|
#include <glib/gi18n.h>
|
2013-02-22 06:28:01 +00:00
|
|
|
#include <locale.h>
|
2013-02-20 13:43:20 +00:00
|
|
|
#include <vte/vte.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
2013-11-10 15:24:02 +00:00
|
|
|
#include "trace.h"
|
2013-02-20 13:43:20 +00:00
|
|
|
#include "ui/console.h"
|
2013-11-28 10:40:27 +00:00
|
|
|
#include "ui/input.h"
|
2013-02-20 13:43:20 +00:00
|
|
|
#include "sysemu/sysemu.h"
|
|
|
|
#include "qmp-commands.h"
|
|
|
|
#include "x_keymap.h"
|
|
|
|
#include "keymaps.h"
|
2013-04-08 14:55:25 +00:00
|
|
|
#include "sysemu/char.h"
|
2013-02-20 13:43:20 +00:00
|
|
|
|
2013-02-20 13:43:21 +00:00
|
|
|
#define MAX_VCS 10
|
|
|
|
|
2013-02-25 15:20:34 +00:00
|
|
|
|
|
|
|
/* Compatibility define to let us build on both Gtk2 and Gtk3 */
|
|
|
|
#if GTK_CHECK_VERSION(3, 0, 0)
|
|
|
|
static inline void gdk_drawable_get_size(GdkWindow *w, gint *ww, gint *wh)
|
|
|
|
{
|
|
|
|
*ww = gdk_window_get_width(w);
|
|
|
|
*wh = gdk_window_get_height(w);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-02-25 15:20:45 +00:00
|
|
|
#if !GTK_CHECK_VERSION(2, 20, 0)
|
|
|
|
#define gtk_widget_get_realized(widget) GTK_WIDGET_REALIZED(widget)
|
|
|
|
#endif
|
|
|
|
|
2013-02-25 15:20:46 +00:00
|
|
|
#ifndef GDK_KEY_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_plus GDK_plus
|
|
|
|
#define GDK_KEY_minus GDK_minus
|
|
|
|
#endif
|
2013-02-25 15:20:45 +00:00
|
|
|
|
2013-07-22 07:04:32 +00:00
|
|
|
#define HOTKEY_MODIFIERS (GDK_CONTROL_MASK | GDK_MOD1_MASK)
|
|
|
|
#define IGNORE_MODIFIER_MASK \
|
|
|
|
(GDK_MODIFIER_MASK & ~(GDK_LOCK_MASK | GDK_MOD2_MASK))
|
|
|
|
|
2013-03-24 18:10:02 +00:00
|
|
|
static const int modifier_keycode[] = {
|
|
|
|
/* shift, control, alt keys, meta keys, both left & right */
|
|
|
|
0x2a, 0x36, 0x1d, 0x9d, 0x38, 0xb8, 0xdb, 0xdd,
|
|
|
|
};
|
|
|
|
|
2013-02-20 13:43:20 +00:00
|
|
|
typedef struct VirtualConsole
|
|
|
|
{
|
|
|
|
GtkWidget *menu_item;
|
|
|
|
GtkWidget *terminal;
|
|
|
|
GtkWidget *scrolled_window;
|
|
|
|
CharDriverState *chr;
|
|
|
|
int fd;
|
|
|
|
} VirtualConsole;
|
|
|
|
|
|
|
|
typedef struct GtkDisplayState
|
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
|
|
|
|
GtkWidget *menu_bar;
|
|
|
|
|
2013-02-20 13:43:26 +00:00
|
|
|
GtkAccelGroup *accel_group;
|
|
|
|
|
2013-02-22 19:53:33 +00:00
|
|
|
GtkWidget *machine_menu_item;
|
|
|
|
GtkWidget *machine_menu;
|
|
|
|
GtkWidget *pause_item;
|
|
|
|
GtkWidget *reset_item;
|
|
|
|
GtkWidget *powerdown_item;
|
2013-02-20 13:43:20 +00:00
|
|
|
GtkWidget *quit_item;
|
|
|
|
|
|
|
|
GtkWidget *view_menu_item;
|
|
|
|
GtkWidget *view_menu;
|
2013-02-20 13:43:23 +00:00
|
|
|
GtkWidget *full_screen_item;
|
|
|
|
GtkWidget *zoom_in_item;
|
|
|
|
GtkWidget *zoom_out_item;
|
|
|
|
GtkWidget *zoom_fixed_item;
|
|
|
|
GtkWidget *zoom_fit_item;
|
2013-02-20 13:43:22 +00:00
|
|
|
GtkWidget *grab_item;
|
|
|
|
GtkWidget *grab_on_hover_item;
|
2013-02-20 13:43:20 +00:00
|
|
|
GtkWidget *vga_item;
|
|
|
|
|
2013-02-20 13:43:21 +00:00
|
|
|
int nb_vcs;
|
|
|
|
VirtualConsole vc[MAX_VCS];
|
|
|
|
|
2013-02-20 13:43:20 +00:00
|
|
|
GtkWidget *show_tabs_item;
|
|
|
|
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *notebook;
|
|
|
|
GtkWidget *drawing_area;
|
|
|
|
cairo_surface_t *surface;
|
2013-06-25 08:48:54 +00:00
|
|
|
pixman_image_t *convert;
|
2013-02-20 13:43:20 +00:00
|
|
|
DisplayChangeListener dcl;
|
2013-02-28 15:10:02 +00:00
|
|
|
DisplaySurface *ds;
|
2013-02-20 13:43:20 +00:00
|
|
|
int button_mask;
|
|
|
|
int last_x;
|
|
|
|
int last_y;
|
|
|
|
|
|
|
|
double scale_x;
|
|
|
|
double scale_y;
|
2013-02-20 13:43:23 +00:00
|
|
|
gboolean full_screen;
|
2013-02-20 13:43:20 +00:00
|
|
|
|
|
|
|
GdkCursor *null_cursor;
|
|
|
|
Notifier mouse_mode_notifier;
|
2013-02-20 13:43:23 +00:00
|
|
|
gboolean free_scale;
|
2013-02-22 19:53:33 +00:00
|
|
|
|
|
|
|
bool external_pause_update;
|
2013-03-24 18:10:02 +00:00
|
|
|
|
|
|
|
bool modifier_pressed[ARRAY_SIZE(modifier_keycode)];
|
2013-02-20 13:43:20 +00:00
|
|
|
} GtkDisplayState;
|
|
|
|
|
|
|
|
static GtkDisplayState *global_state;
|
|
|
|
|
|
|
|
/** Utility Functions **/
|
|
|
|
|
2013-02-20 13:43:22 +00:00
|
|
|
static bool gd_is_grab_active(GtkDisplayState *s)
|
|
|
|
{
|
|
|
|
return gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(s->grab_item));
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool gd_grab_on_hover(GtkDisplayState *s)
|
|
|
|
{
|
|
|
|
return gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(s->grab_on_hover_item));
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool gd_on_vga(GtkDisplayState *s)
|
|
|
|
{
|
|
|
|
return gtk_notebook_get_current_page(GTK_NOTEBOOK(s->notebook)) == 0;
|
|
|
|
}
|
|
|
|
|
2013-02-20 13:43:20 +00:00
|
|
|
static void gd_update_cursor(GtkDisplayState *s, gboolean override)
|
|
|
|
{
|
|
|
|
GdkWindow *window;
|
|
|
|
bool on_vga;
|
|
|
|
|
|
|
|
window = gtk_widget_get_window(GTK_WIDGET(s->drawing_area));
|
|
|
|
|
2013-02-20 13:43:22 +00:00
|
|
|
on_vga = gd_on_vga(s);
|
2013-02-20 13:43:20 +00:00
|
|
|
|
2013-02-20 13:43:22 +00:00
|
|
|
if ((override || on_vga) &&
|
2013-11-28 11:06:04 +00:00
|
|
|
(s->full_screen || qemu_input_is_absolute() || gd_is_grab_active(s))) {
|
2013-02-20 13:43:20 +00:00
|
|
|
gdk_window_set_cursor(window, s->null_cursor);
|
|
|
|
} else {
|
|
|
|
gdk_window_set_cursor(window, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gd_update_caption(GtkDisplayState *s)
|
|
|
|
{
|
|
|
|
const char *status = "";
|
|
|
|
gchar *title;
|
2013-02-20 13:43:22 +00:00
|
|
|
const char *grab = "";
|
2013-02-22 19:53:33 +00:00
|
|
|
bool is_paused = !runstate_is_running();
|
2013-02-20 13:43:22 +00:00
|
|
|
|
|
|
|
if (gd_is_grab_active(s)) {
|
2013-04-01 17:12:02 +00:00
|
|
|
grab = _(" - Press Ctrl+Alt+G to release grab");
|
2013-02-20 13:43:22 +00:00
|
|
|
}
|
2013-02-20 13:43:20 +00:00
|
|
|
|
2013-02-22 19:53:33 +00:00
|
|
|
if (is_paused) {
|
2013-04-01 17:12:02 +00:00
|
|
|
status = _(" [Paused]");
|
2013-02-20 13:43:20 +00:00
|
|
|
}
|
2013-02-22 19:53:33 +00:00
|
|
|
s->external_pause_update = true;
|
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->pause_item),
|
|
|
|
is_paused);
|
|
|
|
s->external_pause_update = false;
|
2013-02-20 13:43:20 +00:00
|
|
|
|
|
|
|
if (qemu_name) {
|
2013-02-20 13:43:22 +00:00
|
|
|
title = g_strdup_printf("QEMU (%s)%s%s", qemu_name, status, grab);
|
2013-02-20 13:43:20 +00:00
|
|
|
} else {
|
2013-02-20 13:43:22 +00:00
|
|
|
title = g_strdup_printf("QEMU%s%s", status, grab);
|
2013-02-20 13:43:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_window_set_title(GTK_WINDOW(s->window), title);
|
|
|
|
|
|
|
|
g_free(title);
|
|
|
|
}
|
|
|
|
|
2013-02-28 15:10:02 +00:00
|
|
|
static void gd_update_windowsize(GtkDisplayState *s)
|
|
|
|
{
|
|
|
|
if (!s->full_screen) {
|
|
|
|
GtkRequisition req;
|
|
|
|
double sx, sy;
|
|
|
|
|
|
|
|
if (s->free_scale) {
|
|
|
|
sx = s->scale_x;
|
|
|
|
sy = s->scale_y;
|
|
|
|
|
|
|
|
s->scale_y = 1.0;
|
|
|
|
s->scale_x = 1.0;
|
|
|
|
} else {
|
|
|
|
sx = 1.0;
|
|
|
|
sy = 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_set_size_request(s->drawing_area,
|
|
|
|
surface_width(s->ds) * s->scale_x,
|
|
|
|
surface_height(s->ds) * s->scale_y);
|
|
|
|
#if GTK_CHECK_VERSION(3, 0, 0)
|
|
|
|
gtk_widget_get_preferred_size(s->vbox, NULL, &req);
|
|
|
|
#else
|
|
|
|
gtk_widget_size_request(s->vbox, &req);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
gtk_window_resize(GTK_WINDOW(s->window),
|
|
|
|
req.width * sx, req.height * sy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gd_update_full_redraw(GtkDisplayState *s)
|
|
|
|
{
|
|
|
|
int ww, wh;
|
|
|
|
gdk_drawable_get_size(gtk_widget_get_window(s->drawing_area), &ww, &wh);
|
|
|
|
gtk_widget_queue_draw_area(s->drawing_area, 0, 0, ww, wh);
|
|
|
|
}
|
|
|
|
|
2013-03-24 18:10:02 +00:00
|
|
|
static void gtk_release_modifiers(GtkDisplayState *s)
|
|
|
|
{
|
|
|
|
int i, keycode;
|
|
|
|
|
|
|
|
if (!gd_on_vga(s)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (i = 0; i < ARRAY_SIZE(modifier_keycode); i++) {
|
|
|
|
keycode = modifier_keycode[i];
|
|
|
|
if (!s->modifier_pressed[i]) {
|
|
|
|
continue;
|
|
|
|
}
|
2013-11-28 10:40:27 +00:00
|
|
|
qemu_input_event_send_key_number(s->dcl.con, keycode, false);
|
2013-03-24 18:10:02 +00:00
|
|
|
s->modifier_pressed[i] = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-20 13:43:20 +00:00
|
|
|
/** DisplayState Callbacks **/
|
|
|
|
|
2012-11-13 13:51:41 +00:00
|
|
|
static void gd_update(DisplayChangeListener *dcl,
|
2013-03-01 12:03:04 +00:00
|
|
|
int x, int y, int w, int h)
|
2013-02-20 13:43:20 +00:00
|
|
|
{
|
2013-02-28 10:34:31 +00:00
|
|
|
GtkDisplayState *s = container_of(dcl, GtkDisplayState, dcl);
|
2013-02-20 13:43:20 +00:00
|
|
|
int x1, x2, y1, y2;
|
2013-02-20 13:43:23 +00:00
|
|
|
int mx, my;
|
|
|
|
int fbw, fbh;
|
|
|
|
int ww, wh;
|
2013-02-20 13:43:20 +00:00
|
|
|
|
2013-11-10 15:24:02 +00:00
|
|
|
trace_gd_update(x, y, w, h);
|
2013-02-20 13:43:20 +00:00
|
|
|
|
2013-06-25 08:48:54 +00:00
|
|
|
if (s->convert) {
|
|
|
|
pixman_image_composite(PIXMAN_OP_SRC, s->ds->image, NULL, s->convert,
|
|
|
|
x, y, 0, 0, x, y, w, h);
|
|
|
|
}
|
|
|
|
|
2013-02-20 13:43:20 +00:00
|
|
|
x1 = floor(x * s->scale_x);
|
|
|
|
y1 = floor(y * s->scale_y);
|
|
|
|
|
|
|
|
x2 = ceil(x * s->scale_x + w * s->scale_x);
|
|
|
|
y2 = ceil(y * s->scale_y + h * s->scale_y);
|
|
|
|
|
2013-02-28 15:10:02 +00:00
|
|
|
fbw = surface_width(s->ds) * s->scale_x;
|
|
|
|
fbh = surface_height(s->ds) * s->scale_y;
|
2013-02-20 13:43:23 +00:00
|
|
|
|
|
|
|
gdk_drawable_get_size(gtk_widget_get_window(s->drawing_area), &ww, &wh);
|
|
|
|
|
|
|
|
mx = my = 0;
|
|
|
|
if (ww > fbw) {
|
|
|
|
mx = (ww - fbw) / 2;
|
|
|
|
}
|
|
|
|
if (wh > fbh) {
|
|
|
|
my = (wh - fbh) / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_queue_draw_area(s->drawing_area, mx + x1, my + y1, (x2 - x1), (y2 - y1));
|
2013-02-20 13:43:20 +00:00
|
|
|
}
|
|
|
|
|
2013-03-01 12:03:04 +00:00
|
|
|
static void gd_refresh(DisplayChangeListener *dcl)
|
2013-02-20 13:43:20 +00:00
|
|
|
{
|
2013-03-15 14:45:54 +00:00
|
|
|
graphic_hw_update(dcl->con);
|
2013-02-20 13:43:20 +00:00
|
|
|
}
|
|
|
|
|
2013-05-10 14:59:45 +00:00
|
|
|
#if GTK_CHECK_VERSION(3, 0, 0)
|
|
|
|
static void gd_mouse_set(DisplayChangeListener *dcl,
|
|
|
|
int x, int y, int visible)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = container_of(dcl, GtkDisplayState, dcl);
|
|
|
|
GdkDisplay *dpy;
|
|
|
|
GdkDeviceManager *mgr;
|
|
|
|
gint x_root, y_root;
|
|
|
|
|
|
|
|
dpy = gtk_widget_get_display(s->drawing_area);
|
|
|
|
mgr = gdk_display_get_device_manager(dpy);
|
|
|
|
gdk_window_get_root_coords(gtk_widget_get_window(s->drawing_area),
|
|
|
|
x, y, &x_root, &y_root);
|
|
|
|
gdk_device_warp(gdk_device_manager_get_client_pointer(mgr),
|
|
|
|
gtk_widget_get_screen(s->drawing_area),
|
|
|
|
x, y);
|
|
|
|
}
|
|
|
|
#else
|
2013-03-20 08:11:41 +00:00
|
|
|
static void gd_mouse_set(DisplayChangeListener *dcl,
|
|
|
|
int x, int y, int visible)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = container_of(dcl, GtkDisplayState, dcl);
|
|
|
|
gint x_root, y_root;
|
|
|
|
|
2013-04-23 10:03:22 +00:00
|
|
|
gdk_window_get_root_coords(gtk_widget_get_window(s->drawing_area),
|
2013-03-20 08:11:41 +00:00
|
|
|
x, y, &x_root, &y_root);
|
|
|
|
gdk_display_warp_pointer(gtk_widget_get_display(s->drawing_area),
|
|
|
|
gtk_widget_get_screen(s->drawing_area),
|
|
|
|
x_root, y_root);
|
|
|
|
}
|
2013-05-10 14:59:45 +00:00
|
|
|
#endif
|
2013-03-20 08:11:41 +00:00
|
|
|
|
|
|
|
static void gd_cursor_define(DisplayChangeListener *dcl,
|
|
|
|
QEMUCursor *c)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = container_of(dcl, GtkDisplayState, dcl);
|
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
GdkCursor *cursor;
|
|
|
|
|
|
|
|
pixbuf = gdk_pixbuf_new_from_data((guchar *)(c->data),
|
|
|
|
GDK_COLORSPACE_RGB, true, 8,
|
|
|
|
c->width, c->height, c->width * 4,
|
|
|
|
NULL, NULL);
|
|
|
|
cursor = gdk_cursor_new_from_pixbuf(gtk_widget_get_display(s->drawing_area),
|
|
|
|
pixbuf, c->hot_x, c->hot_y);
|
2013-04-23 10:03:22 +00:00
|
|
|
gdk_window_set_cursor(gtk_widget_get_window(s->drawing_area), cursor);
|
2013-03-20 08:11:41 +00:00
|
|
|
g_object_unref(pixbuf);
|
2013-06-16 14:13:07 +00:00
|
|
|
#if !GTK_CHECK_VERSION(3, 0, 0)
|
2013-06-03 20:37:23 +00:00
|
|
|
gdk_cursor_unref(cursor);
|
2013-06-16 14:13:07 +00:00
|
|
|
#else
|
|
|
|
g_object_unref(cursor);
|
|
|
|
#endif
|
2013-03-20 08:11:41 +00:00
|
|
|
}
|
|
|
|
|
2013-02-28 14:03:04 +00:00
|
|
|
static void gd_switch(DisplayChangeListener *dcl,
|
|
|
|
DisplaySurface *surface)
|
2013-02-20 13:43:20 +00:00
|
|
|
{
|
2013-02-28 10:34:31 +00:00
|
|
|
GtkDisplayState *s = container_of(dcl, GtkDisplayState, dcl);
|
2013-02-28 15:10:02 +00:00
|
|
|
bool resized = true;
|
2013-02-20 13:43:20 +00:00
|
|
|
|
2013-11-10 15:24:02 +00:00
|
|
|
trace_gd_switch(surface_width(surface), surface_height(surface));
|
2013-02-20 13:43:20 +00:00
|
|
|
|
|
|
|
if (s->surface) {
|
|
|
|
cairo_surface_destroy(s->surface);
|
|
|
|
}
|
|
|
|
|
2013-02-28 15:10:02 +00:00
|
|
|
if (s->ds &&
|
|
|
|
surface_width(s->ds) == surface_width(surface) &&
|
|
|
|
surface_height(s->ds) == surface_height(surface)) {
|
|
|
|
resized = false;
|
|
|
|
}
|
|
|
|
s->ds = surface;
|
2013-02-20 13:43:20 +00:00
|
|
|
|
2013-06-25 08:48:54 +00:00
|
|
|
if (s->convert) {
|
|
|
|
pixman_image_unref(s->convert);
|
|
|
|
s->convert = NULL;
|
|
|
|
}
|
2013-02-20 13:43:20 +00:00
|
|
|
|
2013-06-25 08:48:54 +00:00
|
|
|
if (surface->format == PIXMAN_x8r8g8b8) {
|
|
|
|
/*
|
|
|
|
* PIXMAN_x8r8g8b8 == CAIRO_FORMAT_RGB24
|
|
|
|
*
|
|
|
|
* No need to convert, use surface directly. Should be the
|
|
|
|
* common case as this is qemu_default_pixelformat(32) too.
|
|
|
|
*/
|
|
|
|
s->surface = cairo_image_surface_create_for_data
|
|
|
|
(surface_data(surface),
|
|
|
|
CAIRO_FORMAT_RGB24,
|
|
|
|
surface_width(surface),
|
|
|
|
surface_height(surface),
|
|
|
|
surface_stride(surface));
|
|
|
|
} else {
|
|
|
|
/* Must convert surface, use pixman to do it. */
|
|
|
|
s->convert = pixman_image_create_bits(PIXMAN_x8r8g8b8,
|
|
|
|
surface_width(surface),
|
|
|
|
surface_height(surface),
|
|
|
|
NULL, 0);
|
|
|
|
s->surface = cairo_image_surface_create_for_data
|
|
|
|
((void *)pixman_image_get_data(s->convert),
|
|
|
|
CAIRO_FORMAT_RGB24,
|
|
|
|
pixman_image_get_width(s->convert),
|
|
|
|
pixman_image_get_height(s->convert),
|
|
|
|
pixman_image_get_stride(s->convert));
|
|
|
|
pixman_image_composite(PIXMAN_OP_SRC, s->ds->image, NULL, s->convert,
|
|
|
|
0, 0, 0, 0, 0, 0,
|
|
|
|
pixman_image_get_width(s->convert),
|
|
|
|
pixman_image_get_height(s->convert));
|
|
|
|
}
|
2013-02-20 13:43:23 +00:00
|
|
|
|
2013-02-28 15:10:02 +00:00
|
|
|
if (resized) {
|
|
|
|
gd_update_windowsize(s);
|
|
|
|
} else {
|
|
|
|
gd_update_full_redraw(s);
|
2013-02-20 13:43:23 +00:00
|
|
|
}
|
2013-02-20 13:43:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** QEMU Events **/
|
|
|
|
|
|
|
|
static void gd_change_runstate(void *opaque, int running, RunState state)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = opaque;
|
|
|
|
|
|
|
|
gd_update_caption(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gd_mouse_mode_change(Notifier *notify, void *data)
|
|
|
|
{
|
|
|
|
gd_update_cursor(container_of(notify, GtkDisplayState, mouse_mode_notifier),
|
|
|
|
FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** GTK Events **/
|
|
|
|
|
2013-02-20 13:43:26 +00:00
|
|
|
static gboolean gd_window_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = opaque;
|
|
|
|
gboolean handled = FALSE;
|
|
|
|
|
2013-07-22 07:04:32 +00:00
|
|
|
if (!gd_is_grab_active(s) ||
|
|
|
|
(key->state & IGNORE_MODIFIER_MASK) == HOTKEY_MODIFIERS) {
|
2013-02-20 13:43:26 +00:00
|
|
|
handled = gtk_window_activate_key(GTK_WINDOW(widget), key);
|
|
|
|
}
|
2013-03-24 18:10:02 +00:00
|
|
|
if (handled) {
|
|
|
|
gtk_release_modifiers(s);
|
|
|
|
} else {
|
2013-02-20 13:43:26 +00:00
|
|
|
handled = gtk_window_propagate_key_event(GTK_WINDOW(widget), key);
|
|
|
|
}
|
|
|
|
|
|
|
|
return handled;
|
|
|
|
}
|
|
|
|
|
2013-02-20 13:43:20 +00:00
|
|
|
static gboolean gd_window_close(GtkWidget *widget, GdkEvent *event,
|
|
|
|
void *opaque)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = opaque;
|
|
|
|
|
|
|
|
if (!no_quit) {
|
2012-11-13 13:51:41 +00:00
|
|
|
unregister_displaychangelistener(&s->dcl);
|
2013-02-20 13:43:20 +00:00
|
|
|
qmp_quit(NULL);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = opaque;
|
2013-02-20 13:43:23 +00:00
|
|
|
int mx, my;
|
2013-02-20 13:43:20 +00:00
|
|
|
int ww, wh;
|
|
|
|
int fbw, fbh;
|
|
|
|
|
2013-02-20 13:43:23 +00:00
|
|
|
if (!gtk_widget_get_realized(widget)) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-02-28 15:10:02 +00:00
|
|
|
fbw = surface_width(s->ds);
|
|
|
|
fbh = surface_height(s->ds);
|
2013-02-20 13:43:20 +00:00
|
|
|
|
|
|
|
gdk_drawable_get_size(gtk_widget_get_window(widget), &ww, &wh);
|
|
|
|
|
2013-02-20 13:43:23 +00:00
|
|
|
if (s->full_screen) {
|
2013-02-20 13:43:20 +00:00
|
|
|
s->scale_x = (double)ww / fbw;
|
|
|
|
s->scale_y = (double)wh / fbh;
|
2013-02-20 13:43:23 +00:00
|
|
|
} else if (s->free_scale) {
|
|
|
|
double sx, sy;
|
|
|
|
|
|
|
|
sx = (double)ww / fbw;
|
|
|
|
sy = (double)wh / fbh;
|
|
|
|
|
|
|
|
s->scale_x = s->scale_y = MIN(sx, sy);
|
2013-02-20 13:43:20 +00:00
|
|
|
}
|
|
|
|
|
2013-02-20 13:43:22 +00:00
|
|
|
fbw *= s->scale_x;
|
|
|
|
fbh *= s->scale_y;
|
|
|
|
|
2013-02-20 13:43:23 +00:00
|
|
|
mx = my = 0;
|
|
|
|
if (ww > fbw) {
|
|
|
|
mx = (ww - fbw) / 2;
|
|
|
|
}
|
|
|
|
if (wh > fbh) {
|
|
|
|
my = (wh - fbh) / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
cairo_rectangle(cr, 0, 0, ww, wh);
|
|
|
|
|
|
|
|
/* Optionally cut out the inner area where the pixmap
|
|
|
|
will be drawn. This avoids 'flashing' since we're
|
|
|
|
not double-buffering. Note we're using the undocumented
|
|
|
|
behaviour of drawing the rectangle from right to left
|
|
|
|
to cut out the whole */
|
|
|
|
cairo_rectangle(cr, mx + fbw, my,
|
|
|
|
-1 * fbw, fbh);
|
|
|
|
cairo_fill(cr);
|
|
|
|
|
|
|
|
cairo_scale(cr, s->scale_x, s->scale_y);
|
|
|
|
cairo_set_source_surface(cr, s->surface, mx / s->scale_x, my / s->scale_y);
|
2013-02-20 13:43:20 +00:00
|
|
|
cairo_paint(cr);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-02-25 15:20:42 +00:00
|
|
|
#if !GTK_CHECK_VERSION(3, 0, 0)
|
2013-02-20 13:43:20 +00:00
|
|
|
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;
|
|
|
|
}
|
2013-02-25 15:20:42 +00:00
|
|
|
#endif
|
2013-02-20 13:43:20 +00:00
|
|
|
|
|
|
|
static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
|
|
|
|
void *opaque)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = opaque;
|
|
|
|
int x, y;
|
2013-02-20 13:43:23 +00:00
|
|
|
int mx, my;
|
|
|
|
int fbh, fbw;
|
|
|
|
int ww, wh;
|
|
|
|
|
2013-02-28 15:10:02 +00:00
|
|
|
fbw = surface_width(s->ds) * s->scale_x;
|
|
|
|
fbh = surface_height(s->ds) * s->scale_y;
|
2013-02-20 13:43:20 +00:00
|
|
|
|
2013-02-20 13:43:23 +00:00
|
|
|
gdk_drawable_get_size(gtk_widget_get_window(s->drawing_area), &ww, &wh);
|
|
|
|
|
|
|
|
mx = my = 0;
|
|
|
|
if (ww > fbw) {
|
|
|
|
mx = (ww - fbw) / 2;
|
|
|
|
}
|
|
|
|
if (wh > fbh) {
|
|
|
|
my = (wh - fbh) / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
x = (motion->x - mx) / s->scale_x;
|
|
|
|
y = (motion->y - my) / s->scale_y;
|
|
|
|
|
|
|
|
if (x < 0 || y < 0 ||
|
2013-02-28 15:10:02 +00:00
|
|
|
x >= surface_width(s->ds) ||
|
|
|
|
y >= surface_height(s->ds)) {
|
2013-02-20 13:43:23 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2013-02-20 13:43:20 +00:00
|
|
|
|
2013-11-28 11:06:04 +00:00
|
|
|
if (qemu_input_is_absolute()) {
|
|
|
|
qemu_input_queue_abs(s->dcl.con, INPUT_AXIS_X, x,
|
|
|
|
surface_width(s->ds));
|
|
|
|
qemu_input_queue_abs(s->dcl.con, INPUT_AXIS_Y, y,
|
|
|
|
surface_height(s->ds));
|
|
|
|
qemu_input_event_sync();
|
|
|
|
} else if (s->last_x != -1 && s->last_y != -1 && gd_is_grab_active(s)) {
|
|
|
|
qemu_input_queue_rel(s->dcl.con, INPUT_AXIS_X, x - s->last_x);
|
|
|
|
qemu_input_queue_rel(s->dcl.con, INPUT_AXIS_Y, y - s->last_y);
|
|
|
|
qemu_input_event_sync();
|
2013-02-20 13:43:20 +00:00
|
|
|
}
|
|
|
|
s->last_x = x;
|
|
|
|
s->last_y = y;
|
|
|
|
|
2013-11-28 11:06:04 +00:00
|
|
|
if (!qemu_input_is_absolute() && gd_is_grab_active(s)) {
|
2013-02-25 15:20:35 +00:00
|
|
|
GdkScreen *screen = gtk_widget_get_screen(s->drawing_area);
|
2013-02-20 13:43:22 +00:00
|
|
|
int x = (int)motion->x_root;
|
|
|
|
int y = (int)motion->y_root;
|
|
|
|
|
|
|
|
/* In relative mode check to see if client pointer hit
|
|
|
|
* one of the screen edges, and if so move it back by
|
|
|
|
* 200 pixels. This is important because the pointer
|
|
|
|
* in the server doesn't correspond 1-for-1, and so
|
|
|
|
* may still be only half way across the screen. Without
|
|
|
|
* this warp, the server pointer would thus appear to hit
|
|
|
|
* an invisible wall */
|
|
|
|
if (x == 0) {
|
|
|
|
x += 200;
|
|
|
|
}
|
|
|
|
if (y == 0) {
|
|
|
|
y += 200;
|
|
|
|
}
|
|
|
|
if (x == (gdk_screen_get_width(screen) - 1)) {
|
|
|
|
x -= 200;
|
|
|
|
}
|
|
|
|
if (y == (gdk_screen_get_height(screen) - 1)) {
|
|
|
|
y -= 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x != (int)motion->x_root || y != (int)motion->y_root) {
|
2013-02-25 15:20:40 +00:00
|
|
|
#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);
|
2013-02-20 13:43:22 +00:00
|
|
|
gdk_display_warp_pointer(display, screen, x, y);
|
2013-02-25 15:20:40 +00:00
|
|
|
#endif
|
2013-02-20 13:43:22 +00:00
|
|
|
s->last_x = -1;
|
|
|
|
s->last_y = -1;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2013-02-20 13:43:20 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean gd_button_event(GtkWidget *widget, GdkEventButton *button,
|
|
|
|
void *opaque)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = opaque;
|
2013-11-28 11:06:04 +00:00
|
|
|
InputButton btn;
|
2013-02-20 13:43:20 +00:00
|
|
|
|
|
|
|
if (button->button == 1) {
|
2013-11-28 11:06:04 +00:00
|
|
|
btn = INPUT_BUTTON_LEFT;
|
2013-02-20 13:43:20 +00:00
|
|
|
} else if (button->button == 2) {
|
2013-11-28 11:06:04 +00:00
|
|
|
btn = INPUT_BUTTON_MIDDLE;
|
2013-02-20 13:43:20 +00:00
|
|
|
} else if (button->button == 3) {
|
2013-11-28 11:06:04 +00:00
|
|
|
btn = INPUT_BUTTON_RIGHT;
|
2013-02-20 13:43:20 +00:00
|
|
|
} else {
|
2013-11-28 11:06:04 +00:00
|
|
|
return TRUE;
|
2013-02-20 13:43:20 +00:00
|
|
|
}
|
|
|
|
|
2013-11-28 11:06:04 +00:00
|
|
|
qemu_input_queue_btn(s->dcl.con, btn, button->type == GDK_BUTTON_PRESS);
|
|
|
|
qemu_input_event_sync();
|
2013-02-20 13:43:20 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-03-11 16:26:44 +00:00
|
|
|
static gboolean gd_scroll_event(GtkWidget *widget, GdkEventScroll *scroll,
|
|
|
|
void *opaque)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = opaque;
|
|
|
|
InputButton btn;
|
|
|
|
|
|
|
|
if (scroll->direction == GDK_SCROLL_UP) {
|
|
|
|
btn = INPUT_BUTTON_WHEEL_UP;
|
|
|
|
} else if (scroll->direction == GDK_SCROLL_DOWN) {
|
|
|
|
btn = INPUT_BUTTON_WHEEL_DOWN;
|
|
|
|
} else {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
qemu_input_queue_btn(s->dcl.con, btn, true);
|
|
|
|
qemu_input_event_sync();
|
|
|
|
qemu_input_queue_btn(s->dcl.con, btn, false);
|
|
|
|
qemu_input_event_sync();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-02-20 13:43:20 +00:00
|
|
|
static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque)
|
|
|
|
{
|
2013-03-24 18:10:02 +00:00
|
|
|
GtkDisplayState *s = opaque;
|
2013-12-07 15:25:17 +00:00
|
|
|
int gdk_keycode = key->hardware_keycode;
|
2013-03-24 18:10:02 +00:00
|
|
|
int i;
|
2013-02-20 13:43:20 +00:00
|
|
|
|
2013-12-07 15:25:17 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
UINT qemu_keycode = MapVirtualKey(gdk_keycode, MAPVK_VK_TO_VSC);
|
|
|
|
switch (qemu_keycode) {
|
|
|
|
case 103: /* alt gr */
|
|
|
|
qemu_keycode = 56 | SCANCODE_GREY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
int qemu_keycode;
|
2013-02-20 13:43:20 +00:00
|
|
|
|
|
|
|
if (gdk_keycode < 9) {
|
|
|
|
qemu_keycode = 0;
|
|
|
|
} else if (gdk_keycode < 97) {
|
|
|
|
qemu_keycode = gdk_keycode - 8;
|
|
|
|
} else if (gdk_keycode < 158) {
|
|
|
|
qemu_keycode = translate_evdev_keycode(gdk_keycode - 97);
|
|
|
|
} else if (gdk_keycode == 208) { /* Hiragana_Katakana */
|
|
|
|
qemu_keycode = 0x70;
|
|
|
|
} else if (gdk_keycode == 211) { /* backslash */
|
|
|
|
qemu_keycode = 0x73;
|
|
|
|
} else {
|
|
|
|
qemu_keycode = 0;
|
|
|
|
}
|
2013-12-07 15:25:17 +00:00
|
|
|
#endif
|
2013-02-20 13:43:20 +00:00
|
|
|
|
2013-11-10 15:24:02 +00:00
|
|
|
trace_gd_key_event(gdk_keycode, qemu_keycode,
|
|
|
|
(key->type == GDK_KEY_PRESS) ? "down" : "up");
|
2013-02-20 13:43:20 +00:00
|
|
|
|
2013-03-24 18:10:02 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(modifier_keycode); i++) {
|
|
|
|
if (qemu_keycode == modifier_keycode[i]) {
|
|
|
|
s->modifier_pressed[i] = (key->type == GDK_KEY_PRESS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-28 10:40:27 +00:00
|
|
|
qemu_input_event_send_key_number(s->dcl.con, qemu_keycode,
|
|
|
|
key->type == GDK_KEY_PRESS);
|
2013-02-20 13:43:20 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Window Menu Actions **/
|
|
|
|
|
2013-02-22 19:53:33 +00:00
|
|
|
static void gd_menu_pause(GtkMenuItem *item, void *opaque)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = opaque;
|
|
|
|
|
|
|
|
if (s->external_pause_update) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (runstate_is_running()) {
|
|
|
|
qmp_stop(NULL);
|
|
|
|
} else {
|
|
|
|
qmp_cont(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gd_menu_reset(GtkMenuItem *item, void *opaque)
|
|
|
|
{
|
|
|
|
qmp_system_reset(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gd_menu_powerdown(GtkMenuItem *item, void *opaque)
|
|
|
|
{
|
|
|
|
qmp_system_powerdown(NULL);
|
|
|
|
}
|
|
|
|
|
2013-02-20 13:43:20 +00:00
|
|
|
static void gd_menu_quit(GtkMenuItem *item, void *opaque)
|
|
|
|
{
|
|
|
|
qmp_quit(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gd_menu_switch_vc(GtkMenuItem *item, void *opaque)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = opaque;
|
|
|
|
|
|
|
|
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(s->vga_item))) {
|
|
|
|
gtk_notebook_set_current_page(GTK_NOTEBOOK(s->notebook), 0);
|
2013-02-20 13:43:21 +00:00
|
|
|
} else {
|
|
|
|
int i;
|
|
|
|
|
2013-03-24 18:10:02 +00:00
|
|
|
gtk_release_modifiers(s);
|
2013-02-20 13:43:21 +00:00
|
|
|
for (i = 0; i < s->nb_vcs; i++) {
|
|
|
|
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(s->vc[i].menu_item))) {
|
|
|
|
gtk_notebook_set_current_page(GTK_NOTEBOOK(s->notebook), i + 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-02-20 13:43:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gd_menu_show_tabs(GtkMenuItem *item, void *opaque)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = opaque;
|
|
|
|
|
|
|
|
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(s->show_tabs_item))) {
|
|
|
|
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(s->notebook), TRUE);
|
|
|
|
} else {
|
|
|
|
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(s->notebook), FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-20 13:43:23 +00:00
|
|
|
static void gd_menu_full_screen(GtkMenuItem *item, void *opaque)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = opaque;
|
|
|
|
|
2013-02-22 19:33:34 +00:00
|
|
|
if (!s->full_screen) {
|
2013-02-20 13:43:23 +00:00
|
|
|
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(s->notebook), FALSE);
|
|
|
|
gtk_widget_set_size_request(s->menu_bar, 0, 0);
|
|
|
|
gtk_widget_set_size_request(s->drawing_area, -1, -1);
|
|
|
|
gtk_window_fullscreen(GTK_WINDOW(s->window));
|
|
|
|
if (gd_on_vga(s)) {
|
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item), TRUE);
|
|
|
|
}
|
|
|
|
s->full_screen = TRUE;
|
|
|
|
} else {
|
|
|
|
gtk_window_unfullscreen(GTK_WINDOW(s->window));
|
|
|
|
gd_menu_show_tabs(GTK_MENU_ITEM(s->show_tabs_item), s);
|
|
|
|
gtk_widget_set_size_request(s->menu_bar, -1, -1);
|
|
|
|
gtk_widget_set_size_request(s->drawing_area,
|
2013-02-28 15:10:02 +00:00
|
|
|
surface_width(s->ds),
|
|
|
|
surface_height(s->ds));
|
2013-02-20 13:43:23 +00:00
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item), FALSE);
|
|
|
|
s->full_screen = FALSE;
|
|
|
|
s->scale_x = 1.0;
|
|
|
|
s->scale_y = 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
gd_update_cursor(s, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gd_menu_zoom_in(GtkMenuItem *item, void *opaque)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = opaque;
|
|
|
|
|
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->zoom_fit_item),
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
s->scale_x += .25;
|
|
|
|
s->scale_y += .25;
|
|
|
|
|
2013-02-28 15:10:02 +00:00
|
|
|
gd_update_windowsize(s);
|
2013-02-20 13:43:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gd_menu_zoom_out(GtkMenuItem *item, void *opaque)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = opaque;
|
|
|
|
|
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->zoom_fit_item),
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
s->scale_x -= .25;
|
|
|
|
s->scale_y -= .25;
|
|
|
|
|
|
|
|
s->scale_x = MAX(s->scale_x, .25);
|
|
|
|
s->scale_y = MAX(s->scale_y, .25);
|
|
|
|
|
2013-02-28 15:10:02 +00:00
|
|
|
gd_update_windowsize(s);
|
2013-02-20 13:43:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gd_menu_zoom_fixed(GtkMenuItem *item, void *opaque)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = opaque;
|
|
|
|
|
|
|
|
s->scale_x = 1.0;
|
|
|
|
s->scale_y = 1.0;
|
|
|
|
|
2013-02-28 15:10:02 +00:00
|
|
|
gd_update_windowsize(s);
|
2013-02-20 13:43:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gd_menu_zoom_fit(GtkMenuItem *item, void *opaque)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = opaque;
|
|
|
|
|
|
|
|
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(s->zoom_fit_item))) {
|
|
|
|
s->free_scale = TRUE;
|
|
|
|
} else {
|
|
|
|
s->free_scale = FALSE;
|
2013-06-03 20:36:51 +00:00
|
|
|
s->scale_x = 1.0;
|
|
|
|
s->scale_y = 1.0;
|
|
|
|
gd_update_windowsize(s);
|
2013-02-20 13:43:23 +00:00
|
|
|
}
|
|
|
|
|
2013-02-28 15:10:02 +00:00
|
|
|
gd_update_full_redraw(s);
|
2013-02-20 13:43:23 +00:00
|
|
|
}
|
|
|
|
|
2013-02-20 13:43:22 +00:00
|
|
|
static void gd_grab_keyboard(GtkDisplayState *s)
|
|
|
|
{
|
2013-02-25 15:20:36 +00:00
|
|
|
#if GTK_CHECK_VERSION(3, 0, 0)
|
|
|
|
GdkDisplay *display = gtk_widget_get_display(s->drawing_area);
|
|
|
|
GdkDeviceManager *mgr = gdk_display_get_device_manager(display);
|
|
|
|
GList *devices = gdk_device_manager_list_devices(mgr,
|
|
|
|
GDK_DEVICE_TYPE_MASTER);
|
|
|
|
GList *tmp = devices;
|
|
|
|
while (tmp) {
|
|
|
|
GdkDevice *dev = tmp->data;
|
|
|
|
if (gdk_device_get_source(dev) == GDK_SOURCE_KEYBOARD) {
|
|
|
|
gdk_device_grab(dev,
|
|
|
|
gtk_widget_get_window(s->drawing_area),
|
|
|
|
GDK_OWNERSHIP_NONE,
|
|
|
|
FALSE,
|
|
|
|
GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
|
|
|
|
NULL,
|
|
|
|
GDK_CURRENT_TIME);
|
|
|
|
}
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
g_list_free(devices);
|
|
|
|
#else
|
|
|
|
gdk_keyboard_grab(gtk_widget_get_window(s->drawing_area),
|
2013-02-20 13:43:22 +00:00
|
|
|
FALSE,
|
|
|
|
GDK_CURRENT_TIME);
|
2013-02-25 15:20:36 +00:00
|
|
|
#endif
|
2013-02-20 13:43:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gd_ungrab_keyboard(GtkDisplayState *s)
|
|
|
|
{
|
2013-02-25 15:20:36 +00:00
|
|
|
#if GTK_CHECK_VERSION(3, 0, 0)
|
|
|
|
GdkDisplay *display = gtk_widget_get_display(s->drawing_area);
|
|
|
|
GdkDeviceManager *mgr = gdk_display_get_device_manager(display);
|
|
|
|
GList *devices = gdk_device_manager_list_devices(mgr,
|
|
|
|
GDK_DEVICE_TYPE_MASTER);
|
|
|
|
GList *tmp = devices;
|
|
|
|
while (tmp) {
|
|
|
|
GdkDevice *dev = tmp->data;
|
|
|
|
if (gdk_device_get_source(dev) == GDK_SOURCE_KEYBOARD) {
|
|
|
|
gdk_device_ungrab(dev,
|
|
|
|
GDK_CURRENT_TIME);
|
|
|
|
}
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
g_list_free(devices);
|
|
|
|
#else
|
2013-02-20 13:43:22 +00:00
|
|
|
gdk_keyboard_ungrab(GDK_CURRENT_TIME);
|
2013-02-25 15:20:36 +00:00
|
|
|
#endif
|
2013-02-20 13:43:22 +00:00
|
|
|
}
|
|
|
|
|
2013-02-25 15:20:37 +00:00
|
|
|
static void gd_grab_pointer(GtkDisplayState *s)
|
|
|
|
{
|
|
|
|
#if GTK_CHECK_VERSION(3, 0, 0)
|
|
|
|
GdkDisplay *display = gtk_widget_get_display(s->drawing_area);
|
|
|
|
GdkDeviceManager *mgr = gdk_display_get_device_manager(display);
|
|
|
|
GList *devices = gdk_device_manager_list_devices(mgr,
|
|
|
|
GDK_DEVICE_TYPE_MASTER);
|
|
|
|
GList *tmp = devices;
|
|
|
|
while (tmp) {
|
|
|
|
GdkDevice *dev = tmp->data;
|
|
|
|
if (gdk_device_get_source(dev) == GDK_SOURCE_MOUSE) {
|
|
|
|
gdk_device_grab(dev,
|
|
|
|
gtk_widget_get_window(s->drawing_area),
|
|
|
|
GDK_OWNERSHIP_NONE,
|
|
|
|
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,
|
|
|
|
s->null_cursor,
|
|
|
|
GDK_CURRENT_TIME);
|
|
|
|
}
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
g_list_free(devices);
|
|
|
|
#else
|
|
|
|
gdk_pointer_grab(gtk_widget_get_window(s->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 */
|
|
|
|
s->null_cursor,
|
|
|
|
GDK_CURRENT_TIME);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gd_ungrab_pointer(GtkDisplayState *s)
|
|
|
|
{
|
|
|
|
#if GTK_CHECK_VERSION(3, 0, 0)
|
|
|
|
GdkDisplay *display = gtk_widget_get_display(s->drawing_area);
|
|
|
|
GdkDeviceManager *mgr = gdk_display_get_device_manager(display);
|
|
|
|
GList *devices = gdk_device_manager_list_devices(mgr,
|
|
|
|
GDK_DEVICE_TYPE_MASTER);
|
|
|
|
GList *tmp = devices;
|
|
|
|
while (tmp) {
|
|
|
|
GdkDevice *dev = tmp->data;
|
|
|
|
if (gdk_device_get_source(dev) == GDK_SOURCE_MOUSE) {
|
|
|
|
gdk_device_ungrab(dev,
|
|
|
|
GDK_CURRENT_TIME);
|
|
|
|
}
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
g_list_free(devices);
|
|
|
|
#else
|
|
|
|
gdk_pointer_ungrab(GDK_CURRENT_TIME);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-02-20 13:43:22 +00:00
|
|
|
static void gd_menu_grab_input(GtkMenuItem *item, void *opaque)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = opaque;
|
|
|
|
|
|
|
|
if (gd_is_grab_active(s)) {
|
|
|
|
gd_grab_keyboard(s);
|
2013-02-25 15:20:37 +00:00
|
|
|
gd_grab_pointer(s);
|
2013-02-20 13:43:22 +00:00
|
|
|
} else {
|
|
|
|
gd_ungrab_keyboard(s);
|
2013-02-25 15:20:37 +00:00
|
|
|
gd_ungrab_pointer(s);
|
2013-02-20 13:43:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gd_update_caption(s);
|
|
|
|
gd_update_cursor(s, FALSE);
|
|
|
|
}
|
|
|
|
|
2013-02-20 13:43:20 +00:00
|
|
|
static void gd_change_page(GtkNotebook *nb, gpointer arg1, guint arg2,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = data;
|
2013-02-20 13:43:21 +00:00
|
|
|
guint last_page;
|
2013-02-20 13:43:22 +00:00
|
|
|
gboolean on_vga;
|
2013-02-20 13:43:20 +00:00
|
|
|
|
|
|
|
if (!gtk_widget_get_realized(s->notebook)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-02-20 13:43:21 +00:00
|
|
|
last_page = gtk_notebook_get_current_page(nb);
|
|
|
|
|
|
|
|
if (last_page) {
|
|
|
|
gtk_widget_set_size_request(s->vc[last_page - 1].terminal, -1, -1);
|
|
|
|
}
|
|
|
|
|
2013-02-20 13:43:22 +00:00
|
|
|
on_vga = arg2 == 0;
|
|
|
|
|
|
|
|
if (!on_vga) {
|
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
|
|
|
|
FALSE);
|
2013-02-20 13:43:23 +00:00
|
|
|
} else if (s->full_screen) {
|
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
|
|
|
|
TRUE);
|
2013-02-20 13:43:22 +00:00
|
|
|
}
|
|
|
|
|
2013-02-20 13:43:21 +00:00
|
|
|
if (arg2 == 0) {
|
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->vga_item), TRUE);
|
|
|
|
} else {
|
|
|
|
VirtualConsole *vc = &s->vc[arg2 - 1];
|
|
|
|
VteTerminal *term = VTE_TERMINAL(vc->terminal);
|
|
|
|
int width, height;
|
|
|
|
|
|
|
|
width = 80 * vte_terminal_get_char_width(term);
|
|
|
|
height = 25 * vte_terminal_get_char_height(term);
|
|
|
|
|
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(vc->menu_item), TRUE);
|
|
|
|
gtk_widget_set_size_request(vc->terminal, width, height);
|
|
|
|
}
|
|
|
|
|
2013-02-20 13:43:22 +00:00
|
|
|
gtk_widget_set_sensitive(s->grab_item, on_vga);
|
|
|
|
|
2013-02-20 13:43:20 +00:00
|
|
|
gd_update_cursor(s, TRUE);
|
|
|
|
}
|
|
|
|
|
2013-02-20 13:43:22 +00:00
|
|
|
static gboolean gd_enter_event(GtkWidget *widget, GdkEventCrossing *crossing, gpointer data)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = data;
|
|
|
|
|
|
|
|
if (!gd_is_grab_active(s) && gd_grab_on_hover(s)) {
|
|
|
|
gd_grab_keyboard(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean gd_leave_event(GtkWidget *widget, GdkEventCrossing *crossing, gpointer data)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = data;
|
|
|
|
|
|
|
|
if (!gd_is_grab_active(s) && gd_grab_on_hover(s)) {
|
|
|
|
gd_ungrab_keyboard(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-03-24 18:10:02 +00:00
|
|
|
static gboolean gd_focus_out_event(GtkWidget *widget,
|
|
|
|
GdkEventCrossing *crossing, gpointer data)
|
|
|
|
{
|
|
|
|
GtkDisplayState *s = data;
|
|
|
|
|
|
|
|
gtk_release_modifiers(s);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-02-20 13:43:21 +00:00
|
|
|
/** Virtual Console Callbacks **/
|
|
|
|
|
|
|
|
static int gd_vc_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
|
|
|
|
{
|
|
|
|
VirtualConsole *vc = chr->opaque;
|
|
|
|
|
|
|
|
return write(vc->fd, buf, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nb_vcs;
|
|
|
|
static CharDriverState *vcs[MAX_VCS];
|
|
|
|
|
2013-02-25 14:52:32 +00:00
|
|
|
static CharDriverState *gd_vc_handler(ChardevVC *unused)
|
2013-02-20 13:43:21 +00:00
|
|
|
{
|
|
|
|
CharDriverState *chr;
|
|
|
|
|
|
|
|
chr = g_malloc0(sizeof(*chr));
|
|
|
|
chr->chr_write = gd_vc_chr_write;
|
qemu-char: don't issue CHR_EVENT_OPEN in a BH
When CHR_EVENT_OPENED was initially added, it was CHR_EVENT_RESET,
and it was issued as a bottom-half:
86e94dea5b740dad65446c857f6959eae43e0ba6
Which we basically used to print out a greeting/prompt for the
monitor.
AFAICT the only reason this was ever done in a BH was because in
some cases we'd modify the chr_write handler for a new chardev
backend *after* the site where we issued the reset (see:
86e94d:qemu_chr_open_stdio())
At some point this event was renamed to CHR_EVENT_OPENED, and we've
maintained the use of this BH ever since.
However, due to 9f939df955a4152aad69a19a77e0898631bb2c18, we schedule
the BH via g_idle_add(), which is causing events to sometimes be
delivered after we've already begun processing data from backends,
leading to:
known bugs:
QMP:
session negotation resets with OPENED event, in some cases this
is causing new sessions to get sporadically reset
potential bugs:
hw/usb/redirect.c:
can_read handler checks for dev->parser != NULL, which may be
true if CLOSED BH has not been executed yet. In the past, OPENED
quiesced outstanding CLOSED events prior to us reading client
data. If it's delayed, our check may allow reads to occur even
though we haven't processed the OPENED event yet, and when we
do finally get the OPENED event, our state may get reset.
qtest.c:
can begin session before OPENED event is processed, leading to
a spurious reset of the system and irq_levels
gdbstub.c:
may start a gdb session prior to the machine being paused
To fix these, let's just drop the BH.
Since the initial reasoning for using it still applies to an extent,
work around that by deferring the delivery of CHR_EVENT_OPENED until
after the chardevs have been fully initialized, toward the end of
qmp_chardev_add() (or some cases, qemu_chr_new_from_opts()). This
defers delivery long enough that we can be assured a CharDriverState
is fully initialized before CHR_EVENT_OPENED is sent.
Also, rather than requiring each chardev to do an explicit open, do it
automatically, and allow the small few who don't desire such behavior to
suppress the OPENED-on-init behavior by setting a 'explicit_be_open'
flag.
We additionally add missing OPENED events for stdio backends on w32,
which were previously not being issued, causing us to not recieve the
banner and initial prompts for qmp/hmp.
Reported-by: Stefan Priebe <s.priebe@profihost.ag>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Message-id: 1370636393-21044-1-git-send-email-mdroth@linux.vnet.ibm.com
Cc: qemu-stable@nongnu.org
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-06-07 20:19:53 +00:00
|
|
|
/* defer OPENED events until our vc is fully initialized */
|
|
|
|
chr->explicit_be_open = true;
|
2013-02-20 13:43:21 +00:00
|
|
|
|
|
|
|
vcs[nb_vcs++] = chr;
|
|
|
|
|
|
|
|
return chr;
|
|
|
|
}
|
|
|
|
|
2013-02-20 13:43:20 +00:00
|
|
|
void early_gtk_display_init(void)
|
|
|
|
{
|
2013-02-20 13:43:21 +00:00
|
|
|
register_vc_handler(gd_vc_handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean gd_vc_in(GIOChannel *chan, GIOCondition cond, void *opaque)
|
|
|
|
{
|
|
|
|
VirtualConsole *vc = opaque;
|
|
|
|
uint8_t buffer[1024];
|
|
|
|
ssize_t len;
|
|
|
|
|
|
|
|
len = read(vc->fd, buffer, sizeof(buffer));
|
|
|
|
if (len <= 0) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
qemu_chr_be_write(vc->chr, buffer, len);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-04-26 13:48:46 +00:00
|
|
|
static GSList *gd_vc_init(GtkDisplayState *s, VirtualConsole *vc, int index, GSList *group,
|
|
|
|
GtkWidget *view_menu)
|
2013-02-20 13:43:21 +00:00
|
|
|
{
|
|
|
|
const char *label;
|
|
|
|
char buffer[32];
|
|
|
|
char path[32];
|
2013-02-22 19:09:59 +00:00
|
|
|
#if VTE_CHECK_VERSION(0, 26, 0)
|
2013-02-20 13:43:21 +00:00
|
|
|
VtePty *pty;
|
2013-02-22 19:09:59 +00:00
|
|
|
#endif
|
2013-02-20 13:43:21 +00:00
|
|
|
GIOChannel *chan;
|
|
|
|
GtkWidget *scrolled_window;
|
|
|
|
GtkAdjustment *vadjustment;
|
2013-06-05 14:44:54 +00:00
|
|
|
int master_fd, slave_fd;
|
2013-02-20 13:43:21 +00:00
|
|
|
|
|
|
|
snprintf(buffer, sizeof(buffer), "vc%d", index);
|
|
|
|
snprintf(path, sizeof(path), "<QEMU>/View/VC%d", index);
|
|
|
|
|
|
|
|
vc->chr = vcs[index];
|
|
|
|
|
|
|
|
if (vc->chr->label) {
|
|
|
|
label = vc->chr->label;
|
|
|
|
} else {
|
|
|
|
label = buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
vc->menu_item = gtk_radio_menu_item_new_with_mnemonic(group, label);
|
|
|
|
group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(vc->menu_item));
|
|
|
|
gtk_menu_item_set_accel_path(GTK_MENU_ITEM(vc->menu_item), path);
|
2013-07-22 07:04:32 +00:00
|
|
|
gtk_accel_map_add_entry(path, GDK_KEY_2 + index, HOTKEY_MODIFIERS);
|
2013-02-20 13:43:21 +00:00
|
|
|
|
|
|
|
vc->terminal = vte_terminal_new();
|
|
|
|
|
2013-06-05 14:44:54 +00:00
|
|
|
master_fd = qemu_openpty_raw(&slave_fd, NULL);
|
|
|
|
g_assert(master_fd != -1);
|
2013-02-20 13:43:21 +00:00
|
|
|
|
2013-02-22 19:09:59 +00:00
|
|
|
#if VTE_CHECK_VERSION(0, 26, 0)
|
2013-02-20 13:43:21 +00:00
|
|
|
pty = vte_pty_new_foreign(master_fd, NULL);
|
|
|
|
vte_terminal_set_pty_object(VTE_TERMINAL(vc->terminal), pty);
|
2013-02-22 19:09:59 +00:00
|
|
|
#else
|
|
|
|
vte_terminal_set_pty(VTE_TERMINAL(vc->terminal), master_fd);
|
|
|
|
#endif
|
2013-02-20 13:43:21 +00:00
|
|
|
|
|
|
|
vte_terminal_set_scrollback_lines(VTE_TERMINAL(vc->terminal), -1);
|
|
|
|
|
|
|
|
vadjustment = vte_terminal_get_adjustment(VTE_TERMINAL(vc->terminal));
|
|
|
|
|
|
|
|
scrolled_window = gtk_scrolled_window_new(NULL, vadjustment);
|
|
|
|
gtk_container_add(GTK_CONTAINER(scrolled_window), vc->terminal);
|
|
|
|
|
|
|
|
vte_terminal_set_size(VTE_TERMINAL(vc->terminal), 80, 25);
|
|
|
|
|
|
|
|
vc->fd = slave_fd;
|
|
|
|
vc->chr->opaque = vc;
|
|
|
|
vc->scrolled_window = scrolled_window;
|
|
|
|
|
|
|
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(vc->scrolled_window),
|
|
|
|
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
|
|
|
|
|
|
|
gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), scrolled_window, gtk_label_new(label));
|
|
|
|
g_signal_connect(vc->menu_item, "activate",
|
|
|
|
G_CALLBACK(gd_menu_switch_vc), s);
|
|
|
|
|
2013-04-26 13:48:46 +00:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), vc->menu_item);
|
2013-02-20 13:43:21 +00:00
|
|
|
|
2013-03-26 10:07:54 +00:00
|
|
|
qemu_chr_be_generic_open(vc->chr);
|
2013-02-20 13:43:21 +00:00
|
|
|
if (vc->chr->init) {
|
|
|
|
vc->chr->init(vc->chr);
|
|
|
|
}
|
|
|
|
|
|
|
|
chan = g_io_channel_unix_new(vc->fd);
|
|
|
|
g_io_add_watch(chan, G_IO_IN, gd_vc_in, vc);
|
|
|
|
|
|
|
|
return group;
|
2013-02-20 13:43:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Window Creation **/
|
|
|
|
|
|
|
|
static void gd_connect_signals(GtkDisplayState *s)
|
|
|
|
{
|
|
|
|
g_signal_connect(s->show_tabs_item, "activate",
|
|
|
|
G_CALLBACK(gd_menu_show_tabs), s);
|
|
|
|
|
2013-02-20 13:43:26 +00:00
|
|
|
g_signal_connect(s->window, "key-press-event",
|
|
|
|
G_CALLBACK(gd_window_key_event), s);
|
2013-02-20 13:43:20 +00:00
|
|
|
g_signal_connect(s->window, "delete-event",
|
|
|
|
G_CALLBACK(gd_window_close), s);
|
|
|
|
|
2013-02-25 15:20:42 +00:00
|
|
|
#if GTK_CHECK_VERSION(3, 0, 0)
|
|
|
|
g_signal_connect(s->drawing_area, "draw",
|
|
|
|
G_CALLBACK(gd_draw_event), s);
|
|
|
|
#else
|
2013-02-20 13:43:20 +00:00
|
|
|
g_signal_connect(s->drawing_area, "expose-event",
|
|
|
|
G_CALLBACK(gd_expose_event), s);
|
2013-02-25 15:20:42 +00:00
|
|
|
#endif
|
2013-02-20 13:43:20 +00:00
|
|
|
g_signal_connect(s->drawing_area, "motion-notify-event",
|
|
|
|
G_CALLBACK(gd_motion_event), s);
|
|
|
|
g_signal_connect(s->drawing_area, "button-press-event",
|
|
|
|
G_CALLBACK(gd_button_event), s);
|
|
|
|
g_signal_connect(s->drawing_area, "button-release-event",
|
|
|
|
G_CALLBACK(gd_button_event), s);
|
2014-03-11 16:26:44 +00:00
|
|
|
g_signal_connect(s->drawing_area, "scroll-event",
|
|
|
|
G_CALLBACK(gd_scroll_event), s);
|
2013-02-20 13:43:20 +00:00
|
|
|
g_signal_connect(s->drawing_area, "key-press-event",
|
|
|
|
G_CALLBACK(gd_key_event), s);
|
|
|
|
g_signal_connect(s->drawing_area, "key-release-event",
|
|
|
|
G_CALLBACK(gd_key_event), s);
|
|
|
|
|
2013-02-22 19:53:33 +00:00
|
|
|
g_signal_connect(s->pause_item, "activate",
|
|
|
|
G_CALLBACK(gd_menu_pause), s);
|
|
|
|
g_signal_connect(s->reset_item, "activate",
|
|
|
|
G_CALLBACK(gd_menu_reset), s);
|
|
|
|
g_signal_connect(s->powerdown_item, "activate",
|
|
|
|
G_CALLBACK(gd_menu_powerdown), s);
|
2013-02-20 13:43:20 +00:00
|
|
|
g_signal_connect(s->quit_item, "activate",
|
|
|
|
G_CALLBACK(gd_menu_quit), s);
|
2013-02-20 13:43:23 +00:00
|
|
|
g_signal_connect(s->full_screen_item, "activate",
|
|
|
|
G_CALLBACK(gd_menu_full_screen), s);
|
|
|
|
g_signal_connect(s->zoom_in_item, "activate",
|
|
|
|
G_CALLBACK(gd_menu_zoom_in), s);
|
|
|
|
g_signal_connect(s->zoom_out_item, "activate",
|
|
|
|
G_CALLBACK(gd_menu_zoom_out), s);
|
|
|
|
g_signal_connect(s->zoom_fixed_item, "activate",
|
|
|
|
G_CALLBACK(gd_menu_zoom_fixed), s);
|
|
|
|
g_signal_connect(s->zoom_fit_item, "activate",
|
|
|
|
G_CALLBACK(gd_menu_zoom_fit), s);
|
2013-02-20 13:43:20 +00:00
|
|
|
g_signal_connect(s->vga_item, "activate",
|
|
|
|
G_CALLBACK(gd_menu_switch_vc), s);
|
2013-02-20 13:43:22 +00:00
|
|
|
g_signal_connect(s->grab_item, "activate",
|
|
|
|
G_CALLBACK(gd_menu_grab_input), s);
|
2013-02-20 13:43:20 +00:00
|
|
|
g_signal_connect(s->notebook, "switch-page",
|
|
|
|
G_CALLBACK(gd_change_page), s);
|
2013-02-20 13:43:22 +00:00
|
|
|
g_signal_connect(s->drawing_area, "enter-notify-event",
|
|
|
|
G_CALLBACK(gd_enter_event), s);
|
|
|
|
g_signal_connect(s->drawing_area, "leave-notify-event",
|
|
|
|
G_CALLBACK(gd_leave_event), s);
|
2013-03-24 18:10:02 +00:00
|
|
|
g_signal_connect(s->drawing_area, "focus-out-event",
|
|
|
|
G_CALLBACK(gd_focus_out_event), s);
|
2013-02-20 13:43:20 +00:00
|
|
|
}
|
|
|
|
|
2013-04-26 13:48:46 +00:00
|
|
|
static GtkWidget *gd_create_menu_machine(GtkDisplayState *s, GtkAccelGroup *accel_group)
|
2013-02-20 13:43:20 +00:00
|
|
|
{
|
2013-04-26 13:48:46 +00:00
|
|
|
GtkWidget *machine_menu;
|
2013-02-20 13:43:20 +00:00
|
|
|
GtkWidget *separator;
|
2013-04-26 13:48:46 +00:00
|
|
|
GtkStockItem item;
|
2013-02-20 13:43:20 +00:00
|
|
|
|
2013-04-26 13:48:46 +00:00
|
|
|
machine_menu = gtk_menu_new();
|
|
|
|
gtk_menu_set_accel_group(GTK_MENU(machine_menu), accel_group);
|
2013-02-22 19:53:33 +00:00
|
|
|
|
|
|
|
s->pause_item = gtk_check_menu_item_new_with_mnemonic(_("_Pause"));
|
2013-04-26 13:48:46 +00:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(machine_menu), s->pause_item);
|
2013-02-22 19:53:33 +00:00
|
|
|
|
|
|
|
separator = gtk_separator_menu_item_new();
|
2013-04-26 13:48:46 +00:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(machine_menu), separator);
|
2013-02-22 19:53:33 +00:00
|
|
|
|
|
|
|
s->reset_item = gtk_image_menu_item_new_with_mnemonic(_("_Reset"));
|
2013-04-26 13:48:46 +00:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(machine_menu), s->reset_item);
|
2013-02-22 19:53:33 +00:00
|
|
|
|
|
|
|
s->powerdown_item = gtk_image_menu_item_new_with_mnemonic(_("Power _Down"));
|
2013-04-26 13:48:46 +00:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(machine_menu), s->powerdown_item);
|
2013-02-22 19:53:33 +00:00
|
|
|
|
|
|
|
separator = gtk_separator_menu_item_new();
|
2013-04-26 13:48:46 +00:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(machine_menu), separator);
|
2013-02-20 13:43:20 +00:00
|
|
|
|
|
|
|
s->quit_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL);
|
|
|
|
gtk_stock_lookup(GTK_STOCK_QUIT, &item);
|
|
|
|
gtk_menu_item_set_accel_path(GTK_MENU_ITEM(s->quit_item),
|
2013-02-22 19:53:33 +00:00
|
|
|
"<QEMU>/Machine/Quit");
|
|
|
|
gtk_accel_map_add_entry("<QEMU>/Machine/Quit", item.keyval, item.modifier);
|
2013-04-26 13:48:46 +00:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(machine_menu), s->quit_item);
|
2013-02-20 13:43:20 +00:00
|
|
|
|
2013-04-26 13:48:46 +00:00
|
|
|
return machine_menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *gd_create_menu_view(GtkDisplayState *s, GtkAccelGroup *accel_group)
|
|
|
|
{
|
|
|
|
GSList *group = NULL;
|
|
|
|
GtkWidget *view_menu;
|
|
|
|
GtkWidget *separator;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
view_menu = gtk_menu_new();
|
|
|
|
gtk_menu_set_accel_group(GTK_MENU(view_menu), accel_group);
|
2013-02-20 13:43:20 +00:00
|
|
|
|
2013-02-22 19:33:34 +00:00
|
|
|
s->full_screen_item =
|
|
|
|
gtk_image_menu_item_new_from_stock(GTK_STOCK_FULLSCREEN, NULL);
|
2013-02-20 13:43:23 +00:00
|
|
|
gtk_menu_item_set_accel_path(GTK_MENU_ITEM(s->full_screen_item),
|
|
|
|
"<QEMU>/View/Full Screen");
|
2013-07-22 07:04:32 +00:00
|
|
|
gtk_accel_map_add_entry("<QEMU>/View/Full Screen", GDK_KEY_f,
|
|
|
|
HOTKEY_MODIFIERS);
|
2013-04-26 13:48:46 +00:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->full_screen_item);
|
2013-02-20 13:43:23 +00:00
|
|
|
|
|
|
|
separator = gtk_separator_menu_item_new();
|
2013-04-26 13:48:46 +00:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), separator);
|
2013-02-20 13:43:23 +00:00
|
|
|
|
|
|
|
s->zoom_in_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_IN, NULL);
|
|
|
|
gtk_menu_item_set_accel_path(GTK_MENU_ITEM(s->zoom_in_item),
|
|
|
|
"<QEMU>/View/Zoom In");
|
2013-07-22 07:04:32 +00:00
|
|
|
gtk_accel_map_add_entry("<QEMU>/View/Zoom In", GDK_KEY_plus,
|
|
|
|
HOTKEY_MODIFIERS);
|
2013-04-26 13:48:46 +00:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->zoom_in_item);
|
2013-02-20 13:43:23 +00:00
|
|
|
|
|
|
|
s->zoom_out_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_OUT, NULL);
|
|
|
|
gtk_menu_item_set_accel_path(GTK_MENU_ITEM(s->zoom_out_item),
|
|
|
|
"<QEMU>/View/Zoom Out");
|
2013-07-22 07:04:32 +00:00
|
|
|
gtk_accel_map_add_entry("<QEMU>/View/Zoom Out", GDK_KEY_minus,
|
|
|
|
HOTKEY_MODIFIERS);
|
2013-04-26 13:48:46 +00:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->zoom_out_item);
|
2013-02-20 13:43:23 +00:00
|
|
|
|
|
|
|
s->zoom_fixed_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_100, NULL);
|
|
|
|
gtk_menu_item_set_accel_path(GTK_MENU_ITEM(s->zoom_fixed_item),
|
|
|
|
"<QEMU>/View/Zoom Fixed");
|
2013-07-22 07:04:32 +00:00
|
|
|
gtk_accel_map_add_entry("<QEMU>/View/Zoom Fixed", GDK_KEY_0,
|
|
|
|
HOTKEY_MODIFIERS);
|
2013-04-26 13:48:46 +00:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->zoom_fixed_item);
|
2013-02-20 13:43:23 +00:00
|
|
|
|
2013-02-20 13:43:24 +00:00
|
|
|
s->zoom_fit_item = gtk_check_menu_item_new_with_mnemonic(_("Zoom To _Fit"));
|
2013-04-26 13:48:46 +00:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->zoom_fit_item);
|
2013-02-20 13:43:23 +00:00
|
|
|
|
|
|
|
separator = gtk_separator_menu_item_new();
|
2013-04-26 13:48:46 +00:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), separator);
|
2013-02-20 13:43:23 +00:00
|
|
|
|
2013-02-20 13:43:24 +00:00
|
|
|
s->grab_on_hover_item = gtk_check_menu_item_new_with_mnemonic(_("Grab On _Hover"));
|
2013-04-26 13:48:46 +00:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->grab_on_hover_item);
|
2013-02-20 13:43:22 +00:00
|
|
|
|
2013-02-20 13:43:24 +00:00
|
|
|
s->grab_item = gtk_check_menu_item_new_with_mnemonic(_("_Grab Input"));
|
2013-02-20 13:43:22 +00:00
|
|
|
gtk_menu_item_set_accel_path(GTK_MENU_ITEM(s->grab_item),
|
|
|
|
"<QEMU>/View/Grab Input");
|
2013-07-22 07:04:32 +00:00
|
|
|
gtk_accel_map_add_entry("<QEMU>/View/Grab Input", GDK_KEY_g,
|
|
|
|
HOTKEY_MODIFIERS);
|
2013-04-26 13:48:46 +00:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->grab_item);
|
2013-02-20 13:43:22 +00:00
|
|
|
|
2013-02-20 13:43:20 +00:00
|
|
|
separator = gtk_separator_menu_item_new();
|
2013-04-26 13:48:46 +00:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), separator);
|
2013-02-20 13:43:20 +00:00
|
|
|
|
|
|
|
s->vga_item = gtk_radio_menu_item_new_with_mnemonic(group, "_VGA");
|
|
|
|
group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(s->vga_item));
|
|
|
|
gtk_menu_item_set_accel_path(GTK_MENU_ITEM(s->vga_item),
|
|
|
|
"<QEMU>/View/VGA");
|
2013-07-22 07:04:32 +00:00
|
|
|
gtk_accel_map_add_entry("<QEMU>/View/VGA", GDK_KEY_1, HOTKEY_MODIFIERS);
|
2013-04-26 13:48:46 +00:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->vga_item);
|
2013-02-20 13:43:20 +00:00
|
|
|
|
2013-02-20 13:43:21 +00:00
|
|
|
for (i = 0; i < nb_vcs; i++) {
|
|
|
|
VirtualConsole *vc = &s->vc[i];
|
|
|
|
|
2013-04-26 13:48:46 +00:00
|
|
|
group = gd_vc_init(s, vc, i, group, view_menu);
|
2013-02-20 13:43:21 +00:00
|
|
|
s->nb_vcs++;
|
|
|
|
}
|
|
|
|
|
2013-02-20 13:43:20 +00:00
|
|
|
separator = gtk_separator_menu_item_new();
|
2013-04-26 13:48:46 +00:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), separator);
|
2013-02-20 13:43:20 +00:00
|
|
|
|
2013-02-20 13:43:24 +00:00
|
|
|
s->show_tabs_item = gtk_check_menu_item_new_with_mnemonic(_("Show _Tabs"));
|
2013-04-26 13:48:46 +00:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->show_tabs_item);
|
2013-02-20 13:43:20 +00:00
|
|
|
|
2013-04-26 13:48:46 +00:00
|
|
|
return view_menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gd_create_menus(GtkDisplayState *s)
|
|
|
|
{
|
|
|
|
GtkAccelGroup *accel_group;
|
2013-02-20 13:43:20 +00:00
|
|
|
|
2013-04-26 13:48:46 +00:00
|
|
|
accel_group = gtk_accel_group_new();
|
|
|
|
s->machine_menu = gd_create_menu_machine(s, accel_group);
|
|
|
|
s->view_menu = gd_create_menu_view(s, accel_group);
|
|
|
|
|
|
|
|
s->machine_menu_item = gtk_menu_item_new_with_mnemonic(_("_Machine"));
|
2013-02-22 19:53:33 +00:00
|
|
|
gtk_menu_item_set_submenu(GTK_MENU_ITEM(s->machine_menu_item),
|
|
|
|
s->machine_menu);
|
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(s->menu_bar), s->machine_menu_item);
|
2013-02-20 13:43:20 +00:00
|
|
|
|
2013-04-26 13:48:46 +00:00
|
|
|
s->view_menu_item = gtk_menu_item_new_with_mnemonic(_("_View"));
|
2013-02-20 13:43:20 +00:00
|
|
|
gtk_menu_item_set_submenu(GTK_MENU_ITEM(s->view_menu_item), s->view_menu);
|
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(s->menu_bar), s->view_menu_item);
|
2013-04-26 13:48:46 +00:00
|
|
|
|
|
|
|
g_object_set_data(G_OBJECT(s->window), "accel_group", accel_group);
|
|
|
|
gtk_window_add_accel_group(GTK_WINDOW(s->window), accel_group);
|
|
|
|
s->accel_group = accel_group;
|
2013-02-20 13:43:20 +00:00
|
|
|
}
|
|
|
|
|
2012-11-13 13:51:41 +00:00
|
|
|
static const DisplayChangeListenerOps dcl_ops = {
|
|
|
|
.dpy_name = "gtk",
|
|
|
|
.dpy_gfx_update = gd_update,
|
2013-02-28 14:03:04 +00:00
|
|
|
.dpy_gfx_switch = gd_switch,
|
2012-11-13 13:51:41 +00:00
|
|
|
.dpy_refresh = gd_refresh,
|
2013-03-20 08:11:41 +00:00
|
|
|
.dpy_mouse_set = gd_mouse_set,
|
|
|
|
.dpy_cursor_define = gd_cursor_define,
|
2012-11-13 13:51:41 +00:00
|
|
|
};
|
|
|
|
|
2014-03-12 07:33:50 +00:00
|
|
|
void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
|
2013-02-20 13:43:20 +00:00
|
|
|
{
|
|
|
|
GtkDisplayState *s = g_malloc0(sizeof(*s));
|
2013-03-30 14:21:40 +00:00
|
|
|
char *filename;
|
2013-02-20 13:43:20 +00:00
|
|
|
|
|
|
|
gtk_init(NULL, NULL);
|
|
|
|
|
2012-11-13 13:51:41 +00:00
|
|
|
s->dcl.ops = &dcl_ops;
|
2013-03-15 14:45:54 +00:00
|
|
|
s->dcl.con = qemu_console_lookup_by_index(0);
|
2013-02-20 13:43:20 +00:00
|
|
|
|
|
|
|
s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
2013-02-25 15:20:38 +00:00
|
|
|
#if GTK_CHECK_VERSION(3, 2, 0)
|
|
|
|
s->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
|
|
|
|
#else
|
2013-02-20 13:43:20 +00:00
|
|
|
s->vbox = gtk_vbox_new(FALSE, 0);
|
2013-02-25 15:20:38 +00:00
|
|
|
#endif
|
2013-02-20 13:43:20 +00:00
|
|
|
s->notebook = gtk_notebook_new();
|
|
|
|
s->drawing_area = gtk_drawing_area_new();
|
|
|
|
s->menu_bar = gtk_menu_bar_new();
|
|
|
|
|
|
|
|
s->scale_x = 1.0;
|
|
|
|
s->scale_y = 1.0;
|
2013-02-20 13:43:23 +00:00
|
|
|
s->free_scale = FALSE;
|
2013-02-20 13:43:20 +00:00
|
|
|
|
2013-02-20 13:43:24 +00:00
|
|
|
setlocale(LC_ALL, "");
|
|
|
|
bindtextdomain("qemu", CONFIG_QEMU_LOCALEDIR);
|
|
|
|
textdomain("qemu");
|
|
|
|
|
2013-02-20 13:43:20 +00:00
|
|
|
s->null_cursor = gdk_cursor_new(GDK_BLANK_CURSOR);
|
|
|
|
|
|
|
|
s->mouse_mode_notifier.notify = gd_mouse_mode_change;
|
|
|
|
qemu_add_mouse_mode_change_notifier(&s->mouse_mode_notifier);
|
|
|
|
qemu_add_vm_change_state_handler(gd_change_runstate, s);
|
|
|
|
|
|
|
|
gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), s->drawing_area, gtk_label_new("VGA"));
|
|
|
|
|
2013-06-07 18:24:17 +00:00
|
|
|
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "qemu_logo_no_text.svg");
|
2013-03-30 14:21:40 +00:00
|
|
|
if (filename) {
|
|
|
|
GError *error = NULL;
|
|
|
|
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename, &error);
|
|
|
|
if (pixbuf) {
|
|
|
|
gtk_window_set_icon(GTK_WINDOW(s->window), pixbuf);
|
|
|
|
} else {
|
|
|
|
g_error_free(error);
|
|
|
|
}
|
|
|
|
g_free(filename);
|
|
|
|
}
|
|
|
|
|
2013-02-20 13:43:20 +00:00
|
|
|
gd_create_menus(s);
|
|
|
|
|
|
|
|
gd_connect_signals(s);
|
|
|
|
|
|
|
|
gtk_widget_add_events(s->drawing_area,
|
|
|
|
GDK_POINTER_MOTION_MASK |
|
|
|
|
GDK_BUTTON_PRESS_MASK |
|
|
|
|
GDK_BUTTON_RELEASE_MASK |
|
|
|
|
GDK_BUTTON_MOTION_MASK |
|
2013-02-20 13:43:22 +00:00
|
|
|
GDK_ENTER_NOTIFY_MASK |
|
|
|
|
GDK_LEAVE_NOTIFY_MASK |
|
2013-02-20 13:43:20 +00:00
|
|
|
GDK_SCROLL_MASK |
|
|
|
|
GDK_KEY_PRESS_MASK);
|
|
|
|
gtk_widget_set_double_buffered(s->drawing_area, FALSE);
|
|
|
|
gtk_widget_set_can_focus(s->drawing_area, TRUE);
|
|
|
|
|
|
|
|
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(s->notebook), FALSE);
|
|
|
|
gtk_notebook_set_show_border(GTK_NOTEBOOK(s->notebook), FALSE);
|
|
|
|
|
|
|
|
gd_update_caption(s);
|
|
|
|
|
|
|
|
gtk_box_pack_start(GTK_BOX(s->vbox), s->menu_bar, FALSE, TRUE, 0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(s->vbox), s->notebook, TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
gtk_container_add(GTK_CONTAINER(s->window), s->vbox);
|
|
|
|
|
|
|
|
gtk_widget_show_all(s->window);
|
|
|
|
|
2013-06-10 18:04:43 +00:00
|
|
|
if (full_screen) {
|
|
|
|
gtk_menu_item_activate(GTK_MENU_ITEM(s->full_screen_item));
|
|
|
|
}
|
2014-03-12 07:33:50 +00:00
|
|
|
if (grab_on_hover) {
|
|
|
|
gtk_menu_item_activate(GTK_MENU_ITEM(s->grab_on_hover_item));
|
|
|
|
}
|
2013-06-10 18:04:43 +00:00
|
|
|
|
2013-04-23 13:44:31 +00:00
|
|
|
register_displaychangelistener(&s->dcl);
|
2013-02-20 13:43:20 +00:00
|
|
|
|
|
|
|
global_state = s;
|
|
|
|
}
|