Path: blob/master/thirdparty/linuxbsd_headers/libdecor-0/libdecor.h
9904 views
/*1* Copyright © 2017-2018 Red Hat Inc.2* Copyright © 2018 Jonas Ådahl3* Copyright © 2019 Christian Rauch4*5* Permission is hereby granted, free of charge, to any person obtaining6* a copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sublicense, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial15* portions of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,18* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND20* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS21* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN22* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN23* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE24* SOFTWARE.25*/2627#ifndef LIBDECOR_H28#define LIBDECOR_H2930#include <stdbool.h>31#include <wayland-client.h>3233#ifdef __cplusplus34extern "C" {35#endif3637#if defined(__GNUC__) && __GNUC__ >= 438#define LIBDECOR_EXPORT __attribute__ ((visibility("default")))39#else40#define LIBDECOR_EXPORT41#endif4243struct xdg_toplevel;4445/** \class libdecor46*47* \brief A libdecor context instance.48*/49struct libdecor;5051/** \class libdecor_frame52*53* \brief A frame used for decorating a Wayland surface.54*/55struct libdecor_frame;5657/** \class libdecor_configuration58*59* \brief An object representing a toplevel window configuration.60*/61struct libdecor_configuration;6263/** \class libdecor_state64*65* \brief An object corresponding to a configured content state.66*/67struct libdecor_state;6869enum libdecor_error {70LIBDECOR_ERROR_COMPOSITOR_INCOMPATIBLE,71LIBDECOR_ERROR_INVALID_FRAME_CONFIGURATION,72};7374enum libdecor_window_state {75LIBDECOR_WINDOW_STATE_NONE = 0,76LIBDECOR_WINDOW_STATE_ACTIVE = 1 << 0,77LIBDECOR_WINDOW_STATE_MAXIMIZED = 1 << 1,78LIBDECOR_WINDOW_STATE_FULLSCREEN = 1 << 2,79LIBDECOR_WINDOW_STATE_TILED_LEFT = 1 << 3,80LIBDECOR_WINDOW_STATE_TILED_RIGHT = 1 << 4,81LIBDECOR_WINDOW_STATE_TILED_TOP = 1 << 5,82LIBDECOR_WINDOW_STATE_TILED_BOTTOM = 1 << 6,83LIBDECOR_WINDOW_STATE_SUSPENDED = 1 << 7,84};8586enum libdecor_resize_edge {87LIBDECOR_RESIZE_EDGE_NONE,88LIBDECOR_RESIZE_EDGE_TOP,89LIBDECOR_RESIZE_EDGE_BOTTOM,90LIBDECOR_RESIZE_EDGE_LEFT,91LIBDECOR_RESIZE_EDGE_TOP_LEFT,92LIBDECOR_RESIZE_EDGE_BOTTOM_LEFT,93LIBDECOR_RESIZE_EDGE_RIGHT,94LIBDECOR_RESIZE_EDGE_TOP_RIGHT,95LIBDECOR_RESIZE_EDGE_BOTTOM_RIGHT,96};9798enum libdecor_capabilities {99LIBDECOR_ACTION_MOVE = 1 << 0,100LIBDECOR_ACTION_RESIZE = 1 << 1,101LIBDECOR_ACTION_MINIMIZE = 1 << 2,102LIBDECOR_ACTION_FULLSCREEN = 1 << 3,103LIBDECOR_ACTION_CLOSE = 1 << 4,104};105106struct libdecor_interface {107/**108* An error event109*/110void (* error)(struct libdecor *context,111enum libdecor_error error,112const char *message);113114/* Reserved */115void (* reserved0)(void);116void (* reserved1)(void);117void (* reserved2)(void);118void (* reserved3)(void);119void (* reserved4)(void);120void (* reserved5)(void);121void (* reserved6)(void);122void (* reserved7)(void);123void (* reserved8)(void);124void (* reserved9)(void);125};126127/**128* Interface for integrating a Wayland surface with libdecor.129*/130struct libdecor_frame_interface {131/**132* A new configuration was received. An application should respond to133* this by creating a suitable libdecor_state, and apply it using134* libdecor_frame_commit.135*/136void (* configure)(struct libdecor_frame *frame,137struct libdecor_configuration *configuration,138void *user_data);139140/**141* The window was requested to be closed by the compositor.142*/143void (* close)(struct libdecor_frame *frame,144void *user_data);145146/**147* The window decoration asked to have the main surface to be148* committed. This is required when the decoration is implemented using149* synchronous subsurfaces.150*/151void (* commit)(struct libdecor_frame *frame,152void *user_data);153154/**155* Any mapped popup that has a grab on the given seat should be156* dismissed.157*/158void (* dismiss_popup)(struct libdecor_frame *frame,159const char *seat_name,160void *user_data);161162/* Reserved */163void (* reserved0)(void);164void (* reserved1)(void);165void (* reserved2)(void);166void (* reserved3)(void);167void (* reserved4)(void);168void (* reserved5)(void);169void (* reserved6)(void);170void (* reserved7)(void);171void (* reserved8)(void);172void (* reserved9)(void);173};174175/**176* Remove a reference to the libdecor instance. When the reference count177* reaches zero, it is freed.178*/179void180libdecor_unref(struct libdecor *context);181182/**183* Create a new libdecor context for the given wl_display.184*/185struct libdecor *186libdecor_new(struct wl_display *display,187struct libdecor_interface *iface);188189/**190* Get the file descriptor used by libdecor. This is similar to191* wl_display_get_fd(), thus should be polled, and when data is available,192* libdecor_dispatch() should be called.193*/194int195libdecor_get_fd(struct libdecor *context);196197/**198* Dispatch events. This function should be called when data is available on199* the file descriptor returned by libdecor_get_fd(). If timeout is zero, this200* function will never block.201*/202int203libdecor_dispatch(struct libdecor *context,204int timeout);205206/**207* Decorate the given content wl_surface.208*209* This will create an xdg_surface and an xdg_toplevel, and integrate it210* properly with the windowing system, including creating appropriate211* decorations when needed, as well as handle windowing integration events such212* as resizing, moving, maximizing, etc.213*214* The passed wl_surface should only contain actual application content,215* without any window decoration.216*/217struct libdecor_frame *218libdecor_decorate(struct libdecor *context,219struct wl_surface *surface,220struct libdecor_frame_interface *iface,221void *user_data);222223/**224* Add a reference to the frame object.225*/226void227libdecor_frame_ref(struct libdecor_frame *frame);228229/**230* Remove a reference to the frame object. When the reference count reaches231* zero, the frame object is destroyed.232*/233void234libdecor_frame_unref(struct libdecor_frame *frame);235236/**237* Set the visibility of the frame.238*239* If an application wants to be borderless, it can set the frame visibility to240* false.241*/242void243libdecor_frame_set_visibility(struct libdecor_frame *frame,244bool visible);245246/**247* Get the visibility of the frame.248*/249bool250libdecor_frame_is_visible(struct libdecor_frame *frame);251252253/**254* Set the parent of the window.255*256* This can be used to stack multiple toplevel windows above or under each257* other.258*/259void260libdecor_frame_set_parent(struct libdecor_frame *frame,261struct libdecor_frame *parent);262263/**264* Set the title of the window.265*/266void267libdecor_frame_set_title(struct libdecor_frame *frame,268const char *title);269270/**271* Get the title of the window.272*/273const char *274libdecor_frame_get_title(struct libdecor_frame *frame);275276/**277* Set the application ID of the window.278*/279void280libdecor_frame_set_app_id(struct libdecor_frame *frame,281const char *app_id);282283/**284* Set new capabilities of the window.285*286* This determines whether e.g. a window decoration should show a maximize287* button, etc.288*289* Setting a capability does not implicitly unset any other.290*/291void292libdecor_frame_set_capabilities(struct libdecor_frame *frame,293enum libdecor_capabilities capabilities);294295/**296* Unset capabilities of the window.297*298* The opposite of libdecor_frame_set_capabilities.299*/300void301libdecor_frame_unset_capabilities(struct libdecor_frame *frame,302enum libdecor_capabilities capabilities);303304/**305* Check whether the window has any of the given capabilities.306*/307bool308libdecor_frame_has_capability(struct libdecor_frame *frame,309enum libdecor_capabilities capability);310311/**312* Show the window menu.313*/314void315libdecor_frame_show_window_menu(struct libdecor_frame *frame,316struct wl_seat *wl_seat,317uint32_t serial,318int x,319int y);320321/**322* Issue a popup grab on the window. Call this when a xdg_popup is mapped, so323* that it can be properly dismissed by the decorations.324*/325void326libdecor_frame_popup_grab(struct libdecor_frame *frame,327const char *seat_name);328329/**330* Release the popup grab. Call this when you unmap a popup.331*/332void333libdecor_frame_popup_ungrab(struct libdecor_frame *frame,334const char *seat_name);335336/**337* Translate content surface local coordinates to toplevel window local338* coordinates.339*340* This can be used to translate surface coordinates to coordinates useful for341* e.g. showing the window menu, or positioning a popup.342*/343void344libdecor_frame_translate_coordinate(struct libdecor_frame *frame,345int surface_x,346int surface_y,347int *frame_x,348int *frame_y);349350/**351* Set the min content size.352*353* This translates roughly to xdg_toplevel_set_min_size().354*/355void356libdecor_frame_set_min_content_size(struct libdecor_frame *frame,357int content_width,358int content_height);359360/**361* Set the max content size.362*363* This translates roughly to xdg_toplevel_set_max_size().364*/365void366libdecor_frame_set_max_content_size(struct libdecor_frame *frame,367int content_width,368int content_height);369370/**371* Get the min content size.372*/373void374libdecor_frame_get_min_content_size(const struct libdecor_frame *frame,375int *content_width,376int *content_height);377378/**379* Get the max content size.380*/381void382libdecor_frame_get_max_content_size(const struct libdecor_frame *frame,383int *content_width,384int *content_height);385386/**387* Initiate an interactive resize.388*389* This roughly translates to xdg_toplevel_resize().390*/391void392libdecor_frame_resize(struct libdecor_frame *frame,393struct wl_seat *wl_seat,394uint32_t serial,395enum libdecor_resize_edge edge);396397/**398* Initiate an interactive move.399*400* This roughly translates to xdg_toplevel_move().401*/402void403libdecor_frame_move(struct libdecor_frame *frame,404struct wl_seat *wl_seat,405uint32_t serial);406407/**408* Commit a new window state. This can be called on application driven resizes409* when the window is floating, or in response to received configurations, i.e.410* from e.g. interactive resizes or state changes.411*/412void413libdecor_frame_commit(struct libdecor_frame *frame,414struct libdecor_state *state,415struct libdecor_configuration *configuration);416417/**418* Minimize the window.419*420* Roughly translates to xdg_toplevel_set_minimized().421*/422void423libdecor_frame_set_minimized(struct libdecor_frame *frame);424425/**426* Maximize the window.427*428* Roughly translates to xdg_toplevel_set_maximized().429*/430void431libdecor_frame_set_maximized(struct libdecor_frame *frame);432433/**434* Unmaximize the window.435*436* Roughly translates to xdg_toplevel_unset_maximized().437*/438void439libdecor_frame_unset_maximized(struct libdecor_frame *frame);440441/**442* Fullscreen the window.443*444* Roughly translates to xdg_toplevel_set_fullscreen().445*/446void447libdecor_frame_set_fullscreen(struct libdecor_frame *frame,448struct wl_output *output);449450/**451* Unfullscreen the window.452*453* Roughly translates to xdg_toplevel_unset_unfullscreen().454*/455void456libdecor_frame_unset_fullscreen(struct libdecor_frame *frame);457458/**459* Return true if the window is floating.460*461* A window is floating when it's not maximized, tiled, fullscreen, or in any462* similar way with a fixed size and state.463* Note that this function uses the "applied" configuration. If this function464* is used in the 'configure' callback, the provided configuration has to be465* applied via 'libdecor_frame_commit' first, before it will reflect the current466* window state from the provided configuration.467*/468bool469libdecor_frame_is_floating(struct libdecor_frame *frame);470471/**472* Close the window.473*474* Roughly translates to xdg_toplevel_close().475*/476void477libdecor_frame_close(struct libdecor_frame *frame);478479/**480* Map the window.481*482* This will eventually result in the initial configure event.483*/484void485libdecor_frame_map(struct libdecor_frame *frame);486487/**488* Get the associated xdg_surface for content wl_surface.489*/490struct xdg_surface *491libdecor_frame_get_xdg_surface(struct libdecor_frame *frame);492493/**494* Get the associated xdg_toplevel for the content wl_surface.495*/496struct xdg_toplevel *497libdecor_frame_get_xdg_toplevel(struct libdecor_frame *frame);498499/**500* Create a new content surface state.501*/502struct libdecor_state *503libdecor_state_new(int width,504int height);505506/**507* Free a content surface state.508*/509void510libdecor_state_free(struct libdecor_state *state);511512/**513* Get the expected size of the content for this configuration.514*515* If the configuration doesn't contain a size, false is returned.516*/517bool518libdecor_configuration_get_content_size(struct libdecor_configuration *configuration,519struct libdecor_frame *frame,520int *width,521int *height);522523/**524* Get the window state for this configuration.525*526* If the configuration doesn't contain any associated window state, false is527* returned, and the application should assume the window state remains528* unchanged.529*/530bool531libdecor_configuration_get_window_state(struct libdecor_configuration *configuration,532enum libdecor_window_state *window_state);533534#ifdef __cplusplus535}536#endif537538#endif /* LIBDECOR_H */539540541