Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #include "X11CompositorWidget.h"
7 :
8 : #include "gfxPlatformGtk.h"
9 : #include "mozilla/layers/CompositorThread.h"
10 : #include "mozilla/widget/InProcessCompositorWidget.h"
11 : #include "mozilla/widget/PlatformWidgetTypes.h"
12 : #include "nsWindow.h"
13 :
14 : namespace mozilla {
15 : namespace widget {
16 :
17 1 : X11CompositorWidget::X11CompositorWidget(const CompositorWidgetInitData& aInitData,
18 : const CompositorOptions& aOptions,
19 1 : nsWindow* aWindow)
20 : : CompositorWidget(aOptions)
21 1 : , mWidget(aWindow)
22 : {
23 : // If we have a nsWindow, then grab the already existing display connection
24 : // If we don't, then use the init data to connect to the display
25 1 : if (aWindow) {
26 1 : mXDisplay = aWindow->XDisplay();
27 : } else {
28 0 : mXDisplay = XOpenDisplay(aInitData.XDisplayString().get());
29 : }
30 1 : mXWindow = (Window)aInitData.XWindow();
31 :
32 : // Grab the window's visual and depth
33 : XWindowAttributes windowAttrs;
34 1 : XGetWindowAttributes(mXDisplay, mXWindow, &windowAttrs);
35 :
36 1 : Visual* visual = windowAttrs.visual;
37 1 : int depth = windowAttrs.depth;
38 :
39 : // Initialize the window surface provider
40 1 : mProvider.Initialize(
41 : mXDisplay,
42 : mXWindow,
43 : visual,
44 : depth
45 1 : );
46 :
47 1 : mClientSize = aInitData.InitialClientSize();
48 1 : }
49 :
50 0 : X11CompositorWidget::~X11CompositorWidget()
51 : {
52 0 : mProvider.CleanupResources();
53 :
54 : // If we created our own display connection, we need to destroy it
55 0 : if (!mWidget && mXDisplay) {
56 0 : XCloseDisplay(mXDisplay);
57 0 : mXDisplay = nullptr;
58 : }
59 0 : }
60 :
61 : already_AddRefed<gfx::DrawTarget>
62 0 : X11CompositorWidget::StartRemoteDrawing()
63 : {
64 0 : return nullptr;
65 : }
66 : void
67 0 : X11CompositorWidget::EndRemoteDrawing()
68 : {
69 0 : }
70 :
71 : already_AddRefed<gfx::DrawTarget>
72 27 : X11CompositorWidget::StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion,
73 : layers::BufferMode* aBufferMode)
74 : {
75 : return mProvider.StartRemoteDrawingInRegion(aInvalidRegion,
76 27 : aBufferMode);
77 : }
78 :
79 27 : void X11CompositorWidget::EndRemoteDrawingInRegion(gfx::DrawTarget* aDrawTarget,
80 : LayoutDeviceIntRegion& aInvalidRegion)
81 : {
82 27 : mProvider.EndRemoteDrawingInRegion(aDrawTarget,
83 27 : aInvalidRegion);
84 27 : }
85 :
86 0 : nsIWidget* X11CompositorWidget::RealWidget()
87 : {
88 0 : return mWidget;
89 : }
90 :
91 : void
92 2 : X11CompositorWidget::NotifyClientSizeChanged(const LayoutDeviceIntSize& aClientSize)
93 : {
94 2 : mClientSize = aClientSize;
95 2 : }
96 :
97 : LayoutDeviceIntSize
98 27 : X11CompositorWidget::GetClientSize()
99 : {
100 27 : return mClientSize;
101 : }
102 :
103 : uintptr_t
104 0 : X11CompositorWidget::GetWidgetKey()
105 : {
106 0 : return reinterpret_cast<uintptr_t>(mWidget);
107 : }
108 :
109 : } // namespace widget
110 : } // namespace mozilla
|