michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:expandtab:shiftwidth=2:tabstop=2: michael@0: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /** michael@0: * This file is the Qt implementation of plugin native window. michael@0: */ michael@0: michael@0: #include "nsDebug.h" michael@0: #include "nsPluginNativeWindow.h" michael@0: #include "npapi.h" michael@0: michael@0: /** michael@0: * Qt implementation of plugin window michael@0: */ michael@0: class nsPluginNativeWindowQt : public nsPluginNativeWindow michael@0: { michael@0: public: michael@0: nsPluginNativeWindowQt(); michael@0: virtual ~nsPluginNativeWindowQt(); michael@0: michael@0: virtual nsresult CallSetWindow(nsRefPtr &aPluginInstance); michael@0: private: michael@0: michael@0: NPSetWindowCallbackStruct mWsInfo; michael@0: }; michael@0: michael@0: nsPluginNativeWindowQt::nsPluginNativeWindowQt() : nsPluginNativeWindow() michael@0: { michael@0: //Initialize member variables michael@0: #ifdef DEBUG michael@0: fprintf(stderr,"\n\n\nCreating plugin native window %p\n\n\n", (void *) this); michael@0: #endif michael@0: window = nullptr; michael@0: x = 0; michael@0: y = 0; michael@0: width = 0; michael@0: height = 0; michael@0: memset(&clipRect, 0, sizeof(clipRect)); michael@0: ws_info = &mWsInfo; michael@0: type = NPWindowTypeWindow; michael@0: mWsInfo.type = 0; michael@0: #if defined(MOZ_X11) michael@0: mWsInfo.display = nullptr; michael@0: mWsInfo.visual = nullptr; michael@0: mWsInfo.colormap = 0; michael@0: mWsInfo.depth = 0; michael@0: #endif michael@0: } michael@0: michael@0: nsPluginNativeWindowQt::~nsPluginNativeWindowQt() michael@0: { michael@0: #ifdef DEBUG michael@0: fprintf(stderr,"\n\n\nDestoying plugin native window %p\n\n\n", (void *) this); michael@0: #endif michael@0: } michael@0: michael@0: nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow **aPluginNativeWindow) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aPluginNativeWindow); michael@0: *aPluginNativeWindow = new nsPluginNativeWindowQt(); michael@0: return *aPluginNativeWindow ? NS_OK : NS_ERROR_OUT_OF_MEMORY; michael@0: } michael@0: michael@0: nsresult PLUG_DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aPluginNativeWindow); michael@0: nsPluginNativeWindowQt *p = (nsPluginNativeWindowQt *)aPluginNativeWindow; michael@0: delete p; michael@0: return NS_OK; michael@0: } michael@0: michael@0: nsresult nsPluginNativeWindowQt::CallSetWindow(nsRefPtr &aPluginInstance) michael@0: { michael@0: if (aPluginInstance) { michael@0: if (type == NPWindowTypeWindow) { michael@0: return NS_ERROR_FAILURE; michael@0: } // NPWindowTypeWindow michael@0: aPluginInstance->SetWindow(this); michael@0: } michael@0: else if (mPluginInstance) michael@0: mPluginInstance->SetWindow(nullptr); michael@0: michael@0: SetPluginInstance(aPluginInstance); michael@0: return NS_OK; michael@0: }