| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_OZONE_PLATFORM_CACA_CACA_WINDOW_H_ | |
| 6 #define UI_OZONE_PLATFORM_CACA_CACA_WINDOW_H_ | |
| 7 | |
| 8 #include <caca.h> | |
| 9 | |
| 10 #include "base/debug/stack_trace.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "ui/events/platform/platform_event_dispatcher.h" | |
| 14 #include "ui/gfx/geometry/size.h" | |
| 15 #include "ui/gfx/native_widget_types.h" | |
| 16 #include "ui/ozone/platform/caca/scoped_caca_types.h" | |
| 17 #include "ui/platform_window/platform_window.h" | |
| 18 | |
| 19 namespace ui { | |
| 20 | |
| 21 class CacaEventSource; | |
| 22 class CacaWindowManager; | |
| 23 class PlatformWindowDelegate; | |
| 24 | |
| 25 // Basic initialization of Libcaca. This needs to be shared between SFO and EFO | |
| 26 // since both need the |display_| to draw and process events respectively. | |
| 27 // Note, |canvas_| needs to be here since it is needed for creating a | |
| 28 // |display_|. | |
| 29 class CacaWindow : public PlatformWindow, public PlatformEventDispatcher { | |
| 30 public: | |
| 31 CacaWindow(PlatformWindowDelegate* delegate, | |
| 32 CacaWindowManager* manager, | |
| 33 CacaEventSource* event_source, | |
| 34 const gfx::Rect& bounds); | |
| 35 virtual ~CacaWindow(); | |
| 36 | |
| 37 bool Initialize(); | |
| 38 | |
| 39 // Handlers for events received from libcaca. | |
| 40 void OnCacaQuit(); | |
| 41 void OnCacaResize(); | |
| 42 void OnCacaEvent(ui::Event* event); | |
| 43 | |
| 44 // This is the Caca canvas size. | |
| 45 gfx::Size physical_size() const { return physical_size_; } | |
| 46 gfx::Size bitmap_size() const { return bitmap_size_; } | |
| 47 caca_display_t* display() const { return display_.get(); } | |
| 48 | |
| 49 // PlatformWindow: | |
| 50 virtual gfx::Rect GetBounds() override; | |
| 51 virtual void SetBounds(const gfx::Rect& bounds) override; | |
| 52 virtual void Show() override; | |
| 53 virtual void Hide() override; | |
| 54 virtual void Close() override; | |
| 55 virtual void SetCapture() override; | |
| 56 virtual void ReleaseCapture() override; | |
| 57 virtual void ToggleFullscreen() override; | |
| 58 virtual void Maximize() override; | |
| 59 virtual void Minimize() override; | |
| 60 virtual void Restore() override; | |
| 61 virtual void SetCursor(PlatformCursor cursor) override; | |
| 62 virtual void MoveCursorTo(const gfx::Point& location) override; | |
| 63 | |
| 64 // PlatformEventDispatcher: | |
| 65 virtual bool CanDispatchEvent(const PlatformEvent& event) override; | |
| 66 virtual uint32_t DispatchEvent(const PlatformEvent& event) override; | |
| 67 | |
| 68 private: | |
| 69 // Event polling. | |
| 70 void TryProcessingEvent(); | |
| 71 | |
| 72 // Sync sizes with libcaca. | |
| 73 void UpdateDisplaySize(); | |
| 74 | |
| 75 PlatformWindowDelegate* delegate_; | |
| 76 CacaWindowManager* manager_; | |
| 77 CacaEventSource* event_source_; | |
| 78 gfx::AcceleratedWidget widget_; | |
| 79 | |
| 80 ScopedCacaCanvas canvas_; | |
| 81 ScopedCacaDisplay display_; | |
| 82 | |
| 83 // Size of the console in characters. This can be changed by setting | |
| 84 // CACA_GEOMETRY environment variable. | |
| 85 gfx::Size physical_size_; | |
| 86 | |
| 87 // Size of the backing buffer we draw into. Size in pixels. | |
| 88 gfx::Size bitmap_size_; | |
| 89 | |
| 90 base::WeakPtrFactory<CacaWindow> weak_ptr_factory_; | |
| 91 | |
| 92 DISALLOW_COPY_AND_ASSIGN(CacaWindow); | |
| 93 }; | |
| 94 | |
| 95 } // namespace ui | |
| 96 | |
| 97 #endif // UI_OZONE_PLATFORM_CACA_CACA_WINDOW_H_ | |
| OLD | NEW |