1 /* 2 * DSFML - The Simple and Fast Multimedia Library for D 3 * 4 * Copyright (c) 2013 - 2018 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 * DSFML is based on SFML (Copyright Laurent Gomila) 26 */ 27 28 /** 29 * $(U Window) is the main class of the Window module. It defines an OS window 30 * that is able to receive an OpenGL rendering. 31 * 32 * A $(U Window) can create its own new window, or be embedded into an already 33 * existing control using the create(handle) function. This can be useful for 34 * embedding an OpenGL rendering area into a view which is part of a bigger GUI 35 * with existing windows, controls, etc. It can also serve as embedding an 36 * OpenGL rendering area into a window created by another (probably richer) GUI 37 * library like Qt or wxWidgets. 38 * 39 * The $(U Window) class provides a simple interface for manipulating the 40 * window: move, resize, show/hide, control mouse cursor, etc. It also provides 41 * event handling through its `pollEvent()` and `waitEvent()` functions. 42 * 43 * Note that OpenGL experts can pass their own parameters (antialiasing level 44 * bits for the depth and stencil buffers, etc.) to the OpenGL context attached 45 * to the window, with the $(CONTEXTSETTINGS_LINK) structure which is passed as 46 * an optional argument when creating the window. 47 * 48 * Example: 49 * --- 50 * // Declare and create a new window 51 * auto window = new Window(VideoMode(800, 600), "DSFML window"); 52 * 53 * // Limit the framerate to 60 frames per second (this step is optional) 54 * window.setFramerateLimit(60); 55 * 56 * // The main loop - ends as soon as the window is closed 57 * while (window.isOpen()) 58 * { 59 * // Event processing 60 * Event event; 61 * while (window.pollEvent(event)) 62 * { 63 * // Request for closing the window 64 * if (event.type == Event.EventType.Closed) 65 * window.close(); 66 * } 67 * 68 * // Activate the window for OpenGL rendering 69 * window.setActive(); 70 * 71 * // OpenGL drawing commands go here... 72 * 73 * // End the current frame and display its contents on screen 74 * window.display(); 75 * } 76 * --- 77 */ 78 module dsfml.window.window; 79 80 import dsfml.window.event; 81 import dsfml.window.videomode; 82 import dsfml.window.contextsettings; 83 import dsfml.window.windowhandle; 84 import dsfml.system.vector2; 85 import dsfml.system.err; 86 87 /** 88 * Window that serves as a target for OpenGL rendering. 89 */ 90 class Window 91 { 92 /// Choices for window style 93 enum Style 94 { 95 None = 0, 96 Titlebar = 1 << 0, 97 Resize = 1 << 1, 98 Close = 1 << 2, 99 Fullscreen = 1 << 3, 100 DefaultStyle = Titlebar | Resize | Close 101 } 102 103 package sfWindow* sfPtr; 104 105 //let's RenderWindow inherit from Window without trying to delete the null 106 //pointer 107 private bool m_needsToDelete = true; 108 109 /// Default constructor. 110 this() 111 { 112 sfPtr = sfWindow_construct(); 113 } 114 115 //Construct a window without calling sfWindow_construct 116 //This allows a RenderWindow to be created without creating a Window first 117 protected this(int) 118 { 119 m_needsToDelete = false; 120 } 121 122 //allows RenderWindow to delete the Window pointer when it is created 123 //so that there are not both instances. 124 protected void deleteWindowPtr() 125 { 126 sfWindow_destroy(sfPtr); 127 m_needsToDelete = false; 128 } 129 130 /** 131 * Construct a new window. 132 * 133 * This constructor creates the window with the size and pixel depth defined 134 * in mode. An optional style can be passed to customize the look and 135 * behaviour of the window (borders, title bar, resizable, closable, ...). 136 * If style contains Style::Fullscreen, then mode must be a valid video 137 * mode. 138 * 139 * The fourth parameter is an optional structure specifying advanced OpenGL 140 * context settings such as antialiasing, depth-buffer bits, etc. 141 * 142 * Params: 143 * mode = Video mode to use (defines the width, height and depth of the 144 * rendering area of the window) 145 * title = Title of the window 146 * style = Window style 147 * settings = Additional settings for the underlying OpenGL context 148 */ 149 this(T)(VideoMode mode, immutable(T)[] title, Style style = Style.DefaultStyle, ContextSettings settings = ContextSettings.init) 150 if (is(T == dchar)||is(T == wchar)||is(T == char)) 151 { 152 this(); 153 create(mode, title, style, settings); 154 } 155 156 /** 157 * Construct the window from an existing control. 158 * 159 * Use this constructor if you want to create an OpenGL rendering area into 160 * an already existing control. 161 * 162 * The second parameter is an optional structure specifying advanced OpenGL 163 * context settings such as antialiasing, depth-buffer bits, etc. 164 * 165 * Params: 166 * handle = Platform-specific handle of the control 167 * settings = Additional settings for the underlying OpenGL context 168 */ 169 this(WindowHandle handle, ContextSettings settings = ContextSettings.init) 170 { 171 this(); 172 create(handle, settings); 173 } 174 175 /// Destructor. 176 ~this() 177 { 178 import dsfml.system.config; 179 //this takes care of not freeing a null pointer due to inheritance 180 //(RenderWindow does not create the inherited sfWindow) 181 if(m_needsToDelete) 182 { 183 mixin(destructorOutput); 184 sfWindow_destroy(sfPtr); 185 } 186 } 187 188 @property 189 { 190 /** 191 * Get's or set's the window's position. 192 * 193 * This function only works for top-level windows (i.e. it will be ignored 194 * for windows created from the handle of a child window/control). 195 */ 196 Vector2i position(Vector2i newPosition) 197 { 198 sfWindow_setPosition(sfPtr,newPosition.x, newPosition.y); 199 return newPosition; 200 } 201 202 /// ditto 203 Vector2i position() const 204 { 205 Vector2i temp; 206 sfWindow_getPosition(sfPtr,&temp.x, &temp.y); 207 return temp; 208 } 209 } 210 211 @property 212 { 213 /// Get's or set's the window's size. 214 Vector2u size(Vector2u newSize) 215 { 216 sfWindow_setSize(sfPtr, newSize.x, newSize.y); 217 return newSize; 218 } 219 220 // ditto 221 Vector2u size() const 222 { 223 Vector2u temp; 224 sfWindow_getSize(sfPtr,&temp.x, &temp.y); 225 return temp; 226 } 227 } 228 229 /** 230 * Activate or deactivate the window as the current target for OpenGL 231 * rendering. 232 * 233 * A window is active only on the current thread, if you want to make it 234 * active on another thread you have to deactivate it on the previous thread 235 * first if it was active. Only one window can be active on a thread at a 236 * time, thus the window previously active (if any) automatically gets 237 * deactivated. 238 * 239 * Params: 240 * active = true to activate, false to deactivate 241 * 242 * Returns: true if operation was successful, false otherwise. 243 */ 244 bool setActive(bool active) 245 { 246 return sfWindow_setActive(sfPtr, active); 247 } 248 249 ///Request the current window to be made the active foreground window. 250 void requestFocus() 251 { 252 sfWindow_requestFocus(sfPtr); 253 } 254 255 /** 256 * Check whether the window has the input focus 257 * 258 * Returns: true if the window has focus, false otherwise 259 */ 260 bool hasFocus() const 261 { 262 return sfWindow_hasFocus(sfPtr); 263 } 264 265 /** 266 * Limit the framerate to a maximum fixed frequency. 267 * 268 * If a limit is set, the window will use a small delay after each call to 269 * display() to ensure that the current frame lasted long enough to match 270 * the framerate limit. SFML will try to match the given limit as much as it 271 * can, but since it internally uses dsfml.system.sleep, whose precision 272 * depends on the underlying OS, the results may be a little unprecise as 273 * well (for example, you can get 65 FPS when requesting 60). 274 * 275 * Params: 276 * limit = Framerate limit, in frames per seconds (use 0 to disable limit). 277 */ 278 void setFramerateLimit(uint limit) 279 { 280 sfWindow_setFramerateLimit(sfPtr, limit); 281 } 282 283 /** 284 * Change the window's icon. 285 * 286 * pixels must be an array of width x height pixels in 32-bits RGBA format. 287 * 288 * The OS default icon is used by default. 289 * 290 * Params: 291 * width = Icon's width, in pixels 292 * height = Icon's height, in pixels 293 * pixels = Pointer to the array of pixels in memory 294 */ 295 void setIcon(uint width, uint height, const(ubyte[]) pixels) 296 { 297 sfWindow_setIcon(sfPtr,width, height, pixels.ptr); 298 } 299 300 /** 301 * Change the joystick threshold. 302 * 303 * The joystick threshold is the value below which no JoystickMoved event 304 * will be generated. 305 * 306 * The threshold value is 0.1 by default. 307 * 308 * Params: 309 * threshold = New threshold, in the range [0, 100]. 310 */ 311 void setJoystickThreshold(float threshold) 312 { 313 sfWindow_setJoystickThreshold(sfPtr, threshold); 314 } 315 316 /** 317 * Change the joystick threshold. 318 * 319 * The joystick threshold is the value below which no JoystickMoved event 320 * will be generated. 321 * 322 * The threshold value is 0.1 by default. 323 * 324 * Params: 325 * threshhold = New threshold, in the range [0, 100]. 326 * 327 * Deprecated: Use set `setJoystickThreshold` instead. 328 */ 329 deprecated("Use setJoystickThreshold instead.") 330 void setJoystickThreshhold(float threshhold) 331 { 332 sfWindow_setJoystickThreshold(sfPtr, threshhold); 333 } 334 335 /** 336 * Enable or disable automatic key-repeat. 337 * 338 * If key repeat is enabled, you will receive repeated KeyPressed events 339 * while keeping a key pressed. If it is disabled, you will only get a 340 * single event when the key is pressed. 341 * 342 * Key repeat is enabled by default. 343 * 344 * Params: 345 * enabled = true to enable, false to disable. 346 */ 347 void setKeyRepeatEnabled(bool enabled) 348 { 349 sfWindow_setKeyRepeatEnabled(sfPtr, enabled); 350 } 351 352 /** 353 * Show or hide the mouse cursor. 354 * 355 * The mouse cursor is visible by default. 356 * 357 * Params: 358 * visible = true to show the mouse cursor, false to hide it. 359 */ 360 void setMouseCursorVisible(bool visible) 361 { 362 sfWindow_setMouseCursorVisible(sfPtr, visible); 363 } 364 365 //Cannot use templates here as template member functions cannot be virtual. 366 367 /** 368 * Change the title of the window. 369 * 370 * Params: 371 * newTitle = New title 372 * 373 * Deprecated: Use the version of setTitle that takes a 'const(dchar)[]'. 374 */ 375 deprecated("Use the version of setTitle that takes a 'const(dchar)[]'.") 376 void setTitle(const(char)[] newTitle) 377 { 378 import std.utf: toUTF32; 379 auto convertedTitle = toUTF32(newTitle); 380 sfWindow_setUnicodeTitle(sfPtr, convertedTitle.ptr, convertedTitle.length); 381 } 382 383 /// ditto 384 deprecated("Use the version of setTitle that takes a 'const(dchar)[]'.") 385 void setTitle(const(wchar)[] newTitle) 386 { 387 import std.utf: toUTF32; 388 auto convertedTitle = toUTF32(newTitle); 389 sfWindow_setUnicodeTitle(sfPtr, convertedTitle.ptr, convertedTitle.length); 390 } 391 392 /** 393 * Change the title of the window. 394 * 395 * Params: 396 * newTitle = New title 397 */ 398 void setTitle(const(dchar)[] newTitle) 399 { 400 sfWindow_setUnicodeTitle(sfPtr, newTitle.ptr, newTitle.length); 401 } 402 403 /** 404 * Show or hide the window. 405 * 406 * The window is shown by default. 407 * 408 * Params: 409 * visible = true to show the window, false to hide it 410 */ 411 void setVisible(bool visible) 412 { 413 sfWindow_setVisible(sfPtr, visible); 414 } 415 416 /** 417 * Enable or disable vertical synchronization. 418 * 419 * Activating vertical synchronization will limit the number of frames 420 * displayed to the refresh rate of the monitor. This can avoid some visual 421 * artifacts, and limit the framerate to a good value (but not constant 422 * across different computers). 423 * 424 * Vertical synchronization is disabled by default. 425 * 426 * Params: 427 * enabled = true to enable v-sync, false to deactivate it 428 */ 429 void setVerticalSyncEnabled(bool enabled) 430 { 431 sfWindow_setVerticalSyncEnabled(sfPtr, enabled); 432 } 433 434 /** 435 * Get the settings of the OpenGL context of the window. 436 * 437 * Note that these settings may be different from what was passed to the 438 * constructor or the create() function, if one or more settings were not 439 * supported. In this case, SFML chose the closest match. 440 * 441 * Returns: Structure containing the OpenGL context settings. 442 */ 443 ContextSettings getSettings() const 444 { 445 ContextSettings temp; 446 sfWindow_getSettings(sfPtr,&temp.depthBits, &temp.stencilBits, &temp.antialiasingLevel, &temp.majorVersion, &temp.minorVersion); 447 return temp; 448 } 449 450 /** 451 * Get the OS-specific handle of the window. 452 * 453 * The type of the returned handle is sf::WindowHandle, which is a typedef 454 * to the handle type defined by the OS. You shouldn't need to use this 455 * function, unless you have very specific stuff to implement that SFML 456 * doesn't support, or implement a temporary workaround until a bug is 457 * fixed. 458 * 459 * Returns: System handle of the window. 460 */ 461 WindowHandle getSystemHandle() const 462 { 463 return sfWindow_getSystemHandle(sfPtr); 464 } 465 466 //TODO: Consider adding these methods. 467 //void onCreate 468 //void onResize 469 470 /** 471 * Close the window and destroy all the attached resources. 472 * 473 * After calling this function, the Window instance remains valid and you 474 * can call create() to recreate the window. All other functions such as 475 * pollEvent() or display() will still work (i.e. you don't have to test 476 * isOpen() every time), and will have no effect on closed windows. 477 */ 478 void close() 479 { 480 sfWindow_close(sfPtr); 481 } 482 483 //Cannot use templates here as template member functions cannot be virtual. 484 485 /** 486 * Create (or recreate) the window. 487 * 488 * If the window was already created, it closes it first. If style contains 489 * Style.Fullscreen, then mode must be a valid video mode. 490 * 491 * The fourth parameter is an optional structure specifying advanced OpenGL 492 * context settings such as antialiasing, depth-buffer bits, etc. 493 * 494 * Deprecated: Use the version of create that takes a 'const(dchar)[]'. 495 */ 496 deprecated("Use the version of create that takes a 'const(dchar)[]'.") 497 void create(VideoMode mode, const(char)[] title, Style style = Style.DefaultStyle, ContextSettings settings = ContextSettings.init) 498 { 499 import std.utf: toUTF32; 500 auto convertedTitle = toUTF32(title); 501 sfWindow_createFromSettings(sfPtr, mode.width, mode.height, mode.bitsPerPixel, convertedTitle.ptr, convertedTitle.length, style, settings.depthBits, settings.stencilBits, settings.antialiasingLevel, settings.majorVersion, settings.minorVersion); 502 } 503 504 /// ditto 505 deprecated("Use the version of create that takes a 'const(dchar)[]'.") 506 void create(VideoMode mode, const(wchar)[] title, Style style = Style.DefaultStyle, ContextSettings settings = ContextSettings.init) 507 { 508 import std.utf: toUTF32; 509 auto convertedTitle = toUTF32(title); 510 sfWindow_createFromSettings(sfPtr, mode.width, mode.height, mode.bitsPerPixel, convertedTitle.ptr, convertedTitle.length, style, settings.depthBits, settings.stencilBits, settings.antialiasingLevel, settings.majorVersion, settings.minorVersion); 511 } 512 513 /** 514 * Create (or recreate) the window. 515 * 516 * If the window was already created, it closes it first. If style contains 517 * Style.Fullscreen, then mode must be a valid video mode. 518 * 519 * The fourth parameter is an optional structure specifying advanced OpenGL 520 * context settings such as antialiasing, depth-buffer bits, etc. 521 */ 522 void create(VideoMode mode, const(dchar)[] title, Style style = Style.DefaultStyle, ContextSettings settings = ContextSettings.init) 523 { 524 sfWindow_createFromSettings(sfPtr, mode.width, mode.height, mode.bitsPerPixel, title.ptr, title.length, style, settings.depthBits, settings.stencilBits, settings.antialiasingLevel, settings.majorVersion, settings.minorVersion); 525 } 526 527 /// ditto 528 void create(WindowHandle handle, ContextSettings settings = ContextSettings.init) 529 { 530 sfWindow_createFromHandle(sfPtr, handle, settings.depthBits,settings.stencilBits, settings.antialiasingLevel, settings.majorVersion, settings.minorVersion); 531 } 532 533 /** 534 * Display on screen what has been rendered to the window so far. 535 * 536 * This function is typically called after all OpenGL rendering has been 537 * done for the current frame, in order to show it on screen. 538 */ 539 void display() 540 { 541 sfWindow_display(sfPtr); 542 } 543 544 /** 545 * Tell whether or not the window is open. 546 * 547 * This function returns whether or not the window exists. Note that a 548 * hidden window (setVisible(false)) is open (therefore this function would 549 * return true). 550 * 551 * Returns: true if the window is open, false if it has been closed. 552 */ 553 bool isOpen() const 554 { 555 return (sfWindow_isOpen(sfPtr)); 556 } 557 558 /** 559 * Pop the event on top of the event queue, if any, and return it. 560 * 561 * This function is not blocking: if there's no pending event then it will 562 * return false and leave event unmodified. Note that more than one event 563 * may be present in the event queue, thus you should always call this 564 * function in a loop to make sure that you process every pending event. 565 * 566 * Params: 567 * event = Event to be returned. 568 * 569 * Returns: true if an event was returned, or false if the event queue was 570 * empty. 571 */ 572 bool pollEvent(ref Event event) 573 { 574 return (sfWindow_pollEvent(sfPtr, &event)); 575 } 576 577 /** 578 * Wait for an event and return it. 579 * 580 * This function is blocking: if there's no pending event then it will wait 581 * until an event is received. After this function returns (and no error 582 * occured), the event object is always valid and filled properly. This 583 * function is typically used when you have a thread that is dedicated to 584 * events handling: you want to make this thread sleep as long as no new 585 * event is received. 586 * 587 * Params: 588 * event = Event to be returned 589 * 590 * Returns: False if any error occured. 591 */ 592 bool waitEvent(ref Event event) 593 { 594 return (sfWindow_waitEvent(sfPtr, &event)); 595 } 596 597 //TODO: Clean this up. The names are so bad. :( 598 599 //Gives a way for RenderWindow to send its mouse position 600 protected Vector2i getMousePosition() const 601 { 602 Vector2i temp; 603 sfMouse_getPosition(sfPtr,&temp.x, &temp.y); 604 return temp; 605 } 606 607 //A method for the Mouse class to use in order to get the mouse position 608 //relative to the window 609 package Vector2i mouse_getPosition() const 610 { 611 return getMousePosition(); 612 } 613 614 //Gives a way for Render Window to set its mouse position 615 protected void setMousePosition(Vector2i pos) const 616 { 617 sfMouse_setPosition(pos.x, pos.y, sfPtr); 618 } 619 620 //A method for the mouse class to use 621 package void mouse_SetPosition(Vector2i pos) const 622 { 623 setMousePosition(pos); 624 } 625 626 //Circumvents the package restriction allowing Texture to get the internal 627 //pointer of a regular window (for texture.update) 628 protected static void* getWindowPointer(const(Window) window) 629 { 630 return cast(void*)window.sfPtr; 631 } 632 } 633 634 unittest 635 { 636 version(DSFML_Unittest_Window) 637 { 638 import std.stdio; 639 import dsfml.graphics.image; 640 641 writeln("Unit test for Window class."); 642 643 //constructor 644 auto window = new Window(VideoMode(800,600),"Test Window"); 645 646 //perform each window call 647 Vector2u windowSize = window.size; 648 649 windowSize.x = 1000; 650 windowSize.y = 1000; 651 652 window.size = windowSize; 653 654 Vector2i windowPosition = window.position; 655 656 windowPosition.x = 100; 657 windowPosition.y = 100; 658 659 window.position = windowPosition; 660 661 window.setTitle("thing");//uses the first set title 662 663 window.setTitle("素晴らしい !");//forces the dstring override and uses unicode 664 665 window.setActive(true); 666 667 window.setJoystickThreshhold(1); 668 669 window.setVisible(true); 670 671 window.setFramerateLimit(60); 672 673 window.setMouseCursorVisible(true); 674 675 window.setVerticalSyncEnabled(true); 676 677 auto settings = window.getSettings(); 678 679 auto image = new Image(); 680 image.loadFromFile("res/TestImage.png"); 681 682 window.setIcon(image.getSize().x,image.getSize().x,image.getPixelArray()); 683 684 if(window.isOpen()) 685 { 686 Event event; 687 if(window.pollEvent(event)) 688 { 689 690 } 691 692 //requires users input 693 if(window.waitEvent(event)) 694 { 695 696 } 697 698 window.display(); 699 } 700 701 window.close(); 702 703 } 704 } 705 706 707 package extern(C) struct sfWindow; 708 709 private extern(C): 710 711 //Construct a new window 712 sfWindow* sfWindow_construct(); 713 714 //Construct a new window (with a UTF-32 title) 715 void sfWindow_createFromSettings(sfWindow* window, uint width, uint height, uint bitsPerPixel, const(dchar)* title, size_t titleLength, int style, uint depthBits, uint stencilBits, uint antialiasingLevel, uint majorVersion, uint minorVersion); 716 717 //Construct a window from an existing control 718 void sfWindow_createFromHandle(sfWindow* window, WindowHandle handle, uint depthBits, uint stencilBits, uint antialiasingLevel, uint majorVersion, uint minorVersion); 719 720 // Destroy a window 721 void sfWindow_destroy(sfWindow* window); 722 723 //Close a window and destroy all the attached resources 724 void sfWindow_close(sfWindow* window); 725 726 //Tell whether or not a window is opened 727 bool sfWindow_isOpen(const(sfWindow)* window); 728 729 //Get the settings of the OpenGL context of a window 730 void sfWindow_getSettings(const(sfWindow)* window, uint* depthBits, uint* stencilBits, uint* antialiasingLevel, uint* majorVersion, uint* minorVersion); 731 732 //Pop the event on top of event queue, if any, and return it 733 bool sfWindow_pollEvent(sfWindow* window, Event* event); 734 735 //Wait for an event and return it 736 bool sfWindow_waitEvent(sfWindow* window, Event* event); 737 738 //Get the position of a window 739 void sfWindow_getPosition(const(sfWindow)* window, int* x, int* y); 740 741 //Change the position of a window on screen 742 void sfWindow_setPosition(sfWindow* window, int x, int y); 743 744 //Get the size of the rendering region of a window 745 void sfWindow_getSize(const(sfWindow)* window, uint* width, uint* height); 746 747 //Change the size of the rendering region of a window 748 void sfWindow_setSize(sfWindow* window, uint width, uint height); 749 750 //Change the title of a window 751 void sfWindow_setTitle(sfWindow* window, const(char)* title, size_t length); 752 753 //Change the title of a window (with a UTF-32 string) 754 void sfWindow_setUnicodeTitle(sfWindow* window, const(dchar)* title, size_t length); 755 756 //Change a window's icon 757 void sfWindow_setIcon(sfWindow* window, uint width, uint height, const(ubyte)* pixels); 758 759 //Show or hide a window 760 void sfWindow_setVisible(sfWindow* window, bool visible); 761 762 //Show or hide the mouse cursor 763 void sfWindow_setMouseCursorVisible(sfWindow* window, bool visible); 764 765 //Enable or disable vertical synchronization 766 void sfWindow_setVerticalSyncEnabled(sfWindow* window, bool enabled); 767 768 //Enable or disable automatic key-repeat 769 void sfWindow_setKeyRepeatEnabled(sfWindow* window, bool enabled); 770 771 //Activate or deactivate a window as the current target for OpenGL rendering 772 bool sfWindow_setActive(sfWindow* window, bool active); 773 774 //Request the current window to be made the active foreground window. 775 void sfWindow_requestFocus(sfWindow* window); 776 777 //Check whether the window has the input focus 778 bool sfWindow_hasFocus(const(sfWindow)* window); 779 780 //Display on screen what has been rendered to the window so far 781 void sfWindow_display(sfWindow* window); 782 783 //Limit the framerate to a maximum fixed frequency 784 void sfWindow_setFramerateLimit(sfWindow* window, uint limit); 785 786 //Change the joystick threshold 787 void sfWindow_setJoystickThreshold(sfWindow* window, float threshold); 788 789 790 //Get the OS-specific handle of the window 791 WindowHandle sfWindow_getSystemHandle(const(sfWindow)* window); 792 793 void sfMouse_getPosition(const(sfWindow)* relativeTo, int* x, int* y); 794 void sfMouse_setPosition(int x, int y, const(sfWindow)* relativeTo);