Bug 781058 - Part a: Fix -Werror=int-to-pointer-cast in nsPluginNativeWindowGtk2; r=mounir
authorMs2ger <ms2ger@gmail.com>
Thu, 09 Aug 2012 09:20:18 +0200
changeset 101866 8759d59636f089b1ce1c12a45867513a24fd76b1
parent 101865 144b21a87da45f1447c4556efccbfef8baa3bf72
child 101867 2a19a83e94c81372b7d1f4a797bf30cf53a6ea48
push id23254
push userMs2ger@gmail.com
push dateThu, 09 Aug 2012 07:22:25 +0000
treeherdermozilla-central@3199bc043da4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmounir
bugs781058
milestone17.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 781058 - Part a: Fix -Werror=int-to-pointer-cast in nsPluginNativeWindowGtk2; r=mounir
dom/plugins/base/nsPluginNativeWindowGtk2.cpp
--- a/dom/plugins/base/nsPluginNativeWindowGtk2.cpp
+++ b/dom/plugins/base/nsPluginNativeWindowGtk2.cpp
@@ -23,16 +23,25 @@
 
 class nsPluginNativeWindowGtk2 : public nsPluginNativeWindow {
 public: 
   nsPluginNativeWindowGtk2();
   virtual ~nsPluginNativeWindowGtk2();
 
   virtual nsresult CallSetWindow(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance);
 private:
+  void SetWindow(XID aWindow)
+  {
+    window = reinterpret_cast<void*>(static_cast<uintptr_t>(aWindow));
+  }
+  XID GetWindow() const
+  {
+    return static_cast<XID>(reinterpret_cast<uintptr_t>(window));
+  }
+
   NPSetWindowCallbackStruct mWsInfo;
   /**
    * Either a GtkSocket or a special GtkXtBin widget (derived from GtkSocket)
    * that encapsulates the Xt toolkit within a Gtk Application.
    */
   GtkWidget* mSocketWidget;
   nsresult  CreateXEmbedWindow(bool aEnableXtFocus);
   nsresult  CreateXtWindow();
@@ -126,21 +135,21 @@ nsresult nsPluginNativeWindowGtk2::CallS
       }
 
       // Make sure to resize and re-place the window if required.
       // Need to reset "window" each time as nsObjectFrame::DidReflow sets it
       // to the ancestor window.
       if (GTK_IS_XTBIN(mSocketWidget)) {
         gtk_xtbin_resize(mSocketWidget, width, height);
         // Point the NPWindow structures window to the actual X window
-        window = (void*)GTK_XTBIN(mSocketWidget)->xtwindow;
+        SetWindow(GTK_XTBIN(mSocketWidget)->xtwindow);
       }
       else { // XEmbed or OOP&Xt
         SetAllocation();
-        window = (void*)gtk_socket_get_id(GTK_SOCKET(mSocketWidget));
+        SetWindow(gtk_socket_get_id(GTK_SOCKET(mSocketWidget)));
       }
 #ifdef DEBUG
       printf("nsPluginNativeWindowGtk2: call SetWindow with xid=%p\n", (void *)window);
 #endif
     } // NPWindowTypeWindow
     aPluginInstance->SetWindow(this);
   }
   else if (mPluginInstance)
@@ -148,17 +157,17 @@ nsresult nsPluginNativeWindowGtk2::CallS
 
   SetPluginInstance(aPluginInstance);
   return NS_OK;
 }
 
 nsresult nsPluginNativeWindowGtk2::CreateXEmbedWindow(bool aEnableXtFocus) {
   NS_ASSERTION(!mSocketWidget,"Already created a socket widget!");
   GdkDisplay *display = gdk_display_get_default();
-  GdkWindow *parent_win = gdk_x11_window_lookup_for_display(display, (XID)window);
+  GdkWindow *parent_win = gdk_x11_window_lookup_for_display(display, GetWindow());
   mSocketWidget = gtk_socket_new();
 
   //attach the socket to the container widget
   gtk_widget_set_parent_window(mSocketWidget, parent_win);
 
   // enable/disable focus event handlers,
   // see plugin_window_filter_func() for details
   g_object_set_data(G_OBJECT(mSocketWidget), "enable-xt-focus", (void *)aEnableXtFocus);
@@ -194,21 +203,21 @@ nsresult nsPluginNativeWindowGtk2::Creat
 #endif
 
   // Resize before we show
   SetAllocation();
 
   gtk_widget_show(mSocketWidget);
 
   gdk_flush();
-  window = (void*)gtk_socket_get_id(GTK_SOCKET(mSocketWidget));
+  SetWindow(gtk_socket_get_id(GTK_SOCKET(mSocketWidget)));
 
   // Fill out the ws_info structure.
   // (The windowless case is done in nsObjectFrame.cpp.)
-  GdkWindow *gdkWindow = gdk_window_lookup((XID)window);
+  GdkWindow *gdkWindow = gdk_window_lookup(GetWindow());
   if(!gdkWindow)
     return NS_ERROR_FAILURE;
 
   mWsInfo.display = GDK_WINDOW_XDISPLAY(gdkWindow);
 #if (MOZ_WIDGET_GTK == 2)
   mWsInfo.colormap = GDK_COLORMAP_XCOLORMAP(gdk_drawable_get_colormap(gdkWindow));
   GdkVisual* gdkVisual = gdk_drawable_get_visual(gdkWindow);
   mWsInfo.depth = gdkVisual->depth;
@@ -237,17 +246,17 @@ void nsPluginNativeWindowGtk2::SetAlloca
 nsresult nsPluginNativeWindowGtk2::CreateXtWindow() {
   NS_ASSERTION(!mSocketWidget,"Already created a socket widget!");
 
 #ifdef DEBUG      
   printf("About to create new xtbin of %i X %i from %p...\n",
          width, height, (void*)window);
 #endif
   GdkDisplay *display = gdk_display_get_default();
-  GdkWindow *gdkWindow = gdk_x11_window_lookup_for_display(display, (XID)window);
+  GdkWindow *gdkWindow = gdk_x11_window_lookup_for_display(display, GetWindow());
   mSocketWidget = gtk_xtbin_new(gdkWindow, 0);
   // Check to see if creating the xtbin failed for some reason.
   // if it did, we can't go any further.
   if (!mSocketWidget)
     return NS_ERROR_FAILURE;
 
   g_signal_connect(mSocketWidget, "destroy",
                    G_CALLBACK(gtk_widget_destroyed), &mSocketWidget);