All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Samuel Thibault <samuel.thibault@ens-lyon.org>
Cc: qemu-devel@nongnu.org, kraxel@redhat.com
Subject: Re: [Qemu-devel] [PATCH 4/4] gtk: set window ID
Date: Mon, 31 Oct 2016 16:59:58 +0000	[thread overview]
Message-ID: <20161031165958.GA14901@redhat.com> (raw)
In-Reply-To: <20161031160007.6047-5-samuel.thibault@ens-lyon.org>

On Mon, Oct 31, 2016 at 05:00:07PM +0100, Samuel Thibault wrote:
> This uses the console API to record the window ID of the GTK windows.
> 
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> ---
>  ui/gtk.c | 25 +++++++++++++++++++++++--
>  1 file changed, 23 insertions(+), 2 deletions(-)
> 
> diff --git a/ui/gtk.c b/ui/gtk.c
> index ca737c4..d75f255 100644
> --- a/ui/gtk.c
> +++ b/ui/gtk.c
> @@ -2170,6 +2170,13 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
>      GtkDisplayState *s = g_malloc0(sizeof(*s));
>      char *filename;
>      GdkDisplay *window_display;
> +    GdkWindow *gdk_window;
> +#ifdef GDK_WINDOWING_X11
> +    Window window_id;
> +#elif defined(GDK_WINDOWING_WIN32)
> +    HWND window_id;
> +#endif
> +    int i;
>  
>      if (!gtkinit) {
>          fprintf(stderr, "gtk initialization failed\n");
> @@ -2232,8 +2239,6 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
>      {
>          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) {
> @@ -2253,6 +2258,22 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
>      }
>  
>      gd_set_keycode_type(s);
> +
> +    gdk_window = gtk_widget_get_window(s->window);
> +#ifdef GDK_WINDOWING_X11
> +    window_id = GDK_WINDOW_XID(gdk_window);
> +#elif defined(GDK_WINDOWING_WIN32)
> +    window_id = gdk_win32_window_get_impl_hwnd(gdk_window);
> +#endif

There are other GTK3 backends that may well be used - Wayland, Broadway
and Quartz. You can't use the compile time check on its own any more as
a single GTK can be built with multiple backends at once.

So to fully generalize you need
eg you'll need

    #ifdef GDK_WINDOWING_X11
    if (GDK_IS_X11_DISPLAY(dpy)) {
       ...
    }
    #endif

    #ifdef GDK_WINDOWING_WIN32
    if (GDK_IS_WIN32_DISPLAY(dpy)) {
       ...
    }
    #endif

    #ifdef GDK_WINDOWING_QUARTZ
    if (GDK_IS_QUARTZ_DISPLAY(dpy)) {
       ...
    }
    #endif

    ...and wayland, broadway...

> +    for (i = 0; ; i++) {
> +        /* All consoles share the same window */
> +        QemuConsole *con = qemu_console_lookup_by_index(i);
> +        if (con) {
> +            qemu_console_set_window_id(i, (int) window_id);
> +        } else {
> +            break;
> +        }
> +    }

If neither X11 or Win32 backends are defined, this will error
since window_id will not be declared.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|

      parent reply	other threads:[~2016-10-31 17:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-31 16:00 [Qemu-devel] [PATCHv3 0/4] Move getting XWindow ID from baum driver to graphical backend Samuel Thibault
2016-10-31 16:00 ` [Qemu-devel] [PATCH 1/4] console: add API to get underlying gui window ID Samuel Thibault
2016-11-01 10:11   ` Gerd Hoffmann
2016-10-31 16:00 ` [Qemu-devel] [PATCH 2/4] console: move window ID code from baum to sdl Samuel Thibault
2016-10-31 16:00 ` [Qemu-devel] [PATCH 3/4] sdl2: set window ID Samuel Thibault
2016-10-31 16:00 ` [Qemu-devel] [PATCH 4/4] gtk: " Samuel Thibault
2016-10-31 16:01   ` Samuel Thibault
2016-10-31 16:59   ` Daniel P. Berrange [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161031165958.GA14901@redhat.com \
    --to=berrange@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=samuel.thibault@ens-lyon.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.