 |
Gorgon Game Engine
|
Go to the documentation of this file.
17 #include "../../Geometry/Point.h"
18 #include "../../Event.h"
19 #include "../../Input.h"
20 #include "../../Input/DnD.h"
21 #include "../../Any.h"
23 #include "../../Window.h"
27 static constexpr
int Success = 0,
None = 0;
45 std::map<Input::Key, ConsumableEvent<Window, Input::Key, bool>::Token>
handlers;
61 namespace WindowManager {
115 struct clipboardentry {
117 std::shared_ptr<CopyFreeAny> data;
119 bool operator ==(
const clipboardentry &other)
const {
120 return type == other.type;
133 Byte *data =
nullptr;
157 extern Display *display;
160 extern Visual *visual;
163 extern Cursor blank_cursor;
169 extern bool xinerama;
173 int waitfor_mapnotify(Display *d, XEvent *e,
char *arg);
175 int waitfor_propertynotify(Display *d, XEvent *e,
char *arg);
177 int waitfor_cppropertynotify(Display *d, XEvent *e,
char *arg);
179 int waitfor_selectionnotify(Display *d, XEvent *e,
char *arg);
183 extern std::vector<clipboardentry> clipboard_entries;
185 void handleclipboardevent(XEvent event);
192 T_ GetX4Prop(Atom atom, ::Window w,
const T_ &def) {
195 unsigned long item_count;
196 unsigned long bytes_left;
200 int status = XGetWindowProperty(
204 0, 4, 0, AnyPropertyType,
205 &actual_type, &actual_format,
206 &item_count, &bytes_left,
210 if(status!=Success)
return def;
212 if(item_count<4 || actual_format!=32)
return def;
214 long *cardinals=
reinterpret_cast<long*
>(data);
bool move
Definition: X11.h:38
Atom XA_WM_NAME
Definition: X11.h:85
Atom XA_ATOM
Definition: X11.h:79
static Geometry::Size GetMinimumRequiredSize()
Returns the minimum size required to fit any window inside.
Definition: WindowManager.cpp:14
void swap(Event< Source_, Args_... > &l, Event< Source_, Args_... > &r)
Swaps two events.
Definition: Event.h:351
Geometry::Point GetMousePosition(Gorgon::internal::windowdata *wind)
Definition: X11.cpp:223
void Initialize()
Initializes window manager system.
Definition: WindowManager.cpp:40
This class represents a window.
Definition: Window.h:31
Atom XA_CP_PROP
Definition: X11.h:98
void handleinputevent(XEvent event, Window &wind)
Definition: Input.cpp:463
Atom XdndActionCopy
Definition: X11.h:107
Graphics::ColorMode GetMode() const
Returns the color mode of the image.
Definition: Image.h:1311
std::map< Input::Key, ConsumableEvent< Window, Input::Key, bool >::Token > handlers
Definition: X11.h:45
basic_Image< Byte > Image
Definition: Image.h:1364
bool focused
Definition: X11.h:42
bool ImportBMP(const std::string &filename, bool dib=false)
Imports a given bitmap file. BMP RLE compression and colorspaces are not supported.
Definition: Image.h:591
static const Monitor * FromLocation(Geometry::Point location)
Returns the monitor from the given location. If none found, will return nullptr.
Definition: WindowManager.h:137
std::vector< Resource::GID::Type > GetClipboardFormats()
Returns the list of formats that is in the clipboard supported by the Gorgon Library.
Definition: Clipboard.cpp:223
Atom XA_PROTOCOLS
Definition: X11.h:69
ColorMode
Color modes for images.
Definition: Color.h:16
constexpr Type Image_Data
Uncompressed image data.
Definition: GID.h:155
bool requested
Definition: X11.h:53
This class provides event mechanism.
Definition: Event.h:134
PNG Png
A ready to use PNG class.
Definition: PNG.cpp:304
Atom XdndFinished
Definition: X11.h:102
void Destroy()
Definition: X11.cpp:274
Atom XA_NET_FRAME_EXTENTS
Definition: X11.h:82
int drop
Definition: X11.h:54
Atom XA_Filelist
Definition: X11.h:110
Atom XA_TEXT
Definition: X11.h:71
T_ X
X coordinate.
Definition: Point.h:368
void CopyToBGRABufferLong(unsigned long *buffer) const
Copies this image to a RGBA buffer, buffer should be resize before calling this function.
Definition: Image.h:536
Atom XA_INCR
Definition: X11.h:81
T_ X
X coordinate of the top left corner of this rectangle.
Definition: Rectangle.h:354
Atom XA_CARDINAL
Definition: X11.h:80
T_ Height
Height of this size object.
Definition: Size.h:261
static const struct Gorgon::Window::FullscreenTag Fullscreen
Definition: WindowManager.cpp:12
Atom XA_NET_REQUEST_FRAME_EXTENTS
Definition: X11.h:84
Atom XdndLeave
Definition: X11.h:105
constexpr Type Text
Stores text data, no longer a resource.
Definition: GID.h:134
Gorgon::internal::windowdata * getdata(const Window &w)
Definition: Window.cpp:15
Atom XA_TARGETS
Definition: X11.h:68
void init()
Definition: X11.cpp:143
constexpr Type URIList
List of URIs, not a resource.
Definition: GID.h:146
bool min
Definition: X11.h:36
void Encode(const Containers::Image &input, std::ostream &output, bool replace_colormode=false)
Encodes a given input.
Definition: PNG.h:163
std::set< KeySym > pressed
Definition: X11.h:46
Atom XdndSelection
Definition: X11.h:100
Atom XA_BMP
Definition: X11.h:78
::Window getanywindow()
Definition: Window.cpp:21
static void Refresh(bool force=false)
Asks WindowManager to refresh the list of monitors.
Definition: Monitor.cpp:86
T_ Width
Width of the rectangle.
Definition: Rectangle.h:360
int GetWidth() const
Returns the width of the image.
Definition: Image.h:1296
void FromImage(const Containers::Image &image)
Definition: X11.cpp:260
constexpr Type URL
URL data, not a resource.
Definition: GID.h:140
Atom XdndActionMove
Definition: X11.h:108
bool pointerdisplayed
Definition: X11.h:37
T_ Left
Left-most boundary.
Definition: Bounds.h:399
Geometry::Point moveto
Definition: X11.h:39
Atom XA_STRING
Definition: X11.h:72
GLXContext context
Definition: X11.h:41
Atom XA_UTF8_STRING
Definition: X11.h:73
Atom XA_WM_CHANGE_STATE
Definition: X11.h:94
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
This class represents a 2D geometric size.
Definition: Size.h:23
Atom XA_JPG
Definition: X11.h:77
~Monitor()
Definition: Monitor.cpp:23
void assertkeys(Window &wind, Gorgon::internal::windowdata *data)
Definition: Input.cpp:267
std::string URIDecode(const std::string &str)
Decodes a given URI string according to RFC 3986. May throw URIError.
Definition: URI.cpp:74
void handledndevent(XEvent event, Window &wind)
Definition: DnD.cpp:312
Atom XA_NET_WM_STATE_ADD
Definition: X11.h:88
void SetClipboardList(std::vector< std::string > list, Resource::GID::Type type=Resource::GID::FileList, bool append=false)
Sets a list of strings to the clipboard.
Definition: Clipboard.cpp:493
std::string GetClipboardText(Resource::GID::Type type=Resource::GID::Text)
Returns the clipboard text.
Definition: Clipboard.cpp:249
Collection is a container for reference typed objects.
Definition: Collection.h:21
basic_Point< int > Point
Definition: Point.h:598
Atom XA_NET_WM_ICON
Definition: X11.h:96
Icon & operator=(const Icon &)=delete
Atom XdndPosition
Definition: X11.h:104
Icon()
Definition: X11.cpp:239
Atom XdndStatus
Definition: X11.h:103
::Window handle
Definition: X11.h:35
Atom XA_STRUT
Definition: X11.h:95
constexpr Type FileList
List of local files, not a resource.
Definition: GID.h:143
bool HasAlpha(ColorMode mode)
Returns if the given color mode has alpha channel.
Definition: Color.h:69
Atom XA_CLIPBOARD
X11 atoms for various data identifiers.
basic_Image Duplicate() const
Duplicates this image, essentially performing the work of copy constructor.
Definition: Image.h:62
Atom XA_PNG
Definition: X11.h:76
Containers::Image GetClipboardBitmap()
Returns a bitmap from the clipboard.
Definition: Clipboard.cpp:541
Atom WM_DELETE_WINDOW
Definition: X11.h:70
Geometry::Point ppoint
Definition: X11.h:43
bool operator==(PointList< P_ > &left, const PointList< P_ > &right)
Comparison: this operation is expensive: O(n).
Definition: PointList.h:385
This class represents a 2D point.
Definition: Point.h:32
Atom XA_NET_WM_STATE_FULLSCREEN
Definition: X11.h:89
Atom XA_NET_WM_STATE_MAXIMIZED_HORZ
Definition: X11.h:90
JPEG Jpg
Definition: JPEG.cpp:327
Atom XA_NET_WM_STATE_MAXIMIZED_VERT
Definition: X11.h:91
Atom XA_NET_ACTIVE_WINDOW
Definition: X11.h:93
Atom XA_NET_WM_NAME
Definition: X11.h:86
unsigned char Byte
Represents smallest cell in memory.
Definition: Types.h:9
static const Containers::Collection< Window > & Windows
List of currently created windows.
Definition: Window.h:401
T_ Y
Y coordinate of the top left corner of this rectangle.
Definition: Rectangle.h:357
void addpadding(const Monitor *monitor, int l, int t, int r, int b)
Definition: Monitor.cpp:27
T_ Right
Right-most boundary.
Definition: Bounds.h:405
Atom XA_NET_WORKAREA
Definition: X11.h:83
T_ Height
Height of the rectangle.
Definition: Rectangle.h:363
Atom XA_TEXT_HTML
Definition: X11.h:74
Atom XA_TIMESTAMP
Definition: X11.h:67
Atom XA_NET_WM_STATE_HIDDEN
Definition: X11.h:92
void PushBackUnique(V_ &vector, T_ &&val)
This function push_backs an item to the given vector if the item does not exists in the vector.
Definition: Vector.h:10
T_ Bottom
Bottom-most boundary.
Definition: Bounds.h:408
bool localpointer
Definition: X11.h:56
bool utf8
Definition: X11.h:50
This class is a container for image data.
Definition: Image.h:19
static bool IsChangeEventSupported()
In some cases, Changed event is not supported.
Definition: Monitor.cpp:179
T_ Y
Y coordinate.
Definition: Point.h:371
Represents an icon object that can be used as window icon.
Definition: WindowManager.h:43
void Decode(std::istream &input, Containers::Image &output)
Decodes the given PNG data.
Definition: PNG.h:186
T_ Width
Width of this size object.
Definition: Size.h:258
std::vector< std::string > GetClipboardList(Resource::GID::Type type=Resource::GID::FileList)
Returns a list of strings from the clipboard.
Definition: Clipboard.cpp:383
constexpr Type HTML
HTML data, not a resource.
Definition: GID.h:137
Atom XdndAware
Definition: X11.h:99
Atom XdndTypeList
Definition: X11.h:109
static Event ChangedEvent
Fires when window manager raises an event about a change in the monitor or screen layout.
Definition: WindowManager.h:161
Type to store GID information.
Definition: GID.h:23
bool ismapped
Definition: X11.h:40
void PushBackOrUpdate(V_ &vector, T_ &&val)
This function push_backs an item to the given vector if the item does not exists in the vector,...
Definition: Vector.h:34
~Icon()
Definition: X11.cpp:282
bool filelist
Definition: X11.h:49
int GetHeight() const
Returns the height of the image.
Definition: Image.h:1301
void Decode(std::istream &input, Containers::Image &output)
Decodes given JPG data from the given input and creates the image.
Definition: JPEG.h:130
void SetClipboardText(const std::string &text, Resource::GID::Type type=Resource::GID::Text, bool unicode=true, bool append=false)
Sets the clipboard text to given string.
Definition: Clipboard.cpp:350
Atom XA_URL
Definition: X11.h:75
Represents a rectangle in a 2D space.
Definition: Rectangle.h:19
Atom XdndDrop
Definition: X11.h:106
Atom XA_PRIMARY
Definition: X11.h:97
Input::Mouse::Button buttonfromx11(unsigned btn)
Definition: Input.cpp:74
Input::Keyboard::Key mapx11key(KeySym key, unsigned int keycode)
Definition: Input.cpp:100
void Encode(Containers::Image &input, std::ostream &output, int quality=90)
Encode given image to JPG compressed data.
Definition: JPEG.h:162
std::string xeventname(XEvent &event)
Definition: X11.cpp:289
Atom XA_NET_WM_STATE
Definition: X11.h:87
intptr_t CurrentContext()
Returns an identifier for the current context.
Definition: WindowManager.cpp:34
struct Gorgon::internal::windowdata::xdnddata xdnd
std::string GetAtomName(Atom atom)
Definition: X11.cpp:215
Definition: WindowManager.h:84
Atom XdndEnter
Definition: X11.h:101
T_ Top
Top-most boundary.
Definition: Bounds.h:402
void SetClipboardBitmap(Containers::Image img, bool append=false)
Changes the clipboard to the given image.
Definition: Clipboard.cpp:668