mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-06 14:44:26 +00:00
Bug 669200 - Add support for gtk socket widgets for plugin windows. r=roc
This commit is contained in:
parent
6378e0152d
commit
c01005aaff
@ -31,6 +31,7 @@ EXPORTS += [
|
||||
'nsPluginInstanceOwner.h',
|
||||
'nsPluginLogging.h',
|
||||
'nsPluginNativeWindow.h',
|
||||
'nsPluginNativeWindowGtk.h',
|
||||
'nsPluginPlayPreviewInfo.h',
|
||||
'nsPluginsCID.h',
|
||||
'nsPluginsDir.h',
|
||||
|
@ -10,7 +10,7 @@
|
||||
*/
|
||||
|
||||
#include "nsDebug.h"
|
||||
#include "nsPluginNativeWindow.h"
|
||||
#include "nsPluginNativeWindowGtk.h"
|
||||
#include "nsNPAPIPlugin.h"
|
||||
#include "npapi.h"
|
||||
#include <gtk/gtk.h>
|
||||
@ -24,35 +24,6 @@
|
||||
#endif
|
||||
#include "mozilla/X11Util.h"
|
||||
|
||||
class nsPluginNativeWindowGtk : public nsPluginNativeWindow {
|
||||
public:
|
||||
nsPluginNativeWindowGtk();
|
||||
virtual ~nsPluginNativeWindowGtk();
|
||||
|
||||
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);
|
||||
#if (MOZ_WIDGET_GTK == 2)
|
||||
nsresult CreateXtWindow();
|
||||
#endif
|
||||
void SetAllocation();
|
||||
};
|
||||
|
||||
static gboolean plug_removed_cb (GtkWidget *widget, gpointer data);
|
||||
static void socket_unrealize_cb (GtkWidget *widget, gpointer data);
|
||||
|
||||
|
52
dom/plugins/base/nsPluginNativeWindowGtk.h
Normal file
52
dom/plugins/base/nsPluginNativeWindowGtk.h
Normal file
@ -0,0 +1,52 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
#ifndef _nsPluginNativeWindowGdk_h_
|
||||
#define _nsPluginNativeWindowGdk_h_
|
||||
|
||||
#include "nsPluginNativeWindow.h"
|
||||
#include "nsNPAPIPlugin.h"
|
||||
#include "npapi.h"
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#include <gdk/gdk.h>
|
||||
#if (GTK_MAJOR_VERSION == 3)
|
||||
#include <gtk/gtkx.h>
|
||||
#else
|
||||
#include "gtk2xtbin.h"
|
||||
#endif
|
||||
#include "mozilla/X11Util.h"
|
||||
|
||||
class nsPluginNativeWindowGtk : public nsPluginNativeWindow {
|
||||
public:
|
||||
nsPluginNativeWindowGtk();
|
||||
virtual ~nsPluginNativeWindowGtk();
|
||||
|
||||
virtual nsresult CallSetWindow(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance);
|
||||
nsresult CreateXEmbedWindow(bool aEnableXtFocus);
|
||||
void SetAllocation();
|
||||
|
||||
XID GetWindow() const
|
||||
{
|
||||
return static_cast<XID>(reinterpret_cast<uintptr_t>(window));
|
||||
}
|
||||
|
||||
private:
|
||||
void SetWindow(XID aWindow)
|
||||
{
|
||||
window = reinterpret_cast<void*>(static_cast<uintptr_t>(aWindow));
|
||||
}
|
||||
|
||||
NPSetWindowCallbackStruct mWsInfo;
|
||||
/**
|
||||
* Either a GtkSocket or a special GtkXtBin widget (derived from GtkSocket)
|
||||
* that encapsulates the Xt toolkit within a Gtk Application.
|
||||
*/
|
||||
GtkWidget* mSocketWidget;
|
||||
#if (MOZ_WIDGET_GTK == 2)
|
||||
nsresult CreateXtWindow();
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
@ -8,6 +8,12 @@
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsDebug.h"
|
||||
|
||||
#if defined(MOZ_WIDGET_GTK)
|
||||
#include "nsPluginNativeWindowGtk.h"
|
||||
#else
|
||||
#include "nsPluginNativeWindow.h"
|
||||
#endif
|
||||
|
||||
using namespace mozilla::widget;
|
||||
|
||||
#define PWLOG(...)
|
||||
@ -28,6 +34,9 @@ static NS_DEFINE_CID(kWidgetCID, NS_CHILD_CID);
|
||||
}
|
||||
|
||||
PluginWidgetParent::PluginWidgetParent()
|
||||
#if defined(MOZ_WIDGET_GTK)
|
||||
: mWrapper(nullptr)
|
||||
#endif
|
||||
{
|
||||
PWLOG("PluginWidgetParent::PluginWidgetParent()\n");
|
||||
MOZ_COUNT_CTOR(PluginWidgetParent);
|
||||
@ -60,9 +69,8 @@ PluginWidgetParent::ActorDestroy(ActorDestroyReason aWhy)
|
||||
|
||||
// When plugins run in chrome, nsPluginNativeWindow(Plat) implements platform
|
||||
// specific functionality that wraps plugin widgets. With e10s we currently
|
||||
// bypass this code since we can't connect up platform specific bits in the
|
||||
// content process. We may need to instantiate nsPluginNativeWindow here and
|
||||
// enable some of its logic.
|
||||
// bypass this code on Window, and reuse a bit of it on Linux. Content still
|
||||
// makes use of some of the utility functions as well.
|
||||
|
||||
bool
|
||||
PluginWidgetParent::RecvCreate()
|
||||
@ -73,6 +81,15 @@ PluginWidgetParent::RecvCreate()
|
||||
|
||||
mWidget = do_CreateInstance(kWidgetCID, &rv);
|
||||
|
||||
#if defined(MOZ_WIDGET_GTK)
|
||||
// We need this currently just for GTK in setting up a socket widget
|
||||
// we can send over to content -> plugin.
|
||||
PLUG_NewPluginNativeWindow((nsPluginNativeWindow**)&mWrapper);
|
||||
if (!mWrapper) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// This returns the top level window widget
|
||||
nsCOMPtr<nsIWidget> parentWidget = GetTabParent()->GetWidget();
|
||||
|
||||
@ -98,6 +115,14 @@ PluginWidgetParent::RecvCreate()
|
||||
// chrome.
|
||||
RecvMove(0, 0);
|
||||
|
||||
#if defined(MOZ_WIDGET_GTK)
|
||||
// For setup, initially GTK code expects 'window' to hold the parent.
|
||||
mWrapper->window = mWidget->GetNativeData(NS_NATIVE_PLUGIN_PORT);
|
||||
mWrapper->CreateXEmbedWindow(false);
|
||||
mWrapper->SetAllocation();
|
||||
PWLOG("Plugin XID=%p\n", (void*)mWrapper->window);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -143,7 +168,12 @@ PluginWidgetParent::RecvGetNativePluginPort(uintptr_t* value)
|
||||
{
|
||||
ENSURE_CHANNEL;
|
||||
PWLOG("PluginWidgetParent::RecvGetNativeData()\n");
|
||||
#if defined(MOZ_WIDGET_GTK)
|
||||
*value = (uintptr_t)mWrapper->window;
|
||||
#else
|
||||
*value = (uintptr_t)mWidget->GetNativeData(NS_NATIVE_PLUGIN_PORT);
|
||||
#endif
|
||||
PWLOG("PluginWidgetParent::RecvGetNativeData() %p\n", (void*)*value);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -153,6 +183,11 @@ PluginWidgetParent::RecvResize(const nsIntRect& aRect)
|
||||
ENSURE_CHANNEL;
|
||||
PWLOG("PluginWidgetParent::RecvResize(%d, %d, %d, %d)\n", aRect.x, aRect.y, aRect.width, aRect.height);
|
||||
mWidget->Resize(aRect.width, aRect.height, true);
|
||||
#if defined(MOZ_WIDGET_GTK)
|
||||
mWrapper->width = aRect.width;
|
||||
mWrapper->height = aRect.height;
|
||||
mWrapper->SetAllocation();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,10 @@
|
||||
#include "nsIWidget.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#if defined(MOZ_WIDGET_GTK)
|
||||
class nsPluginNativeWindowGtk;
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace dom {
|
||||
@ -40,6 +44,9 @@ private:
|
||||
mozilla::dom::TabParent* GetTabParent();
|
||||
// The chrome side native widget.
|
||||
nsCOMPtr<nsIWidget> mWidget;
|
||||
#if defined(MOZ_WIDGET_GTK)
|
||||
UniquePtr<nsPluginNativeWindowGtk> mWrapper;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace plugins
|
||||
|
@ -143,6 +143,7 @@ PluginWidgetProxy::GetNativeData(uint32_t aDataType)
|
||||
}
|
||||
uintptr_t value = 0;
|
||||
mActor->SendGetNativePluginPort(&value);
|
||||
PWLOG("PluginWidgetProxy::GetNativeData %p\n", (void*)value);
|
||||
return (void*)value;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user