1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
/*
* Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
* (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com>
*
* This file is part of lsp-ws-lib
* Created on: 10 окт. 2016 г.
*
* lsp-ws-lib is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* lsp-ws-lib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with lsp-ws-lib. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef UI_X11_WINDOW_H_
#define UI_X11_WINDOW_H_
#include <lsp-plug.in/ws/version.h>
#ifdef USE_LIBX11
#include <lsp-plug.in/common/types.h>
#include <lsp-plug.in/common/status.h>
#include <lsp-plug.in/ws/IEventHandler.h>
#include <lsp-plug.in/ws/IWindow.h>
namespace lsp
{
namespace ws
{
namespace x11
{
class X11Display;
class LSP_HIDDEN_MODIFIER X11Window: public IWindow, public IEventHandler
{
protected:
enum flags_t
{
F_GRABBING = 1 << 0,
F_LOCKING = 1 << 1
};
typedef struct btn_event_t
{
event_t sDown;
event_t sUp;
} btn_event_t;
public:
X11Display *pX11Display;
::Window hWindow;
::Window hParent;
::Window hTransientFor;
ISurface *pSurface;
border_style_t enBorderStyle;
motif_hints_t sMotif;
size_t nActions;
size_t nScreen;
size_t nFlags;
mouse_pointer_t enPointer;
bool bWrapper;
bool bVisible;
rectangle_t sSize;
size_limit_t sConstraints;
btn_event_t vBtnEvent[3];
protected:
void drop_surface();
void do_create();
static bool check_click(const btn_event_t *ev);
static bool check_double_click(const btn_event_t *pe, const btn_event_t *ce);
void send_focus_event();
status_t commit_size();
protected:
void calc_constraints(rectangle_t *dst, const rectangle_t *req);
status_t do_update_constraints(bool disable=false);
public:
explicit X11Window(X11Display *core, size_t screen, ::Window wnd, IEventHandler *handler, bool wrapper);
virtual ~X11Window();
/** Window initialization routine
*
* @return status of operation
*/
virtual status_t init() override;
/** Window finalization routine
*
*/
virtual void destroy() override;
public:
inline ::Window x11handle() const { return hWindow; }
inline ::Window x11parent() const { return hParent; }
public:
virtual ISurface *get_surface() override;
virtual status_t invalidate() override;
virtual ssize_t left() override;
virtual ssize_t top() override;
virtual ssize_t width() override;
virtual ssize_t height() override;
virtual status_t set_left(ssize_t left) override;
virtual status_t set_top(ssize_t top) override;
virtual ssize_t set_width(ssize_t width) override;
virtual ssize_t set_height(ssize_t height) override;
virtual status_t set_geometry(const rectangle_t *realize) override;
virtual status_t get_geometry(rectangle_t *realize) override;
virtual status_t get_absolute_geometry(rectangle_t *realize) override;
virtual void *handle() override;
virtual size_t screen() override;
virtual status_t move(ssize_t left, ssize_t top) override;
virtual status_t resize(ssize_t width, ssize_t height) override;
virtual status_t set_border_style(border_style_t style) override;
virtual status_t get_border_style(border_style_t *style) override;
virtual bool is_visible() override;
virtual status_t hide() override;
virtual status_t show() override;
virtual status_t show(IWindow *over) override;
virtual status_t grab_events(grab_t group) override;
virtual status_t ungrab_events() override;
virtual bool is_grabbing_events() const override;
virtual status_t set_size_constraints(const size_limit_t *c) override;
virtual status_t get_size_constraints(size_limit_t *c) override;
virtual status_t take_focus() override;
virtual status_t set_caption(const char *caption) override;
virtual status_t set_caption(const LSPString *caption) override;
virtual status_t get_caption(char *text, size_t len) override;
virtual status_t get_caption(LSPString *text) override;
virtual status_t set_icon(const void *bgra, size_t width, size_t height) override;
virtual status_t get_window_actions(size_t *actions) override;
virtual status_t set_window_actions(size_t actions) override;
virtual status_t set_mouse_pointer(mouse_pointer_t ponter) override;
virtual mouse_pointer_t get_mouse_pointer() override;
virtual status_t set_class(const char *instance, const char *wclass) override;
virtual status_t set_role(const char *wrole) override;
virtual bool has_parent() const override;
public:
virtual status_t handle_event(const event_t *ev) override;
};
} /* namespace x11 */
} /* namespace ws */
} /* namespace lsp */
#endif /* USE_LIBX11 */
#endif /* UI_X11_WINDOW_H_ */
|