XPLMCreateWindow_t

The XPMCreateWindow_t structure defines all of the parameters used to create a modern window using XPLMCreateWindowEx(). The structure will be expanded in future SDK APIs to include more features. Always set the structSize member to the size of your struct in bytes!

All windows created by this function in the XPLM300 version of the API are created with the new X-Plane 11 GUI features. This means your plugin will get to “know” about the existence of X-Plane windows other than the main window. All drawing and mouse callbacks for your window will occur in “boxels,” giving your windows automatic support for high-DPI scaling in X-Plane. In addition, your windows can opt-in to decoration with the X-Plane 11 window styling, and you can use the XPLMSetWindowPositioningMode() API to make your window “popped out” into a first-class operating system window.

Note that this requires dealing with your window’s bounds in “global desktop” positioning units, rather than the traditional panel coordinate system. In global desktop coordinates, the main X-Plane window may not have its origin at coordinate (0, 0), and your own window may have negative coordinates. Assuming you don’t implicitly assume (0, 0) as your origin, the only API change you should need is to start using XPLMGetMouseLocationGlobal() rather than XPLMGetMouseLocation(), and XPLMGetScreenBoundsGlobal() instead of XPLMGetScreenSize().

If you ask to be decorated as a floating window, you’ll get the blue window control bar and blue backing that you see in X-Plane 11’s normal “floating” windows (like the map).

typedef struct {
     // Used to inform XPLMCreateWindowEx() of the SDK version you compiled against; should always be set to sizeof(XPLMCreateWindow_t)
     int                       structSize;
     // Left bound, in global desktop boxels
     int                       left;
     // Top bound, in global desktop boxels
     int                       top;
     // Right bound, in global desktop boxels
     int                       right;
     // Bottom bound, in global desktop boxels
     int                       bottom;
     int                       visible;
     XPLMDrawWindow_f          drawWindowFunc;
     // A callback to handle the user left-clicking within your window (or NULL to ignore left clicks)
     XPLMHandleMouseClick_f    handleMouseClickFunc;
     XPLMHandleKey_f           handleKeyFunc;
     XPLMHandleCursor_f        handleCursorFunc;
     XPLMHandleMouseWheel_f    handleMouseWheelFunc;
     // A reference which will be passed into each of your window callbacks. Use this to pass information to yourself as needed.
     void *                    refcon;
     // Specifies the type of X-Plane 11-style "wrapper" you want around your window, if any
     XPLMWindowDecoration      decorateAsFloatingWindow;
     XPLMWindowLayer           layer;
     // A callback to handle the user right-clicking within your window (or NULL to ignore right clicks)
     XPLMHandleMouseClick_f    handleRightClickFunc;
} XPLMCreateWindow_t;