зеркало из https://github.com/mozilla/pjs.git
Bug 627699 - Port GTK2 to GTK3, dom patch. r=karlt
This commit is contained in:
Родитель
770e8bcd0a
Коммит
aa0047e7ea
|
@ -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 <gdk/gdk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#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);
|
||||
|
|
|
@ -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 <gtk/gtk.h>
|
||||
#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
|
||||
|
|
|
@ -56,11 +56,13 @@
|
|||
#endif
|
||||
|
||||
// needed for nppdf plugin
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
#if (MOZ_WIDGET_GTK)
|
||||
#include <gdk/gdk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <gdk/gdkx.h>
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
#include "gtk2compat.h"
|
||||
#include "gtk2xtbin.h"
|
||||
|
||||
class nsPluginNativeWindowGtk2 : public nsPluginNativeWindow {
|
||||
|
@ -147,8 +148,8 @@ nsresult nsPluginNativeWindowGtk2::CallSetWindow(nsRefPtr<nsNPAPIPluginInstance>
|
|||
|
||||
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);
|
||||
|
|
|
@ -44,9 +44,12 @@ using mozilla::ipc::ProcessChild;
|
|||
using namespace mozilla::plugins;
|
||||
using namespace std;
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#if (MOZ_WIDGET_GTK == 3)
|
||||
#include <gtk/gtkx.h>
|
||||
#endif
|
||||
#include <gdk/gdkx.h>
|
||||
#include <gdk/gdk.h>
|
||||
#include "gtk2xtbin.h"
|
||||
|
|
|
@ -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 <gdk/gdk.h>
|
||||
#elif defined(XP_MACOSX)
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
|
@ -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);
|
||||
|
|
|
@ -17,8 +17,12 @@
|
|||
|
||||
#include "mozilla/ipc/SyncChannel.h"
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
#include <gtk/gtk.h>
|
||||
#if (MOZ_WIDGET_GTK == 3)
|
||||
#include <gtk/gtkx.h>
|
||||
#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<NPNToolkitType*>(aValue) = NPNVGtk2;
|
||||
return NPERR_NO_ERROR;
|
||||
#endif
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <glib.h>
|
||||
#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()
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
Загрузка…
Ссылка в новой задаче