Re: [spice-gtk] Use G_OS_WIN32 #define everywhere

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sounds good to me.  ACK.


On Wed, 2014-08-13 at 16:13 +0200, Christophe Fergeau wrote:
> Currently some parts of the windows specific code is checking for the
> WIN32 define, and other parts are checking G_OS_WIN32. This commit uses
> G_OS_WIN32 everywhere for consistency.
> ---
>  gtk/channel-display.c   |  8 ++++----
>  gtk/decode-jpeg.c       |  2 +-
>  gtk/spice-gtk-session.c |  6 ++++--
>  gtk/spice-widget.c      | 27 ++++++++++++++-------------
>  gtk/spicy.c             | 20 ++++++++++----------
>  5 files changed, 33 insertions(+), 30 deletions(-)
> 
> diff --git a/gtk/channel-display.c b/gtk/channel-display.c
> index 20dfe55..1e1312c 100644
> --- a/gtk/channel-display.c
> +++ b/gtk/channel-display.c
> @@ -81,7 +81,7 @@ struct _SpiceDisplayChannelPrivate {
>      GArray                      *monitors;
>      guint                       monitors_max;
>      gboolean                    enable_adaptive_streaming;
> -#ifdef WIN32
> +#ifdef G_OS_WIN32
>      HDC dc;
>  #endif
>  };
> @@ -575,7 +575,7 @@ static SpiceImageSurfacesOps image_surfaces_ops = {
>      .get = surfaces_get
>  };
>  
> -#if defined(WIN32)
> +#if defined(G_OS_WIN32)
>  static HDC create_compatible_dc(void)
>  {
>      HDC dc = CreateCompatibleDC(NULL);
> @@ -615,7 +615,7 @@ static void spice_display_channel_init(SpiceDisplayChannel *channel)
>      c->image_cache.ops = &image_cache_ops;
>      c->palette_cache.ops = &palette_cache_ops;
>      c->image_surfaces.ops = &image_surfaces_ops;
> -#if defined(WIN32)
> +#if defined(G_OS_WIN32)
>      c->dc = create_compatible_dc();
>  #endif
>      c->monitors_max = 1;
> @@ -1143,7 +1143,7 @@ static gboolean display_stream_render(display_stream *st)
>  
>              st->surface->canvas->ops->put_image(
>                  st->surface->canvas,
> -#ifdef WIN32
> +#ifdef G_OS_WIN32
>                  SPICE_DISPLAY_CHANNEL(st->channel)->priv->dc,
>  #endif
>                  dest, data,
> diff --git a/gtk/decode-jpeg.c b/gtk/decode-jpeg.c
> index db54a31..697d0de 100644
> --- a/gtk/decode-jpeg.c
> +++ b/gtk/decode-jpeg.c
> @@ -19,7 +19,7 @@
>  
>  #include "decode.h"
>  
> -#ifdef WIN32
> +#ifdef G_OS_WIN32
>  /* We need some hacks to avoid warnings from the jpeg headers, ex: */
>  /* #define HAVE_BOOLEAN */
>  #define XMD_H
> diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
> index abd39c7..8dd05f4 100644
> --- a/gtk/spice-gtk-session.c
> +++ b/gtk/spice-gtk-session.c
> @@ -17,6 +17,8 @@
>  */
>  #include "config.h"
>  
> +#include <glib.h>
> +
>  #if HAVE_X11_XKBLIB_H
>  #include <X11/XKBlib.h>
>  #include <gdk/gdkx.h>
> @@ -25,7 +27,7 @@
>  #include <X11/Xlib.h>
>  #include <gdk/gdkx.h>
>  #endif
> -#ifdef WIN32
> +#ifdef G_OS_WIN32
>  #include <windows.h>
>  #include <gdk/gdkwin32.h>
>  #ifndef MAPVK_VK_TO_VSC /* may be undefined in older mingw-headers */
> @@ -140,7 +142,7 @@ static guint32 get_keyboard_lock_modifiers(void)
>      if (keyboard_state.led_mask & 0x04) {
>          modifiers |= SPICE_INPUTS_SCROLL_LOCK;
>      }
> -#elif defined(WIN32)
> +#elif defined(G_OS_WIN32)
>      if (GetKeyState(VK_CAPITAL) & 1) {
>          modifiers |= SPICE_INPUTS_CAPS_LOCK;
>      }
> diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
> index b6bb0a9..1220030 100644
> --- a/gtk/spice-widget.c
> +++ b/gtk/spice-widget.c
> @@ -18,6 +18,7 @@
>  #include "config.h"
>  
>  #include <math.h>
> +#include <glib.h>
>  
>  #if HAVE_X11_XKBLIB_H
>  #include <X11/XKBlib.h>
> @@ -27,7 +28,7 @@
>  #include <X11/Xlib.h>
>  #include <gdk/gdkx.h>
>  #endif
> -#ifdef WIN32
> +#ifdef G_OS_WIN32
>  #include <windows.h>
>  #include <gdk/gdkwin32.h>
>  #ifndef MAPVK_VK_TO_VSC /* may be undefined in older mingw-headers */
> @@ -99,7 +100,7 @@ enum {
>  
>  static guint signals[SPICE_DISPLAY_LAST_SIGNAL];
>  
> -#ifdef WIN32
> +#ifdef G_OS_WIN32
>  static HWND win32_window = NULL;
>  #endif
>  
> @@ -639,7 +640,7 @@ void spice_display_set_grab_keys(SpiceDisplay *display, SpiceGrabSequence *seq)
>      d->activeseq = g_new0(gboolean, d->grabseq->nkeysyms);
>  }
>  
> -#ifdef WIN32
> +#ifdef G_OS_WIN32
>  static LRESULT CALLBACK keyboard_hook_cb(int code, WPARAM wparam, LPARAM lparam)
>  {
>      if  (win32_window && code == HC_ACTION && wparam != WM_KEYUP) {
> @@ -721,7 +722,7 @@ static void try_keyboard_grab(SpiceDisplay *display)
>      SPICE_DEBUG("grab keyboard");
>      gtk_widget_grab_focus(widget);
>  
> -#ifdef WIN32
> +#ifdef G_OS_WIN32
>      if (d->keyboard_hook == NULL)
>          d->keyboard_hook = SetWindowsHookEx(WH_KEYBOARD_LL, keyboard_hook_cb,
>                                              GetModuleHandle(NULL), 0);
> @@ -748,7 +749,7 @@ static void try_keyboard_ungrab(SpiceDisplay *display)
>  
>      SPICE_DEBUG("ungrab keyboard");
>      gdk_keyboard_ungrab(GDK_CURRENT_TIME);
> -#ifdef WIN32
> +#ifdef G_OS_WIN32
>      if (d->keyboard_hook != NULL) {
>          UnhookWindowsHookEx(d->keyboard_hook);
>          d->keyboard_hook = NULL;
> @@ -811,7 +812,7 @@ static void set_mouse_accel(SpiceDisplay *display, gboolean enabled)
>  #endif
>  }
>  
> -#ifdef WIN32
> +#ifdef G_OS_WIN32
>  static gboolean win32_clip_cursor(void)
>  {
>      RECT window, workarea, rect;
> @@ -865,7 +866,7 @@ static GdkGrabStatus do_pointer_grab(SpiceDisplay *display)
>      if (!gtk_widget_get_realized(GTK_WIDGET(display)))
>          goto end;
>  
> -#ifdef WIN32
> +#ifdef G_OS_WIN32
>      if (!win32_clip_cursor())
>          goto end;
>  #endif
> @@ -961,7 +962,7 @@ static void mouse_wrap(SpiceDisplay *display, GdkEventMotion *motion)
>      SpiceDisplayPrivate *d = display->priv;
>      gint xr, yr;
>  
> -#ifdef WIN32
> +#ifdef G_OS_WIN32
>      RECT clip;
>      g_return_if_fail(GetClipCursor(&clip));
>      xr = clip.left + (clip.right - clip.left) / 2;
> @@ -997,7 +998,7 @@ static void try_mouse_ungrab(SpiceDisplay *display)
>  
>      gdk_pointer_ungrab(GDK_CURRENT_TIME);
>      gtk_grab_remove(GTK_WIDGET(display));
> -#ifdef WIN32
> +#ifdef G_OS_WIN32
>      ClipCursor(NULL);
>  #endif
>      set_mouse_accel(display, TRUE);
> @@ -1276,7 +1277,7 @@ static gboolean check_for_grab_key(SpiceDisplay *display, int type, int keyval)
>  
>  static void update_display(SpiceDisplay *display)
>  {
> -#ifdef WIN32
> +#ifdef G_OS_WIN32
>      win32_window = display ? GDK_WINDOW_HWND(gtk_widget_get_window(GTK_WIDGET(display))) : NULL;
>  #endif
>  }
> @@ -1287,7 +1288,7 @@ static gboolean key_event(GtkWidget *widget, GdkEventKey *key)
>      SpiceDisplayPrivate *d = display->priv;
>      int scancode;
>  
> -#ifdef WIN32
> +#ifdef G_OS_WIN32
>      /* on windows, we ought to ignore the reserved key event? */
>      if (key->hardware_keycode == 0xff)
>          return false;
> @@ -1320,7 +1321,7 @@ static gboolean key_event(GtkWidget *widget, GdkEventKey *key)
>  
>      scancode = vnc_display_keymap_gdk2xtkbd(d->keycode_map, d->keycode_maplen,
>                                              key->hardware_keycode);
> -#ifdef WIN32
> +#ifdef G_OS_WIN32
>      /* MapVirtualKey doesn't return scancode with needed higher byte */
>      scancode = MapVirtualKey(key->hardware_keycode, MAPVK_VK_TO_VSC) |
>          (scancode & 0xff00);
> @@ -1686,7 +1687,7 @@ static gboolean configure_event(GtkWidget *widget, GdkEventConfigure *conf)
>      d->mx = conf->x;
>      d->my = conf->y;
>  
> -#ifdef WIN32
> +#ifdef G_OS_WIN32
>      if (d->mouse_grab_active) {
>          try_mouse_ungrab(display);
>          try_mouse_grab(display);
> diff --git a/gtk/spicy.c b/gtk/spicy.c
> index 57af34c..80d53b4 100644
> --- a/gtk/spicy.c
> +++ b/gtk/spicy.c
> @@ -73,7 +73,7 @@ struct _SpiceWindow {
>      bool             fullscreen;
>      bool             mouse_grabbed;
>      SpiceChannel     *display_channel;
> -#ifdef WIN32
> +#ifdef G_OS_WIN32
>      gint             win_x;
>      gint             win_y;
>  #endif
> @@ -185,7 +185,7 @@ static struct {
>      { .text = N_("TLS Port"),   .prop = "tls-port"  },
>  };
>  
> -#ifndef WIN32
> +#ifndef G_OS_WIN32
>  static void recent_selection_changed_dialog_cb(GtkRecentChooser *chooser, gpointer data)
>  {
>      GtkRecentInfo *info;
> @@ -264,7 +264,7 @@ static int connect_dialog(SpiceSession *session)
>      label = gtk_label_new("Recent connections:");
>      gtk_box_pack_start(GTK_BOX(area), label, TRUE, TRUE, 0);
>      gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
> -#ifndef WIN32
> +#ifndef G_OS_WIN32
>      GtkRecentFilter *rfilter;
>      GtkWidget *recent;
>  
> @@ -397,13 +397,13 @@ static void menu_cb_paste(GtkAction *action, void *data)
>  static void window_set_fullscreen(SpiceWindow *win, gboolean fs)
>  {
>      if (fs) {
> -#ifdef WIN32
> +#ifdef G_OS_WIN32
>          gtk_window_get_position(GTK_WINDOW(win->toplevel), &win->win_x, &win->win_y);
>  #endif
>          gtk_window_fullscreen(GTK_WINDOW(win->toplevel));
>      } else {
>          gtk_window_unfullscreen(GTK_WINDOW(win->toplevel));
> -#ifdef WIN32
> +#ifdef G_OS_WIN32
>          gtk_window_move(GTK_WINDOW(win->toplevel), win->win_x, win->win_y);
>  #endif
>      }
> @@ -933,7 +933,7 @@ static gboolean is_gtk_session_property(const gchar *property)
>      return FALSE;
>  }
>  
> -#ifndef WIN32
> +#ifndef G_OS_WIN32
>  static void recent_item_activated_cb(GtkRecentChooser *chooser, gpointer data)
>  {
>      GtkRecentInfo *info;
> @@ -1033,7 +1033,7 @@ static SpiceWindow *create_spice_window(spice_connection *conn, SpiceChannel *ch
>      win->ritem  = gtk_ui_manager_get_widget
>          (win->ui, "/MainMenu/FileMenu/FileRecentMenu");
>  
> -#ifndef WIN32
> +#ifndef G_OS_WIN32
>      GtkRecentFilter  *rfilter;
>  
>      win->rmenu = gtk_recent_chooser_menu_new();
> @@ -1701,7 +1701,7 @@ static void (* segv_handler) (int) = SIG_DFL;
>  static void (* abrt_handler) (int) = SIG_DFL;
>  static void (* fpe_handler)  (int) = SIG_DFL;
>  static void (* ill_handler)  (int) = SIG_DFL;
> -#ifndef WIN32
> +#ifndef G_OS_WIN32
>  static void (* bus_handler)  (int) = SIG_DFL;
>  #endif
>  
> @@ -1718,7 +1718,7 @@ signal_handler(int signum)
>      signal(SIGABRT, abrt_handler);
>      signal(SIGFPE,  fpe_handler);
>      signal(SIGILL,  ill_handler);
> -#ifndef WIN32
> +#ifndef G_OS_WIN32
>      signal(SIGBUS,  bus_handler);
>  #endif
>  
> @@ -1805,7 +1805,7 @@ int main(int argc, char *argv[])
>      abrt_handler = signal(SIGABRT, signal_handler);
>      fpe_handler  = signal(SIGFPE,  signal_handler);
>      ill_handler  = signal(SIGILL,  signal_handler);
> -#ifndef WIN32
> +#ifndef G_OS_WIN32
>      signal(SIGHUP, signal_handler);
>      bus_handler  = signal(SIGBUS,  signal_handler);
>  #endif


_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]