OLD | NEW |
(Empty) | |
| 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 <X11/Xlib.h> |
| 12 #include "../Window.h" |
| 13 #include "SkChecksum.h" |
| 14 #include "SkTDynamicHash.h" |
| 15 |
| 16 typedef Window XWindow; |
| 17 |
| 18 namespace sk_app { |
| 19 |
| 20 struct ContextPlatformData_unix { |
| 21 Display* fDisplay; |
| 22 XWindow fHWnd; |
| 23 VisualID fVisualID; |
| 24 }; |
| 25 |
| 26 class Window_unix : public Window { |
| 27 public: |
| 28 Window_unix() : Window() {} |
| 29 ~Window_unix() override {} |
| 30 |
| 31 bool init(Display* display); |
| 32 |
| 33 void setTitle(const char*) override; |
| 34 void show() override; |
| 35 |
| 36 bool attach(BackendType attachType, const DisplayParams& params) override; |
| 37 |
| 38 void onInval() override; |
| 39 |
| 40 bool handleEvent(const XEvent& event); |
| 41 |
| 42 static const XWindow& GetKey(const Window_unix& w) { |
| 43 return w.fHWnd; |
| 44 } |
| 45 |
| 46 static uint32_t Hash(const XWindow& w) { |
| 47 return SkChecksum::Mix(w); |
| 48 } |
| 49 |
| 50 static SkTDynamicHash<Window_unix, XWindow> gWindowMap; |
| 51 |
| 52 void markPendingPaint() { fPendingPaint = true; } |
| 53 void finishPaint() { |
| 54 if (fPendingPaint) { |
| 55 this->onPaint(); |
| 56 fPendingPaint = false; |
| 57 } |
| 58 } |
| 59 |
| 60 void markPendingResize(int width, int height) { |
| 61 fPendingWidth = width; |
| 62 fPendingHeight = height; |
| 63 fPendingResize = true; |
| 64 } |
| 65 void finishResize() { |
| 66 if (fPendingResize) { |
| 67 this->onResize(fPendingWidth, fPendingHeight); |
| 68 fPendingResize = false; |
| 69 } |
| 70 } |
| 71 |
| 72 private: |
| 73 Display* fDisplay; |
| 74 XWindow fHWnd; |
| 75 |
| 76 Atom fWmDeleteMessage; |
| 77 |
| 78 bool fPendingPaint; |
| 79 int fPendingWidth; |
| 80 int fPendingHeight; |
| 81 bool fPendingResize; |
| 82 }; |
| 83 |
| 84 } // namespace sk_app |
| 85 |
| 86 #endif |
OLD | NEW |