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.
5 #ifndef UI_OZONE_PLATFORM_CACA_CACA_WINDOW_H_
6 #define UI_OZONE_PLATFORM_CACA_CACA_WINDOW_H_
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"
21 class CacaEventSource
;
22 class CacaWindowManager
;
23 class PlatformWindowDelegate
;
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
29 class CacaWindow
: public PlatformWindow
, public PlatformEventDispatcher
{
31 CacaWindow(PlatformWindowDelegate
* delegate
,
32 CacaWindowManager
* manager
,
33 CacaEventSource
* event_source
,
34 const gfx::Rect
& bounds
);
35 ~CacaWindow() override
;
39 // Handlers for events received from libcaca.
42 void OnCacaEvent(ui::Event
* event
);
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(); }
50 gfx::Rect
GetBounds() override
;
51 void SetBounds(const gfx::Rect
& bounds
) override
;
54 void Close() override
;
55 void SetCapture() override
;
56 void ReleaseCapture() override
;
57 void ToggleFullscreen() override
;
58 void Maximize() override
;
59 void Minimize() override
;
60 void Restore() override
;
61 void SetCursor(PlatformCursor cursor
) override
;
62 void MoveCursorTo(const gfx::Point
& location
) override
;
63 void ConfineCursorToBounds(const gfx::Rect
& bounds
) override
;
64 PlatformImeController
* GetPlatformImeController() override
;
66 // PlatformEventDispatcher:
67 bool CanDispatchEvent(const PlatformEvent
& event
) override
;
68 uint32_t DispatchEvent(const PlatformEvent
& event
) override
;
72 void TryProcessingEvent();
74 // Sync sizes with libcaca.
75 void UpdateDisplaySize();
77 PlatformWindowDelegate
* delegate_
;
78 CacaWindowManager
* manager_
;
79 CacaEventSource
* event_source_
;
80 gfx::AcceleratedWidget widget_
;
82 ScopedCacaCanvas canvas_
;
83 ScopedCacaDisplay display_
;
85 // Size of the console in characters. This can be changed by setting
86 // CACA_GEOMETRY environment variable.
87 gfx::Size physical_size_
;
89 // Size of the backing buffer we draw into. Size in pixels.
90 gfx::Size bitmap_size_
;
92 base::WeakPtrFactory
<CacaWindow
> weak_ptr_factory_
;
94 DISALLOW_COPY_AND_ASSIGN(CacaWindow
);
99 #endif // UI_OZONE_PLATFORM_CACA_CACA_WINDOW_H_