|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* vim:expandtab:shiftwidth=2:tabstop=2: |
|
3 */ |
|
4 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
5 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
7 |
|
8 /** |
|
9 * This file is the Qt implementation of plugin native window. |
|
10 */ |
|
11 |
|
12 #include "nsDebug.h" |
|
13 #include "nsPluginNativeWindow.h" |
|
14 #include "npapi.h" |
|
15 |
|
16 /** |
|
17 * Qt implementation of plugin window |
|
18 */ |
|
19 class nsPluginNativeWindowQt : public nsPluginNativeWindow |
|
20 { |
|
21 public: |
|
22 nsPluginNativeWindowQt(); |
|
23 virtual ~nsPluginNativeWindowQt(); |
|
24 |
|
25 virtual nsresult CallSetWindow(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance); |
|
26 private: |
|
27 |
|
28 NPSetWindowCallbackStruct mWsInfo; |
|
29 }; |
|
30 |
|
31 nsPluginNativeWindowQt::nsPluginNativeWindowQt() : nsPluginNativeWindow() |
|
32 { |
|
33 //Initialize member variables |
|
34 #ifdef DEBUG |
|
35 fprintf(stderr,"\n\n\nCreating plugin native window %p\n\n\n", (void *) this); |
|
36 #endif |
|
37 window = nullptr; |
|
38 x = 0; |
|
39 y = 0; |
|
40 width = 0; |
|
41 height = 0; |
|
42 memset(&clipRect, 0, sizeof(clipRect)); |
|
43 ws_info = &mWsInfo; |
|
44 type = NPWindowTypeWindow; |
|
45 mWsInfo.type = 0; |
|
46 #if defined(MOZ_X11) |
|
47 mWsInfo.display = nullptr; |
|
48 mWsInfo.visual = nullptr; |
|
49 mWsInfo.colormap = 0; |
|
50 mWsInfo.depth = 0; |
|
51 #endif |
|
52 } |
|
53 |
|
54 nsPluginNativeWindowQt::~nsPluginNativeWindowQt() |
|
55 { |
|
56 #ifdef DEBUG |
|
57 fprintf(stderr,"\n\n\nDestoying plugin native window %p\n\n\n", (void *) this); |
|
58 #endif |
|
59 } |
|
60 |
|
61 nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow **aPluginNativeWindow) |
|
62 { |
|
63 NS_ENSURE_ARG_POINTER(aPluginNativeWindow); |
|
64 *aPluginNativeWindow = new nsPluginNativeWindowQt(); |
|
65 return *aPluginNativeWindow ? NS_OK : NS_ERROR_OUT_OF_MEMORY; |
|
66 } |
|
67 |
|
68 nsresult PLUG_DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow) |
|
69 { |
|
70 NS_ENSURE_ARG_POINTER(aPluginNativeWindow); |
|
71 nsPluginNativeWindowQt *p = (nsPluginNativeWindowQt *)aPluginNativeWindow; |
|
72 delete p; |
|
73 return NS_OK; |
|
74 } |
|
75 |
|
76 nsresult nsPluginNativeWindowQt::CallSetWindow(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance) |
|
77 { |
|
78 if (aPluginInstance) { |
|
79 if (type == NPWindowTypeWindow) { |
|
80 return NS_ERROR_FAILURE; |
|
81 } // NPWindowTypeWindow |
|
82 aPluginInstance->SetWindow(this); |
|
83 } |
|
84 else if (mPluginInstance) |
|
85 mPluginInstance->SetWindow(nullptr); |
|
86 |
|
87 SetPluginInstance(aPluginInstance); |
|
88 return NS_OK; |
|
89 } |