This creates a window with the given options. The window will be visible and able to receive input as soon as you start your event loop. You may draw on it immediately after creating the window, without needing to wait for the event loop to start if you want.
Same as above, except using the Size struct instead of separate width and height.
Creates a window based on the given Image. It's client area width and height is equal to the image. (A window's client area is the drawable space inside; it excludes the title bar, etc.)
Wraps a native window handle with very little additional processing - notably no destruction this is incomplete so don't use it for much right now. The purpose of this is to make native windows created through the low level API (so you can use platform-specific options and other details SimpleWindow does not expose) available to the event loop wrappers.
A destructor is present on this object, but not explicitly documented in the source.
Returns the actual logical DPI for the window on its current display monitor. If the window straddles monitors, it will return the value of one or the other in a platform-defined manner.
Add listener for custom event. Can be used like this:
Emit a beep to get user's attention.
Closes the window. If there are no more open windows, the event loop will terminate.
close is one of the few methods that can be called from other threads. This shared overload reflects that.
Style of the window's corners
Style of the window's corners
This lets you draw on the window (or its backing buffer) using basic 2D primitives.
The event loop automatically returns when the window is closed pulseTimeout is given in milliseconds. If pulseTimeout == 0, no pulse timer is created. The event loop will block until an event arrives or the pulse timer goes off.
This is the function eventLoop forwards to. It, in turn, forwards to EventLoop.get.run.
Sets the input focus to this window.
not fully implemented but planned for a future release
Get the title as set by the window manager. May not match what you attempted to set.
Grabs exclusive input from the user until you release it with releaseInputGrab.
Alias for hidden = true
Hide cursor when it enters the window.
Note: only implemented on Windows. No-op on other platforms. You may want to use hide instead.
Move window.
Move and resize window (this can be faster and more visually pleasant than doing it separately).
"Lock" this window handle, to do multithreaded synchronization. You probably won't need to call this, as it's not recommended to share window between threads.
"Unlock" this window handle, to do multithreaded synchronization. You probably won't need to call this, as it's not recommended to share window between threads.
Returns the native window.
Sets the window opacity. On X11 this requires a compositor to be running. On windows the WindowFlags.extraComposite must be set at window creation.
Post event to queue. It is safe to call this from non-UI threads. if replace is true, replace all existing events typed ET with the new one (if evt is empty, remove 'em all) Returns true if event was queued. Always returns false if evt is null.
Post event to queue. It is safe to call this from non-UI threads. If timeoutmsecs is greater than zero, the event will be delayed for at least timeoutmsecs milliseconds. if replace is true, replace all existing events typed ET with the new one (if evt is empty, remove 'em all) Returns true if event was queued. Always returns false if evt is null.
call this to invoke your delegate. It automatically sets up the context and flips the buffer. If you need to redraw the scene in response to an event, call this.
Queues an opengl redraw as soon as the other pending events are cleared.
Releases OpenGL context, so it can be reused in, for example, different thread. This is only valid if you passed OpenGlOptions.yes to the constructor. This doesn't throw, returning success flag instead.
Releases the grab acquired by grabInput.
Remove event listener. It is safe to pass invalid event id here.
Requests attention from the user for this window.
Resize window.
Send dummy window event to ping event loop. Required to process NotificationIcon on X11, for example.
Makes all gl* functions target this window until changed. This is only valid if you passed OpenGlOptions.yes to the constructor.
Makes all gl* functions target this window until changed. This is only valid if you passed OpenGlOptions.yes to the constructor. This doesn't throw, returning success flag instead.
Sets your event handlers, without entering the event loop. Useful if you have multiple windows - set the handlers on each window, then only do eventLoop on your main window or call EventLoop.get.run();.
Tells the IME whether or not an input field is currently focused in the window.
Sets the location for the IME (input method editor) to pop up when the user activates it.
Set window maximal size.
Set window minimal size.
Set window resize step (window size will be changed with the given granularity on supported platforms). Currently only supported on X11.
Alias for hidden = false
Don't hide cursor when it enters the window.
simpledisplay always uses double buffering, usually automatically. This manually swaps the OpenGL buffers.
Copies the window's current state into a TrueColorImage.
"Warp" mouse pointer to coordinates relative to window top-left corner. Return "success" flag.
The native implementation is available, but you shouldn't use it unless you are familiar with the underlying operating system, don't mind depending on it, and know simpledisplay.d's internals too. It is virtually private; you can hopefully do what you need to do with handleNativeEvent instead.
Returns the actual size of the window, bypassing the logical illusions of Resizability.automaticallyScaleIfPossible.
Returns true if the window has been closed.
Changes the cursor for the window. If the cursor is hidden via hideCursor, this has no effect.
Is our custom event queue empty? Can be used in simple cases to prevent "spamming" window with events it can't cope with. It is safe to call this from non-UI threads.
Does our custom event queue contains at least one with the given type? Can be used in simple cases to prevent "spamming" window with events it can't cope with. It is safe to call this from non-UI threads.
Returns true if the window is focused.
Height of the window's drawable client area, in pixels.
Returns true if the window is hidden.
Shows or hides the window based on the bool argument.
Set the icon that is seen in the title bar or taskbar, etc., for the user. If passed null, does nothing.
Draws an image on the window. This is meant to provide quick look of a static image generated elsewhere.
true if OpenGL was initialized for this window.
Set the window title, which is visible on the window manager title bar, operating system taskbar, etc.
Gets the title
Returns true if the window is visible (mapped).
This will allow you to change OpenGL vsync state.
Width of the window's drawable client area, in pixels.
This is the same as handleNativeEvent, but static so it can hook ALL events in the loop. If you used to use handleNativeEvent depending on it being static, just change it to use this instead and it will work the same way.
This will be called when WM wants to close your window (i.e. user clicked "close" icon, for example). You'll have to call close() manually if you set this delegate.
Event listeners added with addEventListener have their exceptions swallowed by the event loop. This delegate can handle them again before it proceeds.
Handles a higher level keyboard event - c is the character just pressed. Settable through setEventHandlers.
Called when Expose event comes. See Xlib manual to understand the arguments. * Return false if you want Simpledisplay to copy backbuffer, or true if you did it yourself. * You will probably never need to setup this handler, it is for very low-level stuff. * * WARNING! Xlib is multithread-locked when this handles is called!
What follows are the event handlers. These are set automatically by the eventLoop function, but are still public so you can change them later. wasPressed == true means key down. false == key up. Handles a low-level keyboard event. Settable through setEventHandlers.
Mouse event handler. Settable through setEventHandlers.
Platform specific - handle any native message this window gets.
Handles a timer pulse. Settable through setEventHandlers.
Called inside close() method. Our window is still alive, and we can free various resources. * Sometimes it is easier to setup the delegate instead of subclassing.
Called when we received destroy notification. At this stage we cannot do much with our window * (as it is already dead, and it's native handle cannot be used), but we still can do some * last minute cleanup.
Sent when the window is moved to a new DPI context, for example, when it is dragged between monitors or if the window is moved to a new remote connection or a monitor is hot-swapped.
Called when the focus changes, param is if we have it (true) or are losing it (false).
use to redraw child widgets if you use system apis to add stuff
Put your code in here that you want to be drawn automatically when your window is uncovered. Set a handler here *before* entering your event loop any time you pass OpenGlOptions.yes to the constructor. Ideally, you will set this delegate immediately after constructing the SimpleWindow.
Used iff WindowFlags.managesChildWindowFocus is set when the window is created. The delegate will be called when the window manager asks you to take focus.
When in opengl mode and automatically resizing, it will set the opengl viewport to stretch.
Set this to false if you don't need to do glFinish() after swapOpenGlBuffers(). Note that at least NVidia proprietary driver may segfault if you will modify texture fast enough without waiting 'em to finish their frame business.
This will be called when window visibility was changed.
handle a resize, after it happens. You must construct the window with Resizability.allowResizing for this to ever happen.
Be warned: this can be a very slow operation
SimpleWindow tries to make ordinary windows very easy to create and use without locking you out of more advanced or complex features of the underlying windowing system.
For many applications, you can simply call new SimpleWindow(some_width, some_height, "some title") and get a suitable window to work with.
From there, you can opt into additional features, like custom resizability and OpenGL support with the next two constructor arguments. Or, if you need even more, you can set a window type and customization flags with the final two constructor arguments.
If none of that works for you, you can also create a window using native function calls, then wrap the window in a SimpleWindow instance by calling new SimpleWindow(native_handle). Remember, though, if you do this, managing the window is still your own responsibility! Notably, you will need to destroy it yourself.
The flagship window class.