diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 4c401d82d28..af159ec80d0 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -50,7 +50,7 @@ #include "nsIMarkupDocumentViewer.h" #include "nsClientRect.h" -#if defined(MOZ_X11) && defined(MOZ_WIDGET_GTK2) +#if defined(MOZ_X11) && defined(MOZ_WIDGET_GTK) #include #include #endif @@ -213,8 +213,8 @@ nsDOMWindowUtils::Redraw(PRUint32 aCount, PRUint32 *aDurationOut) for (PRUint32 i = 0; i < aCount; i++) rootFrame->InvalidateWithFlags(r, nsIFrame::INVALIDATE_IMMEDIATE); -#if defined(MOZ_X11) && defined(MOZ_WIDGET_GTK2) - XSync(GDK_DISPLAY(), False); +#if defined(MOZ_X11) && defined(MOZ_WIDGET_GTK) + XSync(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), False); #endif *aDurationOut = PR_IntervalToMilliseconds(PR_IntervalNow() - iStart); diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 05243027cf4..82920b9e9a1 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -4,7 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifdef MOZ_WIDGET_GTK2 +#ifdef MOZ_WIDGET_GTK #include #endif @@ -218,7 +218,7 @@ ContentChild::Init(MessageLoop* aIOLoop, base::ProcessHandle aParentHandle, IPC::Channel* aChannel) { -#ifdef MOZ_WIDGET_GTK2 +#ifdef MOZ_WIDGET_GTK // sigh gtk_init(NULL, NULL); #endif diff --git a/dom/plugins/base/nsNPAPIPlugin.cpp b/dom/plugins/base/nsNPAPIPlugin.cpp index e703161b51f..a5927897127 100644 --- a/dom/plugins/base/nsNPAPIPlugin.cpp +++ b/dom/plugins/base/nsNPAPIPlugin.cpp @@ -56,11 +56,13 @@ #endif // needed for nppdf plugin -#ifdef MOZ_WIDGET_GTK2 +#if (MOZ_WIDGET_GTK) #include #include +#if (MOZ_WIDGET_GTK == 2) #include "gtk2xtbin.h" #endif +#endif #ifdef XP_OS2 #define INCL_DOS @@ -2013,7 +2015,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result) } case NPNVToolkit: { -#ifdef MOZ_WIDGET_GTK2 +#ifdef MOZ_WIDGET_GTK *((NPNToolkitType*)result) = NPNVGtk2; #endif @@ -2028,7 +2030,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result) } case NPNVSupportsXEmbedBool: { -#ifdef MOZ_WIDGET_GTK2 +#ifdef MOZ_WIDGET_GTK *(NPBool*)result = true; #elif defined(MOZ_WIDGET_QT) // Desktop Flash fail to initialize if browser does not support NPNVSupportsXEmbedBool @@ -2055,7 +2057,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result) case NPNVSupportsWindowless: { #if defined(XP_WIN) || defined(XP_MACOSX) || \ - (defined(MOZ_X11) && (defined(MOZ_WIDGET_GTK2) || defined(MOZ_WIDGET_QT))) + (defined(MOZ_X11) && (defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_QT))) *(NPBool*)result = true; #else *(NPBool*)result = false; diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index ef8c5de34ed..4fb58bfae2b 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -734,7 +734,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetNetscapeWindow(void *value) } return rv; -#elif (defined(MOZ_WIDGET_GTK2) || defined(MOZ_WIDGET_QT)) && defined(MOZ_X11) +#elif (defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_QT)) && defined(MOZ_X11) // X11 window managers want the toplevel window for WM_TRANSIENT_FOR. nsIWidget* win = mObjectFrame->GetNearestWidget(); if (!win) @@ -2432,7 +2432,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const nsGUIEvent& anEvent) nsIntPoint rootPoint(-1,-1); if (widget) rootPoint = anEvent.refPoint + widget->WidgetToScreenOffset(); -#ifdef MOZ_WIDGET_GTK2 +#ifdef MOZ_WIDGET_GTK Window root = GDK_ROOT_WINDOW(); #elif defined(MOZ_WIDGET_QT) Window root = RootWindowOfScreen(DefaultScreenOfDisplay(mozilla::DefaultXDisplay())); @@ -2520,7 +2520,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const nsGUIEvent& anEvent) if (anEvent.pluginEvent) { XKeyEvent &event = pluginEvent.xkey; -#ifdef MOZ_WIDGET_GTK2 +#ifdef MOZ_WIDGET_GTK event.root = GDK_ROOT_WINDOW(); event.time = anEvent.time; const GdkEventKey* gdkEvent = @@ -3046,17 +3046,11 @@ void nsPluginInstanceOwner::Paint(gfxContext* aContext, aContext->Translate(pluginRect.TopLeft()); Renderer renderer(window, this, pluginSize, pluginDirtyRect); -#ifdef MOZ_WIDGET_GTK2 - // This is the visual used by the widgets, 24-bit if available. - GdkVisual* gdkVisual = gdk_rgb_get_visual(); - Visual* visual = gdk_x11_visual_get_xvisual(gdkVisual); - Screen* screen = - gdk_x11_screen_get_xscreen(gdk_visual_get_screen(gdkVisual)); -#else + Display* dpy = mozilla::DefaultXDisplay(); Screen* screen = DefaultScreenOfDisplay(dpy); Visual* visual = DefaultVisualOfScreen(screen); -#endif + renderer.Draw(aContext, nsIntSize(window->width, window->height), rendererFlags, screen, visual, nsnull); } diff --git a/dom/plugins/base/nsPluginNativeWindowGtk2.cpp b/dom/plugins/base/nsPluginNativeWindowGtk2.cpp index 2d9a5dbcdf0..09ec470c7fd 100644 --- a/dom/plugins/base/nsPluginNativeWindowGtk2.cpp +++ b/dom/plugins/base/nsPluginNativeWindowGtk2.cpp @@ -16,6 +16,7 @@ #include #include +#include "gtk2compat.h" #include "gtk2xtbin.h" class nsPluginNativeWindowGtk2 : public nsPluginNativeWindow { @@ -147,8 +148,8 @@ nsresult nsPluginNativeWindowGtk2::CallSetWindow(nsRefPtr nsresult nsPluginNativeWindowGtk2::CreateXEmbedWindow() { NS_ASSERTION(!mSocketWidget,"Already created a socket widget!"); - - GdkWindow *parent_win = gdk_window_lookup((XID)window); + GdkDisplay *display = gdk_display_get_default(); + GdkWindow *parent_win = gdk_x11_window_lookup_for_display(display, (XID)window); mSocketWidget = gtk_socket_new(); //attach the socket to the container widget @@ -179,7 +180,10 @@ nsresult nsPluginNativeWindowGtk2::CreateXEmbedWindow() { // background and this would happen immediately (before the plug is // created). Setting the background to None prevents the server from // painting this window, avoiding flicker. - gdk_window_set_back_pixmap(mSocketWidget->window, NULL, FALSE); + // TODO GTK3 +#if (MOZ_WIDGET_GTK == 2) + gdk_window_set_back_pixmap(gtk_widget_get_window(mSocketWidget), NULL, FALSE); +#endif // Resize before we show SetAllocation(); @@ -196,11 +200,17 @@ nsresult nsPluginNativeWindowGtk2::CreateXEmbedWindow() { 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.visual = GDK_VISUAL_XVISUAL(gdkVisual); mWsInfo.depth = gdkVisual->depth; - +#else + mWsInfo.colormap = None; + GdkVisual* gdkVisual = gdk_window_get_visual(gdkWindow); + mWsInfo.depth = gdk_visual_get_depth(gdkVisual); +#endif + mWsInfo.visual = GDK_VISUAL_XVISUAL(gdkVisual); + return NS_OK; } @@ -223,7 +233,8 @@ nsresult nsPluginNativeWindowGtk2::CreateXtWindow() { printf("About to create new xtbin of %i X %i from %p...\n", width, height, (void*)window); #endif - GdkWindow *gdkWindow = gdk_window_lookup((XID)window); + GdkDisplay *display = gdk_display_get_default(); + GdkWindow *gdkWindow = gdk_x11_window_lookup_for_display(display, (XID)window); 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. @@ -270,8 +281,9 @@ socket_unrealize_cb(GtkWidget *widget, gpointer data) { // Unmap and reparent any child windows that GDK does not yet know about. // (See bug 540114 comment 10.) - GdkWindow* socket_window = widget->window; - Display* display = GDK_DISPLAY(); + GdkWindow* socket_window = gtk_widget_get_window(widget); + GdkDisplay* gdkDisplay = gdk_display_get_default(); + Display* display = GDK_DISPLAY_XDISPLAY(gdkDisplay); // Ignore X errors that may happen if windows get destroyed (possibly // requested by the plugin) between XQueryTree and when we operate on them. @@ -280,13 +292,13 @@ socket_unrealize_cb(GtkWidget *widget, gpointer data) Window root, parent; Window* children; unsigned int nchildren; - if (!XQueryTree(display, gdk_x11_drawable_get_xid(socket_window), + if (!XQueryTree(display, gdk_x11_window_get_xid(socket_window), &root, &parent, &children, &nchildren)) return; for (unsigned int i = 0; i < nchildren; ++i) { Window child = children[i]; - if (!gdk_window_lookup(child)) { + if (!gdk_x11_window_lookup_for_display(gdkDisplay, child)) { // This window is not known to GDK. XUnmapWindow(display, child); XReparentWindow(display, child, DefaultRootWindow(display), 0, 0); diff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp index c1dfbe3a998..8e7193b3e8c 100644 --- a/dom/plugins/ipc/PluginInstanceChild.cpp +++ b/dom/plugins/ipc/PluginInstanceChild.cpp @@ -44,9 +44,12 @@ using mozilla::ipc::ProcessChild; using namespace mozilla::plugins; using namespace std; -#ifdef MOZ_WIDGET_GTK2 +#ifdef MOZ_WIDGET_GTK #include +#if (MOZ_WIDGET_GTK == 3) +#include +#endif #include #include #include "gtk2xtbin.h" diff --git a/dom/plugins/ipc/PluginInstanceParent.cpp b/dom/plugins/ipc/PluginInstanceParent.cpp index dce4333a819..19b66b65aee 100644 --- a/dom/plugins/ipc/PluginInstanceParent.cpp +++ b/dom/plugins/ipc/PluginInstanceParent.cpp @@ -36,7 +36,7 @@ extern const PRUnichar* kOOPPPluginFocusEventId; UINT gOOPPPluginFocusEvent = RegisterWindowMessage(kOOPPPluginFocusEventId); extern const PRUnichar* kFlashFullscreenClass; -#elif defined(MOZ_WIDGET_GTK2) +#elif defined(MOZ_WIDGET_GTK) #include #elif defined(XP_MACOSX) #include @@ -1268,7 +1268,7 @@ PluginInstanceParent::NPP_HandleEvent(void* event) // Release any active pointer grab so that the plugin X client can // grab the pointer if it wishes. Display *dpy = DefaultXDisplay(); -# ifdef MOZ_WIDGET_GTK2 +# ifdef MOZ_WIDGET_GTK // GDK attempts to (asynchronously) track whether there is an active // grab so ungrab through GDK. gdk_pointer_ungrab(npevent->xbutton.time); diff --git a/dom/plugins/ipc/PluginModuleChild.cpp b/dom/plugins/ipc/PluginModuleChild.cpp index 4a1eed0ef26..83d6e2fb26a 100644 --- a/dom/plugins/ipc/PluginModuleChild.cpp +++ b/dom/plugins/ipc/PluginModuleChild.cpp @@ -17,8 +17,12 @@ #include "mozilla/ipc/SyncChannel.h" -#ifdef MOZ_WIDGET_GTK2 +#ifdef MOZ_WIDGET_GTK #include +#if (MOZ_WIDGET_GTK == 3) +#include +#endif +#include "gtk2compat.h" #endif #include "nsIFile.h" @@ -90,7 +94,7 @@ PluginModuleChild::PluginModuleChild() , mInitializeFunc(0) #if defined(OS_WIN) || defined(OS_MACOSX) , mGetEntryPointsFunc(0) -#elif defined(MOZ_WIDGET_GTK2) +#elif defined(MOZ_WIDGET_GTK) , mNestedLoopTimerId(0) #elif defined(MOZ_WIDGET_QT) , mNestedLoopTimerObject(0) @@ -229,7 +233,7 @@ PluginModuleChild::Init(const std::string& aPluginFilename, return true; } -#if defined(MOZ_WIDGET_GTK2) +#if defined(MOZ_WIDGET_GTK) typedef void (*GObjectDisposeFn)(GObject*); typedef gboolean (*GtkWidgetScrollEventFn)(GtkWidget*, GdkEventScroll*); typedef void (*GtkPlugEmbeddedFn)(GtkPlug*); @@ -269,16 +273,16 @@ wrap_gtk_plug_dispose(GObject* object) { static gboolean gtk_plug_scroll_event(GtkWidget *widget, GdkEventScroll *gdk_event) { - if (!GTK_WIDGET_TOPLEVEL(widget)) // in same process as its GtkSocket + if (!gtk_widget_is_toplevel(widget)) // in same process as its GtkSocket return FALSE; // event not handled; propagate to GtkSocket - GdkWindow* socket_window = GTK_PLUG(widget)->socket_window; + GdkWindow* socket_window = gtk_plug_get_socket_window(GTK_PLUG(widget)); if (!socket_window) return FALSE; // Propagate the event to the embedder. - GdkScreen* screen = gdk_drawable_get_screen(socket_window); - GdkWindow* plug_window = widget->window; + GdkScreen* screen = gdk_window_get_screen(socket_window); + GdkWindow* plug_window = gtk_widget_get_window(widget); GdkWindow* event_window = gdk_event->window; gint x = gdk_event->x; gint y = gdk_event->y; @@ -324,9 +328,9 @@ gtk_plug_scroll_event(GtkWidget *widget, GdkEventScroll *gdk_event) memset(&xevent, 0, sizeof(xevent)); xevent.xbutton.type = ButtonPress; - xevent.xbutton.window = GDK_WINDOW_XWINDOW(socket_window); - xevent.xbutton.root = GDK_WINDOW_XWINDOW(gdk_screen_get_root_window(screen)); - xevent.xbutton.subwindow = GDK_WINDOW_XWINDOW(plug_window); + xevent.xbutton.window = gdk_x11_window_get_xid(socket_window); + xevent.xbutton.root = gdk_x11_window_get_xid(gdk_screen_get_root_window(screen)); + xevent.xbutton.subwindow = gdk_x11_window_get_xid(plug_window); xevent.xbutton.time = gdk_event->time; xevent.xbutton.x = x; xevent.xbutton.y = y; @@ -354,7 +358,7 @@ gtk_plug_scroll_event(GtkWidget *widget, GdkEventScroll *gdk_event) static void wrap_gtk_plug_embedded(GtkPlug* plug) { - GdkWindow* socket_window = plug->socket_window; + GdkWindow* socket_window = gtk_plug_get_socket_window(plug); if (socket_window) { if (gtk_check_version(2,18,7) != NULL // older && g_object_get_data(G_OBJECT(socket_window), @@ -497,7 +501,7 @@ PluginModuleChild::ShouldContinueFromReplyTimeout() bool PluginModuleChild::InitGraphics() { -#if defined(MOZ_WIDGET_GTK2) +#if defined(MOZ_WIDGET_GTK) // Work around plugins that don't interact well with GDK // client-side windows. PR_SetEnv("GDK_NATIVE_WINDOWS=1"); @@ -1072,7 +1076,7 @@ _getvalue(NPP aNPP, switch (aVariable) { // Copied from nsNPAPIPlugin.cpp case NPNVToolkit: -#if defined(MOZ_WIDGET_GTK2) || defined(MOZ_WIDGET_QT) +#if defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_QT) *static_cast(aValue) = NPNVGtk2; return NPERR_NO_ERROR; #endif diff --git a/dom/plugins/ipc/PluginModuleChild.h b/dom/plugins/ipc/PluginModuleChild.h index dc170c95b18..ac7709bb707 100644 --- a/dom/plugins/ipc/PluginModuleChild.h +++ b/dom/plugins/ipc/PluginModuleChild.h @@ -306,7 +306,7 @@ private: void InitQuirksModes(const nsCString& aMimeType); bool InitGraphics(); void DeinitGraphics(); -#if defined(MOZ_WIDGET_GTK2) +#if defined(MOZ_WIDGET_GTK) static gboolean DetectNestedEventLoop(gpointer data); static gboolean ProcessBrowserEvents(gpointer data); @@ -340,7 +340,7 @@ private: NPPluginFuncs mFunctions; NPSavedData mSavedData; -#if defined(MOZ_WIDGET_GTK2) +#if defined(MOZ_WIDGET_GTK) // If a plugin spins a nested glib event loop in response to a // synchronous IPC message from the browser, the loop might break // only after the browser responds to a request sent by the diff --git a/dom/plugins/ipc/PluginModuleParent.cpp b/dom/plugins/ipc/PluginModuleParent.cpp index ff66d60f92e..bb7d4f227ed 100644 --- a/dom/plugins/ipc/PluginModuleParent.cpp +++ b/dom/plugins/ipc/PluginModuleParent.cpp @@ -4,7 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifdef MOZ_WIDGET_GTK2 +#ifdef MOZ_WIDGET_GTK #include #elif XP_MACOSX #include "PluginInterposeOSX.h" @@ -964,7 +964,7 @@ PluginModuleParent::AnswerProcessSomeEvents() return true; } -#elif !defined(MOZ_WIDGET_GTK2) +#elif !defined(MOZ_WIDGET_GTK) bool PluginModuleParent::AnswerProcessSomeEvents() { diff --git a/dom/plugins/test/testplugin/nptest.cpp b/dom/plugins/test/testplugin/nptest.cpp index 5112137dc1c..e9336bba185 100644 --- a/dom/plugins/test/testplugin/nptest.cpp +++ b/dom/plugins/test/testplugin/nptest.cpp @@ -3221,7 +3221,7 @@ hangPlugin(NPObject* npobj, const NPVariant* args, uint32_t argCount, return true; } -#if defined(MOZ_WIDGET_GTK2) +#if defined(MOZ_WIDGET_GTK) bool getClipboardText(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)