1 /*
2 * DSFML - The Simple and Fast Multimedia Library for D
3 *
4 * Copyright (c) 2013 - 2017 Jeremy DeHaan (dehaan.jeremiah@gmail.com)
5 *
6 * This software is provided 'as-is', without any express or implied warranty.
7 * In no event will the authors be held liable for any damages arising from the
8 * use of this software.
9 *
10 * Permission is granted to anyone to use this software for any purpose,
11 * including commercial applications, and to alter it and redistribute it
12 * freely, subject to the following restrictions:
13 *
14 * 1. The origin of this software must not be misrepresented; you must not claim
15 * that you wrote the original software. If you use this software in a product,
16 * an acknowledgment in the product documentation would be appreciated but is
17 * not required.
18 *
19 * 2. Altered source versions must be plainly marked as such, and must not be
20 * misrepresented as being the original software.
21 *
22 * 3. This notice may not be removed or altered from any source distribution
23 */24 25 /**
26 * $(U Window) is the main class of the Window module. It defines an OS window
27 * that is able to receive an OpenGL rendering.
28 *
29 * A $(U Window) can create its own new window, or be embedded into an already
30 * existing control using the create(handle) function. This can be useful for
31 * embedding an OpenGL rendering area into a view which is part of a bigger GUI
32 * with existing windows, controls, etc. It can also serve as embedding an
33 * OpenGL rendering area into a window created by another (probably richer) GUI
34 * library like Qt or wxWidgets.
35 *
36 * The $(U Window) class provides a simple interface for manipulating the
37 * window: move, resize, show/hide, control mouse cursor, etc. It also provides
38 * event handling through its `pollEvent()` and `waitEvent()` functions.
39 *
40 * Note that OpenGL experts can pass their own parameters (antialiasing level
41 * bits for the depth and stencil buffers, etc.) to the OpenGL context attached
42 * to the window, with the $(CONTEXTSETTINGS_LINK) structure which is passed as
43 * an optional argument when creating the window.
44 *
45 * Example:
46 * ---
47 * // Declare and create a new window
48 * auto window = new Window(VideoMode(800, 600), "DSFML window");
49 *
50 * // Limit the framerate to 60 frames per second (this step is optional)
51 * window.setFramerateLimit(60);
52 *
53 * // The main loop - ends as soon as the window is closed
54 * while (window.isOpen())
55 * {
56 * // Event processing
57 * Event event;
58 * while (window.pollEvent(event))
59 * {
60 * // Request for closing the window
61 * if (event.type == Event.EventType.Closed)
62 * window.close();
63 * }
64 *
65 * // Activate the window for OpenGL rendering
66 * window.setActive();
67 *
68 * // OpenGL drawing commands go here...
69 *
70 * // End the current frame and display its contents on screen
71 * window.display();
72 * }
73 * ---
74 */75 moduledsfml.window.window;
76 77 importdsfml.window.event;
78 importdsfml.window.videomode;
79 importdsfml.window.contextsettings;
80 importdsfml.window.windowhandle;
81 importdsfml.system.vector2;
82 importdsfml.system.err;
83 84 /**
85 * Window that serves as a target for OpenGL rendering.
86 */87 classWindow88 {
89 /// Choices for window style90 enumStyle91 {
92 None = 0,
93 Titlebar = 1 << 0,
94 Resize = 1 << 1,
95 Close = 1 << 2,
96 Fullscreen = 1 << 3,
97 DefaultStyle = Titlebar | Resize | Close98 }
99 100 packagesfWindow* sfPtr;
101 102 //let's RenderWindow inherit from Window without trying to delete the null103 //pointer104 privateboolm_needsToDelete = true;
105 106 /// Default constructor.107 this()
108 {
109 sfPtr = sfWindow_construct();
110 }
111 112 //Construct a window without calling sfWindow_construct113 //This allows a RenderWindow to be created without creating a Window first114 protectedthis(int)
115 {
116 m_needsToDelete = false;
117 }
118 119 //allows RenderWindow to delete the Window pointer when it is created120 //so that there are not both instances.121 protectedvoiddeleteWindowPtr()
122 {
123 sfWindow_destroy(sfPtr);
124 m_needsToDelete = false;
125 }
126 127 /**
128 * Construct a new window.
129 *
130 * This constructor creates the window with the size and pixel depth defined
131 * in mode. An optional style can be passed to customize the look and
132 * behaviour of the window (borders, title bar, resizable, closable, ...).
133 * If style contains Style::Fullscreen, then mode must be a valid video
134 * mode.
135 *
136 * The fourth parameter is an optional structure specifying advanced OpenGL
137 * context settings such as antialiasing, depth-buffer bits, etc.
138 *
139 * Params:
140 * mode = Video mode to use (defines the width, height and depth of the
141 * rendering area of the window)
142 * title = Title of the window
143 * style = Window style
144 * settings = Additional settings for the underlying OpenGL context
145 */146 this(T)(VideoModemode, immutable(T)[] title, Stylestyle = Style.DefaultStyle, ContextSettingssettings = ContextSettings.init)
147 if (is(T == dchar)||is(T == wchar)||is(T == char))
148 {
149 this();
150 create(mode, title, style, settings);
151 }
152 153 /**
154 * Construct the window from an existing control.
155 *
156 * Use this constructor if you want to create an OpenGL rendering area into
157 * an already existing control.
158 *
159 * The second parameter is an optional structure specifying advanced OpenGL
160 * context settings such as antialiasing, depth-buffer bits, etc.
161 *
162 * Params:
163 * handle = Platform-specific handle of the control
164 * settings = Additional settings for the underlying OpenGL context
165 */166 this(WindowHandlehandle, ContextSettingssettings = ContextSettings.init)
167 {
168 this();
169 create(handle, settings);
170 }
171 172 /// Destructor.173 ~this()
174 {
175 importdsfml.system.config;
176 //this takes care of not freeing a null pointer due to inheritance177 //(RenderWindow does not create the inherited sfWindow)178 if(m_needsToDelete)
179 {
180 mixin(destructorOutput);
181 sfWindow_destroy(sfPtr);
182 }
183 }
184 185 /**
186 * Get's or set's the window's position.
187 *
188 * This function only works for top-level windows (i.e. it will be ignored
189 * for windows created from the handle of a child window/control).
190 */191 @property192 {
193 Vector2iposition(Vector2inewPosition)
194 {
195 sfWindow_setPosition(sfPtr,newPosition.x, newPosition.y);
196 returnnewPosition;
197 }
198 199 Vector2iposition()
200 {
201 Vector2itemp;
202 sfWindow_getPosition(sfPtr,&temp.x, &temp.y);
203 returntemp;
204 }
205 }
206 207 ///Get's or set's the window's size.208 @property209 {
210 Vector2usize(Vector2unewSize)
211 {
212 sfWindow_setSize(sfPtr, newSize.x, newSize.y);
213 returnnewSize;
214 }
215 Vector2usize()
216 {
217 Vector2utemp;
218 sfWindow_getSize(sfPtr,&temp.x, &temp.y);
219 returntemp;
220 }
221 }
222 223 /**
224 * Activate or deactivate the window as the current target for OpenGL
225 * rendering.
226 *
227 * A window is active only on the current thread, if you want to make it
228 * active on another thread you have to deactivate it on the previous thread
229 * first if it was active. Only one window can be active on a thread at a
230 * time, thus the window previously active (if any) automatically gets
231 * deactivated.
232 *
233 * Params:
234 * active = true to activate, false to deactivate
235 *
236 * Returns: true if operation was successful, false otherwise.
237 */238 boolsetActive(boolactive)
239 {
240 importdsfml.system..string;
241 booltoReturn = sfWindow_setActive(sfPtr, active);
242 err.write(dsfml.system..string.toString(sfErr_getOutput()));
243 returntoReturn;
244 }
245 246 ///Request the current window to be made the active foreground window.247 voidrequestFocus()
248 {
249 sfWindow_requestFocus(sfPtr);
250 }
251 252 /**
253 * Check whether the window has the input focus
254 *
255 * Returns: true if the window has focus, false otherwise
256 */257 boolhasFocus() const258 {
259 returnsfWindow_hasFocus(sfPtr);
260 }
261 262 /**
263 * Limit the framerate to a maximum fixed frequency.
264 *
265 * If a limit is set, the window will use a small delay after each call to
266 * display() to ensure that the current frame lasted long enough to match
267 * the framerate limit. SFML will try to match the given limit as much as it
268 * can, but since it internally uses dsfml.system.sleep, whose precision
269 * depends on the underlying OS, the results may be a little unprecise as
270 * well (for example, you can get 65 FPS when requesting 60).
271 *
272 * Params:
273 * limit = Framerate limit, in frames per seconds (use 0 to disable limit).
274 */275 voidsetFramerateLimit(uintlimit)
276 {
277 sfWindow_setFramerateLimit(sfPtr, limit);
278 }
279 280 /**
281 * Change the window's icon.
282 *
283 * pixels must be an array of width x height pixels in 32-bits RGBA format.
284 *
285 * The OS default icon is used by default.
286 *
287 * Params:
288 * width = Icon's width, in pixels
289 * height = Icon's height, in pixels
290 * pixels = Pointer to the array of pixels in memory
291 */292 voidsetIcon(uintwidth, uintheight, const(ubyte[]) pixels)
293 {
294 sfWindow_setIcon(sfPtr,width, height, pixels.ptr);
295 }
296 297 /**
298 * Change the joystick threshold.
299 *
300 * The joystick threshold is the value below which no JoystickMoved event
301 * will be generated.
302 *
303 * The threshold value is 0.1 by default.
304 *
305 * Params:
306 * threshold = New threshold, in the range [0, 100].
307 */308 voidsetJoystickThreshold(floatthreshold)
309 {
310 sfWindow_setJoystickThreshold(sfPtr, threshold);
311 }
312 313 /**
314 * Change the joystick threshold.
315 *
316 * The joystick threshold is the value below which no JoystickMoved event
317 * will be generated.
318 *
319 * The threshold value is 0.1 by default.
320 *
321 * Params:
322 * threshold = New threshold, in the range [0, 100].
323 *
324 * Deprecated: Use set `setJoystickThreshold` instead.
325 */326 deprecated("Use setJoystickThreshold instead.")
327 voidsetJoystickThreshhold(floatthreshhold)
328 {
329 sfWindow_setJoystickThreshold(sfPtr, threshhold);
330 }
331 332 /**
333 * Enable or disable automatic key-repeat.
334 *
335 * If key repeat is enabled, you will receive repeated KeyPressed events
336 * while keeping a key pressed. If it is disabled, you will only get a
337 * single event when the key is pressed.
338 *
339 * Key repeat is enabled by default.
340 *
341 * Params:
342 * enabled = true to enable, false to disable.
343 */344 voidsetKeyRepeatEnabled(boolenabled)
345 {
346 enabled ? sfWindow_setKeyRepeatEnabled(sfPtr,true):sfWindow_setKeyRepeatEnabled(sfPtr,false);
347 }
348 349 /**
350 * Show or hide the mouse cursor.
351 *
352 * The mouse cursor is visible by default.
353 *
354 * Params:
355 * visible = true to show the mouse cursor, false to hide it.
356 */357 voidsetMouseCursorVisible(boolvisible)
358 {
359 visible ? sfWindow_setMouseCursorVisible(sfPtr,true): sfWindow_setMouseCursorVisible(sfPtr,false);
360 }
361 362 //Cannot use templates here as template member functions cannot be virtual.363 364 /**
365 * Change the title of the window.
366 *
367 * Params:
368 * title = New title
369 */370 voidsetTitle(const(char)[] newTitle)
371 {
372 importdsfml.system..string;
373 374 autoconvertedTitle = stringConvert!(char, dchar)(newTitle);
375 sfWindow_setUnicodeTitle(sfPtr, convertedTitle.ptr, convertedTitle.length);
376 }
377 378 /// ditto379 voidsetTitle(const(wchar)[] newTitle)
380 {
381 importdsfml.system..string;
382 autoconvertedTitle = stringConvert!(wchar, dchar)(newTitle);
383 sfWindow_setUnicodeTitle(sfPtr, convertedTitle.ptr, convertedTitle.length);
384 }
385 386 /// ditto387 voidsetTitle(const(dchar)[] newTitle)
388 {
389 sfWindow_setUnicodeTitle(sfPtr, newTitle.ptr, newTitle.length);
390 }
391 392 /**
393 * Show or hide the window.
394 *
395 * The window is shown by default.
396 *
397 * Params:
398 * visible = true to show the window, false to hide it
399 */400 voidsetVisible(boolvisible)
401 {
402 sfWindow_setVisible(sfPtr,visible);
403 }
404 405 /**
406 * Enable or disable vertical synchronization.
407 *
408 * Activating vertical synchronization will limit the number of frames
409 * displayed to the refresh rate of the monitor. This can avoid some visual
410 * artifacts, and limit the framerate to a good value (but not constant
411 * across different computers).
412 *
413 * Vertical synchronization is disabled by default.
414 *
415 * Params:
416 * enabled = true to enable v-sync, false to deactivate it
417 */418 voidsetVerticalSyncEnabled(boolenabled)
419 {
420 enabled ? sfWindow_setVerticalSyncEnabled(sfPtr, true): sfWindow_setVerticalSyncEnabled(sfPtr, false);
421 }
422 423 /**
424 * Get the settings of the OpenGL context of the window.
425 *
426 * Note that these settings may be different from what was passed to the
427 * constructor or the create() function, if one or more settings were not
428 * supported. In this case, SFML chose the closest match.
429 *
430 * Returns: Structure containing the OpenGL context settings.
431 */432 ContextSettingsgetSettings() const433 {
434 ContextSettingstemp;
435 sfWindow_getSettings(sfPtr,&temp.depthBits, &temp.stencilBits, &temp.antialiasingLevel, &temp.majorVersion, &temp.minorVersion);
436 returntemp;
437 }
438 439 /**
440 * Get the OS-specific handle of the window.
441 *
442 * The type of the returned handle is sf::WindowHandle, which is a typedef
443 * to the handle type defined by the OS. You shouldn't need to use this
444 * function, unless you have very specific stuff to implement that SFML
445 * doesn't support, or implement a temporary workaround until a bug is
446 * fixed.
447 *
448 * Returns: System handle of the window.
449 */450 WindowHandlegetSystemHandle() const451 {
452 returnsfWindow_getSystemHandle(sfPtr);
453 }
454 455 //TODO: Consider adding these methods.456 //void onCreate457 //void onResize458 459 /**
460 * Close the window and destroy all the attached resources.
461 *
462 * After calling this function, the Window instance remains valid and you
463 * can call create() to recreate the window. All other functions such as
464 * pollEvent() or display() will still work (i.e. you don't have to test
465 * isOpen() every time), and will have no effect on closed windows.
466 */467 voidclose()
468 {
469 sfWindow_close(sfPtr);
470 }
471 472 //Cannot use templates here as template member functions cannot be virtual.473 474 /**
475 * Create (or recreate) the window.
476 *
477 * If the window was already created, it closes it first. If style contains
478 * Style.Fullscreen, then mode must be a valid video mode.
479 *
480 * The fourth parameter is an optional structure specifying advanced OpenGL
481 * context settings such as antialiasing, depth-buffer bits, etc.
482 */483 voidcreate(VideoModemode, const(char)[] title, Stylestyle = Style.DefaultStyle, ContextSettingssettings = ContextSettings.init)
484 {
485 importdsfml.system..string;
486 487 autoconvertedTitle = stringConvert!(char,dchar)(title);
488 sfWindow_createFromSettings(sfPtr, mode.width, mode.height, mode.bitsPerPixel, convertedTitle.ptr, convertedTitle.length, style, settings.depthBits, settings.stencilBits, settings.antialiasingLevel, settings.majorVersion, settings.minorVersion);
489 err.write(dsfml.system..string.toString(sfErr_getOutput()));
490 }
491 492 /// ditto493 voidcreate(VideoModemode, const(wchar)[] title, Stylestyle = Style.DefaultStyle, ContextSettingssettings = ContextSettings.init)
494 {
495 importdsfml.system..string;
496 autoconvertedTitle = stringConvert!(wchar,dchar)(title);
497 sfWindow_createFromSettings(sfPtr, mode.width, mode.height, mode.bitsPerPixel, convertedTitle.ptr, convertedTitle.length, style, settings.depthBits, settings.stencilBits, settings.antialiasingLevel, settings.majorVersion, settings.minorVersion);
498 err.write(dsfml.system..string.toString(sfErr_getOutput()));
499 }
500 501 /// ditto502 voidcreate(VideoModemode, const(dchar)[] title, Stylestyle = Style.DefaultStyle, ContextSettingssettings = ContextSettings.init)
503 {
504 importdsfml.system..string;
505 sfWindow_createFromSettings(sfPtr, mode.width, mode.height, mode.bitsPerPixel, title.ptr, title.length, style, settings.depthBits, settings.stencilBits, settings.antialiasingLevel, settings.majorVersion, settings.minorVersion);
506 err.write(dsfml.system..string.toString(sfErr_getOutput()));
507 }
508 509 /// ditto510 voidcreate(WindowHandlehandle, ContextSettingssettings = ContextSettings.init)
511 {
512 importdsfml.system..string;
513 sfWindow_createFromHandle(sfPtr, handle, settings.depthBits,settings.stencilBits, settings.antialiasingLevel, settings.majorVersion, settings.minorVersion);
514 err.write(dsfml.system..string.toString(sfErr_getOutput()));
515 }
516 517 /**
518 * Display on screen what has been rendered to the window so far.
519 *
520 * This function is typically called after all OpenGL rendering has been
521 * done for the current frame, in order to show it on screen.
522 */523 voiddisplay()
524 {
525 sfWindow_display(sfPtr);
526 }
527 528 /**
529 * Tell whether or not the window is open.
530 *
531 * This function returns whether or not the window exists. Note that a
532 * hidden window (setVisible(false)) is open (therefore this function would
533 * return true).
534 *
535 * Returns: true if the window is open, false if it has been closed.
536 */537 boolisOpen()
538 {
539 return (sfWindow_isOpen(sfPtr));
540 }
541 542 /**
543 * Pop the event on top of the event queue, if any, and return it.
544 *
545 * This function is not blocking: if there's no pending event then it will
546 * return false and leave event unmodified. Note that more than one event
547 * may be present in the event queue, thus you should always call this
548 * function in a loop to make sure that you process every pending event.
549 *
550 * Params:
551 * event = Event to be returned.
552 *
553 * Returns: true if an event was returned, or false if the event queue was
554 * empty.
555 */556 boolpollEvent(refEventevent)
557 {
558 return (sfWindow_pollEvent(sfPtr, &event));
559 }
560 561 /**
562 * Wait for an event and return it.
563 *
564 * This function is blocking: if there's no pending event then it will wait
565 * until an event is received. After this function returns (and no error
566 * occured), the event object is always valid and filled properly. This
567 * function is typically used when you have a thread that is dedicated to
568 * events handling: you want to make this thread sleep as long as no new
569 * event is received.
570 *
571 * Params:
572 * event = Event to be returned
573 *
574 * Returns: False if any error occured.
575 */576 boolwaitEvent(refEventevent)
577 {
578 return (sfWindow_waitEvent(sfPtr, &event));
579 }
580 581 //TODO: Clean this up. The names are so bad. :(582 583 //Gives a way for RenderWindow to send its mouse position584 protectedVector2igetMousePosition()const585 {
586 Vector2itemp;
587 sfMouse_getPosition(sfPtr,&temp.x, &temp.y);
588 returntemp;
589 }
590 591 //A method for the Mouse class to use in order to get the mouse position592 //relative to the window593 packageVector2imouse_getPosition()const594 {
595 returngetMousePosition();
596 }
597 598 //Gives a way for Render Window to set its mouse position599 protectedvoidsetMousePosition(Vector2ipos) const600 {
601 sfMouse_setPosition(pos.x, pos.y, sfPtr);
602 }
603 604 //A method for the mouse class to use605 packagevoidmouse_SetPosition(Vector2ipos) const606 {
607 setMousePosition(pos);
608 }
609 610 //Circumvents the package restriction allowing Texture to get the internal611 //pointer of a regular window (for texture.update)612 protectedstaticvoid* getWindowPointer(const(Window) window)
613 {
614 returncast(void*)window.sfPtr;
615 }
616 }
617 618 unittest619 {
620 version(DSFML_Unittest_Window)
621 {
622 importstd.stdio;
623 importdsfml.graphics.image;
624 625 writeln("Unit test for Window class.");
626 627 628 //constructor629 autowindow = newWindow(VideoMode(800,600),"Test Window");
630 631 //perform each window call632 Vector2uwindowSize = window.size;
633 634 windowSize.x = 1000;
635 windowSize.y = 1000;
636 637 window.size = windowSize;
638 639 Vector2iwindowPosition = window.position;
640 641 windowPosition.x = 100;
642 windowPosition.y = 100;
643 644 window.position = windowPosition;
645 646 window.setTitle("thing");//uses the first set title647 648 window.setTitle("素晴らしい !");//forces the dstring override and uses unicode649 650 window.setActive(true);
651 652 window.setJoystickThreshhold(1);
653 654 window.setVisible(true);
655 656 window.setFramerateLimit(60);
657 658 window.setMouseCursorVisible(true);
659 660 window.setVerticalSyncEnabled(true);
661 662 autosettings = window.getSettings();
663 664 autoimage = newImage();
665 image.loadFromFile("res/TestImage.png");
666 667 window.setIcon(image.getSize().x,image.getSize().x,image.getPixelArray());
668 669 if(window.isOpen())
670 {
671 Eventevent;
672 if(window.pollEvent(event))
673 {
674 675 }
676 //requires users input677 if(window.waitEvent(event))
678 {
679 680 }
681 682 window.display();
683 }
684 685 window.close();
686 687 }
688 }
689 690 691 packageextern(C) structsfWindow;
692 693 privateextern(C):
694 695 //Construct a new window696 sfWindow* sfWindow_construct();
697 698 //Construct a new window (with a UTF-32 title)699 voidsfWindow_createFromSettings(sfWindow* window, uintwidth, uintheight, uintbitsPerPixel, const(dchar)* title, size_ttitleLength, intstyle, uintdepthBits, uintstencilBits, uintantialiasingLevel, uintmajorVersion, uintminorVersion);
700 701 //Construct a window from an existing control702 voidsfWindow_createFromHandle(sfWindow* window, WindowHandlehandle, uintdepthBits, uintstencilBits, uintantialiasingLevel, uintmajorVersion, uintminorVersion);
703 704 // Destroy a window705 voidsfWindow_destroy(sfWindow* window);
706 707 //Close a window and destroy all the attached resources708 voidsfWindow_close(sfWindow* window);
709 710 //Tell whether or not a window is opened711 boolsfWindow_isOpen(const(sfWindow)* window);
712 713 //Get the settings of the OpenGL context of a window714 voidsfWindow_getSettings(const(sfWindow)* window, uint* depthBits, uint* stencilBits, uint* antialiasingLevel, uint* majorVersion, uint* minorVersion);
715 716 //Pop the event on top of event queue, if any, and return it717 boolsfWindow_pollEvent(sfWindow* window, Event* event);
718 719 //Wait for an event and return it720 boolsfWindow_waitEvent(sfWindow* window, Event* event);
721 722 //Get the position of a window723 voidsfWindow_getPosition(const(sfWindow)* window, int* x, int* y);
724 725 //Change the position of a window on screen726 voidsfWindow_setPosition(sfWindow* window, intx, inty);
727 728 //Get the size of the rendering region of a window729 voidsfWindow_getSize(const(sfWindow)* window, uint* width, uint* height);
730 731 //Change the size of the rendering region of a window732 voidsfWindow_setSize(sfWindow* window, uintwidth, uintheight);
733 734 //Change the title of a window735 voidsfWindow_setTitle(sfWindow* window, const(char)* title, size_tlength);
736 737 //Change the title of a window (with a UTF-32 string)738 voidsfWindow_setUnicodeTitle(sfWindow* window, const(dchar)* title, size_tlength);
739 740 //Change a window's icon741 voidsfWindow_setIcon(sfWindow* window, uintwidth, uintheight, const(ubyte)* pixels);
742 743 //Show or hide a window744 voidsfWindow_setVisible(sfWindow* window, boolvisible);
745 746 //Show or hide the mouse cursor747 voidsfWindow_setMouseCursorVisible(sfWindow* window, boolvisible);
748 749 //Enable or disable vertical synchronization750 voidsfWindow_setVerticalSyncEnabled(sfWindow* window, boolenabled);
751 752 //Enable or disable automatic key-repeat753 voidsfWindow_setKeyRepeatEnabled(sfWindow* window, boolenabled);
754 755 //Activate or deactivate a window as the current target for OpenGL rendering756 boolsfWindow_setActive(sfWindow* window, boolactive);
757 758 //Request the current window to be made the active foreground window.759 voidsfWindow_requestFocus(sfWindow* window);
760 761 //Check whether the window has the input focus762 boolsfWindow_hasFocus(const(sfWindow)* window);
763 764 //Display on screen what has been rendered to the window so far765 voidsfWindow_display(sfWindow* window);
766 767 //Limit the framerate to a maximum fixed frequency768 voidsfWindow_setFramerateLimit(sfWindow* window, uintlimit);
769 770 //Change the joystick threshold771 voidsfWindow_setJoystickThreshold(sfWindow* window, floatthreshold);
772 773 774 //Get the OS-specific handle of the window775 WindowHandlesfWindow_getSystemHandle(const(sfWindow)* window);
776 777 voidsfMouse_getPosition(const(sfWindow)* relativeTo, int* x, int* y);
778 voidsfMouse_setPosition(intx, inty, const(sfWindow)* relativeTo);
779 780 const(char)* sfErr_getOutput();