Flutter Engine
The Flutter Engine
Window_unix.h
Go to the documentation of this file.
1/*
2* Copyright 2016 Google Inc.
3*
4* Use of this source code is governed by a BSD-style license that can be
5* found in the LICENSE file.
6*/
7
8#ifndef Window_unix_DEFINED
9#define Window_unix_DEFINED
10
11#include "src/core/SkChecksum.h"
13#include "tools/sk_app/Window.h"
14
15#include <GL/glx.h>
16#include <X11/Xlib.h>
17
18#include <string>
19
21
22namespace sk_app {
23
24class Window_unix : public Window {
25public:
27 : Window()
28 , fDisplay(nullptr)
29 , fWindow(0)
30 , fGC(nullptr)
31 , fFBConfig(nullptr)
32 , fVisualInfo(nullptr)
33 , fMSAASampleCount(1) {}
34 ~Window_unix() override { this->closeWindow(); }
35
36 bool initWindow(Display* display);
37
38 void setTitle(const char*) override;
39 void show() override;
40
41 const char* getClipboardText() override;
42 void setClipboardText(const char*) override;
43
44 bool attach(BackendType) override;
45
46 void onInval() override;
47
48 bool handleEvent(const XEvent& event);
49
50 static const XWindow& GetKey(const Window_unix& w) {
51 return w.fWindow;
52 }
53
54 static uint32_t Hash(const XWindow& w) {
55 return SkChecksum::Mix(w);
56 }
57
59
60 void markPendingPaint() { fPendingPaint = true; }
61 void finishPaint() {
62 if (fPendingPaint) {
63 this->onPaint();
64 fPendingPaint = false;
65 }
66 }
67
69 if (width != this->width() || height != this->height()){
70 fPendingResize = true;
71 fPendingWidth = width;
72 fPendingHeight = height;
73 }
74 }
75 void finishResize() {
76 if (fPendingResize) {
77 this->onResize(fPendingWidth, fPendingHeight);
78 fPendingResize = false;
79 }
80 }
81
82 void setRequestedDisplayParams(const DisplayParams&, bool allowReattach) override;
83
84private:
85 void closeWindow();
86
87 Display* fDisplay;
88 XWindow fWindow;
89 GC fGC;
90 GLXFBConfig* fFBConfig;
91 XVisualInfo* fVisualInfo;
92 int fMSAASampleCount;
93
94 Atom fWmDeleteMessage;
95
96 bool fPendingPaint;
97 int fPendingWidth;
98 int fPendingHeight;
99 bool fPendingResize;
100
101 BackendType fBackend = BackendType::kRaster_BackendType;
102
103 std::string fClipboardText;
104};
105
106} // namespace sk_app
107
108#endif
Window XWindow
Definition: Window_unix.h:20
void show() override
bool handleEvent(const XEvent &event)
void setTitle(const char *) override
const char * getClipboardText() override
static uint32_t Hash(const XWindow &w)
Definition: Window_unix.h:54
bool attach(BackendType) override
static SkTDynamicHash< Window_unix, XWindow > gWindowMap
Definition: Window_unix.h:58
void markPendingResize(int width, int height)
Definition: Window_unix.h:68
void onInval() override
~Window_unix() override
Definition: Window_unix.h:34
bool initWindow(Display *display)
Definition: Window_unix.cpp:44
void setClipboardText(const char *) override
void setRequestedDisplayParams(const DisplayParams &, bool allowReattach) override
static const XWindow & GetKey(const Window_unix &w)
Definition: Window_unix.h:50
int height() const
Definition: Window.cpp:130
void onResize(int width, int height)
Definition: Window.cpp:108
int width() const
Definition: Window.cpp:123
void onPaint()
Definition: Window.cpp:81
FlKeyEvent * event
Definition: dart.idl:411
static uint32_t Mix(uint32_t hash)
Definition: SkChecksum.h:30
SkScalar w