haiku: Implement message box for Haiku
authorEXL <exlmotodev@gmail.com>
Mon, 11 Nov 2019 16:44:40 -0500
changeset 1323057ed423da32a
parent 13229 0b98870c7f72
child 13231 7685ed78cd5c
haiku: Implement message box for Haiku

Add implementation for functions:

SDL_ShowSimpleMessageBox()
SDL_ShowMessageBox()

Add simple customization support also.
Fix build for x86_gcc2.

Partially fixes Bugzilla #4442.
include/SDL_syswm.h
src/main/haiku/SDL_BeApp.cc
src/main/haiku/SDL_BeApp.h
src/video/SDL_video.c
src/video/haiku/SDL_bmessagebox.cc
src/video/haiku/SDL_bmessagebox.h
src/video/haiku/SDL_bwindow.cc
     1.1 --- a/include/SDL_syswm.h	Mon Nov 04 11:15:24 2019 +0300
     1.2 +++ b/include/SDL_syswm.h	Mon Nov 11 16:44:40 2019 -0500
     1.3 @@ -132,7 +132,8 @@
     1.4      SDL_SYSWM_WINRT,
     1.5      SDL_SYSWM_ANDROID,
     1.6      SDL_SYSWM_VIVANTE,
     1.7 -    SDL_SYSWM_OS2
     1.8 +    SDL_SYSWM_OS2,
     1.9 +    SDL_SYSWM_HAIKU
    1.10  } SDL_SYSWM_TYPE;
    1.11  
    1.12  /**
     2.1 --- a/src/main/haiku/SDL_BeApp.cc	Mon Nov 04 11:15:24 2019 +0300
     2.2 +++ b/src/main/haiku/SDL_BeApp.cc	Mon Nov 11 16:44:40 2019 -0500
     2.3 @@ -48,13 +48,14 @@
     2.4  static int SDL_BeAppActive = 0;
     2.5  static SDL_Thread *SDL_AppThread = NULL;
     2.6  
     2.7 +/* Default application signature */
     2.8 +const char *signature = "application/x-SDL-executable";
     2.9 +
    2.10  static int
    2.11  StartBeApp(void *unused)
    2.12  {
    2.13      BApplication *App;
    2.14  
    2.15 -    // default application signature
    2.16 -    const char *signature = "application/x-SDL-executable";
    2.17      // dig resources for correct signature
    2.18      image_info info;
    2.19      int32 cookie = 0;
     3.1 --- a/src/main/haiku/SDL_BeApp.h	Mon Nov 04 11:15:24 2019 +0300
     3.2 +++ b/src/main/haiku/SDL_BeApp.h	Mon Nov 11 16:44:40 2019 -0500
     3.3 @@ -31,6 +31,9 @@
     3.4  /* Quit the Be Application, if there's nothing left to do */
     3.5  extern void SDL_QuitBeApp(void);
     3.6  
     3.7 +/* Be Application Signature*/
     3.8 +extern const char *signature;
     3.9 +
    3.10  /* vi: set ts=4 sw=4 expandtab: */
    3.11  
    3.12  #ifdef __cplusplus
     4.1 --- a/src/video/SDL_video.c	Mon Nov 04 11:15:24 2019 +0300
     4.2 +++ b/src/video/SDL_video.c	Mon Nov 11 16:44:40 2019 -0500
     4.3 @@ -3846,9 +3846,12 @@
     4.4  #if SDL_VIDEO_DRIVER_X11
     4.5  #include "x11/SDL_x11messagebox.h"
     4.6  #endif
     4.7 -
     4.8 -
     4.9 -#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT || SDL_VIDEO_DRIVER_COCOA || SDL_VIDEO_DRIVER_UIKIT || SDL_VIDEO_DRIVER_X11
    4.10 +#if SDL_VIDEO_DRIVER_HAIKU
    4.11 +#include "haiku/SDL_bmessagebox.h"
    4.12 +#endif
    4.13 +
    4.14 +
    4.15 +#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT || SDL_VIDEO_DRIVER_COCOA || SDL_VIDEO_DRIVER_UIKIT || SDL_VIDEO_DRIVER_X11 || SDL_VIDEO_DRIVER_HAIKU
    4.16  static SDL_bool SDL_MessageboxValidForDriver(const SDL_MessageBoxData *messageboxdata, SDL_SYSWM_TYPE drivertype)
    4.17  {
    4.18      SDL_SysWMinfo info;
    4.19 @@ -3941,6 +3944,13 @@
    4.20          retval = 0;
    4.21      }
    4.22  #endif
    4.23 +#if SDL_VIDEO_DRIVER_HAIKU
    4.24 +    if (retval == -1 &&
    4.25 +        SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_HAIKU) &&
    4.26 +        BE_ShowMessageBox(messageboxdata, buttonid) == 0) {
    4.27 +        retval = 0;
    4.28 +    }
    4.29 +#endif
    4.30      if (retval == -1) {
    4.31          SDL_SetError("No message system available");
    4.32      }
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/video/haiku/SDL_bmessagebox.cc	Mon Nov 11 16:44:40 2019 -0500
     5.3 @@ -0,0 +1,425 @@
     5.4 +/*
     5.5 +  Simple DirectMedia Layer
     5.6 +  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
     5.7 +  Copyright (C) 2018 EXL <exlmotodev@gmail.com>
     5.8 +
     5.9 +  This software is provided 'as-is', without any express or implied
    5.10 +  warranty.  In no event will the authors be held liable for any damages
    5.11 +  arising from the use of this software.
    5.12 +
    5.13 +  Permission is granted to anyone to use this software for any purpose,
    5.14 +  including commercial applications, and to alter it and redistribute it
    5.15 +  freely, subject to the following restrictions:
    5.16 +
    5.17 +  1. The origin of this software must not be misrepresented; you must not
    5.18 +     claim that you wrote the original software. If you use this software
    5.19 +     in a product, an acknowledgment in the product documentation would be
    5.20 +     appreciated but is not required.
    5.21 +  2. Altered source versions must be plainly marked as such, and must not be
    5.22 +     misrepresented as being the original software.
    5.23 +  3. This notice may not be removed or altered from any source distribution.
    5.24 +*/
    5.25 +
    5.26 +#include "../../SDL_internal.h"
    5.27 +
    5.28 +#if SDL_VIDEO_DRIVER_HAIKU
    5.29 +
    5.30 +#include "SDL_messagebox.h"
    5.31 +
    5.32 +/* For application signature. */
    5.33 +#include "../../main/haiku/SDL_BeApp.h"
    5.34 +
    5.35 +#include <Alert.h>
    5.36 +#include <Application.h>
    5.37 +#include <Button.h>
    5.38 +#include <Font.h>
    5.39 +#include <Layout.h>
    5.40 +#include <String.h>
    5.41 +#include <TextView.h>
    5.42 +#include <View.h>
    5.43 +#include <Window.h>
    5.44 +
    5.45 +#include <InterfaceDefs.h>
    5.46 +#include <SupportDefs.h>
    5.47 +#include <GraphicsDefs.h>
    5.48 +
    5.49 +#include <new>
    5.50 +#include <vector>
    5.51 +#include <algorithm>
    5.52 +
    5.53 +enum
    5.54 +{
    5.55 +	G_CLOSE_BUTTON_ID   = -1,
    5.56 +	G_DEFAULT_BUTTON_ID = 0,
    5.57 +	G_MAX_STRING_LENGTH_BYTES = 120
    5.58 +};
    5.59 +
    5.60 +class BE_SDL_MessageBox : public BAlert
    5.61 +{
    5.62 +	float fComputedMessageBoxWidth;
    5.63 +
    5.64 +	BTextView *fMessageBoxTextView;
    5.65 +
    5.66 +	int fCloseButton;
    5.67 +	int fDefaultButton;
    5.68 +
    5.69 +	bool fCustomColorScheme;
    5.70 +	bool fThereIsLongLine;
    5.71 +	rgb_color fTextColor;
    5.72 +
    5.73 +	const char *fTitle;
    5.74 +	const char *BE_SDL_DefTitle;
    5.75 +	const char *BE_SDL_DefMessage;
    5.76 +	const char *BE_SDL_DefButton;
    5.77 +
    5.78 +	std::vector<const SDL_MessageBoxButtonData *> fButtons;
    5.79 +
    5.80 +	static bool
    5.81 +	SortButtonsPredicate(const SDL_MessageBoxButtonData *aButtonLeft,
    5.82 +	                                 const SDL_MessageBoxButtonData *aButtonRight)
    5.83 +	{
    5.84 +		return aButtonLeft->buttonid < aButtonRight->buttonid;
    5.85 +	}
    5.86 +
    5.87 +	alert_type
    5.88 +	ConvertMessageBoxType(const SDL_MessageBoxFlags aWindowType) const
    5.89 +	{
    5.90 +		switch (aWindowType)
    5.91 +		{
    5.92 +			default:
    5.93 +			case SDL_MESSAGEBOX_WARNING:
    5.94 +			{
    5.95 +				return B_WARNING_ALERT;
    5.96 +			}
    5.97 +			case SDL_MESSAGEBOX_ERROR:
    5.98 +			{
    5.99 +				return B_STOP_ALERT;
   5.100 +			}
   5.101 +			case SDL_MESSAGEBOX_INFORMATION:
   5.102 +			{
   5.103 +				return B_INFO_ALERT;
   5.104 +			}
   5.105 +		}
   5.106 +	}
   5.107 +
   5.108 +	rgb_color
   5.109 +	ConvertColorType(const SDL_MessageBoxColor *aColor) const
   5.110 +	{
   5.111 +		rgb_color color = { aColor->r, aColor->g, aColor->b, color.alpha = 255 };
   5.112 +		return color;
   5.113 +	}
   5.114 +
   5.115 +	int32
   5.116 +	GetLeftPanelWidth(void) const
   5.117 +	{
   5.118 +		// See file "haiku/src/kits/interface/Alert.cpp" for this magic numbers.
   5.119 +		//    IconStripeWidth = 30 * Scale
   5.120 +		//    IconSize = 32 * Scale
   5.121 +		//    Scale = max_c(1, ((int32)be_plain_font->Size() + 15) / 16)
   5.122 +		//    RealWidth = (IconStripeWidth * Scale) + (IconSize * Scale)
   5.123 +
   5.124 +		int32 scale = max_c(1, ((int32)be_plain_font->Size() + 15) / 16);
   5.125 +		return (30 * scale) + (32 * scale);
   5.126 +	}
   5.127 +
   5.128 +	void
   5.129 +	UpdateTextViewWidth(void)
   5.130 +	{
   5.131 +		fComputedMessageBoxWidth = fMessageBoxTextView->PreferredSize().Width() + GetLeftPanelWidth();
   5.132 +	}
   5.133 +
   5.134 +	void
   5.135 +	ParseSdlMessageBoxData(const SDL_MessageBoxData *aMessageBoxData)
   5.136 +	{
   5.137 +		if (aMessageBoxData == NULL)
   5.138 +		{
   5.139 +			SetTitle(BE_SDL_DefTitle);
   5.140 +			SetMessageText(BE_SDL_DefMessage);
   5.141 +			AddButton(BE_SDL_DefButton);
   5.142 +			return;
   5.143 +		}
   5.144 +
   5.145 +		if (aMessageBoxData->numbuttons <= 0)
   5.146 +		{
   5.147 +			AddButton(BE_SDL_DefButton);
   5.148 +		}
   5.149 +		else
   5.150 +		{
   5.151 +			AddSdlButtons(aMessageBoxData->buttons, aMessageBoxData->numbuttons);
   5.152 +		}
   5.153 +
   5.154 +		if (aMessageBoxData->colorScheme != NULL)
   5.155 +		{
   5.156 +			fCustomColorScheme = true;
   5.157 +			ApplyAndParseColorScheme(aMessageBoxData->colorScheme);
   5.158 +		}
   5.159 +
   5.160 +		(aMessageBoxData->title != NULL) ?
   5.161 +			SetTitle(aMessageBoxData->title) : SetTitle(BE_SDL_DefTitle);
   5.162 +		(aMessageBoxData->message != NULL) ?
   5.163 +			SetMessageText(aMessageBoxData->message) : SetMessageText(BE_SDL_DefMessage);
   5.164 +
   5.165 +		SetType(ConvertMessageBoxType(static_cast<SDL_MessageBoxFlags>(aMessageBoxData->flags)));
   5.166 +	}
   5.167 +
   5.168 +	void
   5.169 +	ApplyAndParseColorScheme(const SDL_MessageBoxColorScheme *aColorScheme)
   5.170 +	{
   5.171 +		SetBackgroundColor(&aColorScheme->colors[SDL_MESSAGEBOX_COLOR_BACKGROUND]);
   5.172 +		fTextColor = ConvertColorType(&aColorScheme->colors[SDL_MESSAGEBOX_COLOR_TEXT]);
   5.173 +		SetButtonColors(&aColorScheme->colors[SDL_MESSAGEBOX_COLOR_BUTTON_BORDER],
   5.174 +		                &aColorScheme->colors[SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND],
   5.175 +		                &aColorScheme->colors[SDL_MESSAGEBOX_COLOR_TEXT],
   5.176 +		                &aColorScheme->colors[SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED]);
   5.177 +	}
   5.178 +
   5.179 +	void
   5.180 +	SetButtonColors(const SDL_MessageBoxColor *aBorderColor,
   5.181 +	                const SDL_MessageBoxColor *aBackgroundColor,
   5.182 +	                const SDL_MessageBoxColor *aTextColor,
   5.183 +	                const SDL_MessageBoxColor *aSelectedColor)
   5.184 +	{
   5.185 +		if (fCustomColorScheme)
   5.186 +		{
   5.187 +			int32 countButtons = CountButtons();
   5.188 +			for (int i = 0; i < countButtons; ++i)
   5.189 +			{
   5.190 +				ButtonAt(i)->SetViewColor(ConvertColorType(aBorderColor));
   5.191 +				ButtonAt(i)->SetLowColor(ConvertColorType(aBackgroundColor));
   5.192 +
   5.193 +				// This doesn't work. See this why:
   5.194 +				// https://github.com/haiku/haiku/commit/de9c53f8f5008c7b3b0af75d944a628e17f6dffe
   5.195 +				// Let it remain.
   5.196 +				ButtonAt(i)->SetHighColor(ConvertColorType(aTextColor));
   5.197 +			}
   5.198 +		}
   5.199 +		// TODO: Not Implemented.
   5.200 +		// Is it even necessary?!
   5.201 +		(void)aSelectedColor;
   5.202 +	}
   5.203 +
   5.204 +	void
   5.205 +	SetBackgroundColor(const SDL_MessageBoxColor *aColor)
   5.206 +	{
   5.207 +		rgb_color background = ConvertColorType(aColor);
   5.208 +
   5.209 +		GetLayout()->View()->SetViewColor(background);
   5.210 +		// See file "haiku/src/kits/interface/Alert.cpp", the "TAlertView" is the internal name of the left panel.
   5.211 +		FindView("TAlertView")->SetViewColor(background);
   5.212 +		fMessageBoxTextView->SetViewColor(background);
   5.213 +	}
   5.214 +
   5.215 +	bool
   5.216 +	CheckLongLines(const char *aMessage)
   5.217 +	{
   5.218 +		int final = 0;
   5.219 +
   5.220 +		// This UTF-8 friendly.
   5.221 +		BString message = aMessage;
   5.222 +		int32 length = message.CountChars();
   5.223 +
   5.224 +		for (int i = 0, c = 0; i < length; ++i)
   5.225 +		{
   5.226 +			c++;
   5.227 +			if (*(message.CharAt(i)) == '\n')
   5.228 +			{
   5.229 +				c = 0;
   5.230 +			}
   5.231 +			if (c > final)
   5.232 +			{
   5.233 +				final = c;
   5.234 +			}
   5.235 +		}
   5.236 +
   5.237 +		return (final > G_MAX_STRING_LENGTH_BYTES);
   5.238 +	}
   5.239 +
   5.240 +	void
   5.241 +	SetMessageText(const char *aMessage)
   5.242 +	{
   5.243 +		fThereIsLongLine = CheckLongLines(aMessage);
   5.244 +		if (fThereIsLongLine)
   5.245 +		{
   5.246 +			fMessageBoxTextView->SetWordWrap(true);
   5.247 +		}
   5.248 +
   5.249 +		rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);
   5.250 +		if (fCustomColorScheme)
   5.251 +		{
   5.252 +			textColor = fTextColor;
   5.253 +		}
   5.254 +
   5.255 +		/*
   5.256 +		if (fNoTitledWindow)
   5.257 +		{
   5.258 +			fMessageBoxTextView->SetFontAndColor(be_bold_font);
   5.259 +			fMessageBoxTextView->Insert(fTitle);
   5.260 +			fMessageBoxTextView->Insert("\n\n");
   5.261 +			fMessageBoxTextView->SetFontAndColor(be_plain_font);
   5.262 +		}
   5.263 +		*/
   5.264 +
   5.265 +		fMessageBoxTextView->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor);
   5.266 +		fMessageBoxTextView->Insert(aMessage);
   5.267 +
   5.268 +		// Be sure to call update width method.
   5.269 +		UpdateTextViewWidth();
   5.270 +	}
   5.271 +
   5.272 +	void
   5.273 +	AddSdlButtons(const SDL_MessageBoxButtonData *aButtons, int aNumButtons)
   5.274 +	{
   5.275 +		for (int i = 0; i < aNumButtons; ++i)
   5.276 +		{
   5.277 +			fButtons.push_back(&aButtons[i]);
   5.278 +		}
   5.279 +
   5.280 +		std::sort(fButtons.begin(), fButtons.end(), &BE_SDL_MessageBox::SortButtonsPredicate);
   5.281 +
   5.282 +		size_t countButtons = fButtons.size();
   5.283 +		for (size_t i = 0; i < countButtons; ++i)
   5.284 +		{
   5.285 +			switch (fButtons[i]->flags)
   5.286 +			{
   5.287 +				case SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT:
   5.288 +				{
   5.289 +					fCloseButton = static_cast<int>(i);
   5.290 +					break;
   5.291 +				}
   5.292 +				case SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT:
   5.293 +				{
   5.294 +					fDefaultButton = static_cast<int>(i);
   5.295 +					break;
   5.296 +				}
   5.297 +				default:
   5.298 +				{
   5.299 +					break;
   5.300 +				}
   5.301 +			}
   5.302 +			AddButton(fButtons[i]->text);
   5.303 +		}
   5.304 +
   5.305 +		SetDefaultButton(ButtonAt(fDefaultButton));
   5.306 +	}
   5.307 +
   5.308 +public:
   5.309 +	explicit
   5.310 +	BE_SDL_MessageBox(const SDL_MessageBoxData *aMessageBoxData)
   5.311 +		: BAlert(NULL, NULL, NULL, NULL, NULL, B_WIDTH_FROM_LABEL, B_WARNING_ALERT),
   5.312 +		  fComputedMessageBoxWidth(0.0f),
   5.313 +		  fCloseButton(G_CLOSE_BUTTON_ID), fDefaultButton(G_DEFAULT_BUTTON_ID),
   5.314 +		  fCustomColorScheme(false), fThereIsLongLine(false),
   5.315 +		  BE_SDL_DefTitle("SDL2 MessageBox"),
   5.316 +		  BE_SDL_DefMessage("Some information has been lost."),
   5.317 +		  BE_SDL_DefButton("OK")
   5.318 +	{
   5.319 +		// MessageBox settings.
   5.320 +		// We need a title to display it.
   5.321 +		SetLook(B_TITLED_WINDOW_LOOK);
   5.322 +		SetFlags(Flags() | B_CLOSE_ON_ESCAPE);
   5.323 +
   5.324 +		// MessageBox TextView settings.
   5.325 +		fMessageBoxTextView = TextView();
   5.326 +		fMessageBoxTextView->SetWordWrap(false);
   5.327 +		fMessageBoxTextView->SetStylable(true);
   5.328 +
   5.329 +		ParseSdlMessageBoxData(aMessageBoxData);
   5.330 +	}
   5.331 +
   5.332 +	int
   5.333 +	GetCloseButtonId(void) const
   5.334 +	{
   5.335 +		return fCloseButton;
   5.336 +	}
   5.337 +
   5.338 +	virtual
   5.339 +	~BE_SDL_MessageBox(void)
   5.340 +	{
   5.341 +		fButtons.clear();
   5.342 +	}
   5.343 +
   5.344 +protected:
   5.345 +	virtual void
   5.346 +	FrameResized(float aNewWidth, float aNewHeight)
   5.347 +	{
   5.348 +		if (fComputedMessageBoxWidth > aNewWidth)
   5.349 +		{
   5.350 +			ResizeTo(fComputedMessageBoxWidth, aNewHeight);
   5.351 +		}
   5.352 +		else
   5.353 +		{
   5.354 +			BAlert::FrameResized(aNewWidth, aNewHeight);
   5.355 +		}
   5.356 +	}
   5.357 +
   5.358 +	virtual void
   5.359 +	SetTitle(const char* aTitle)
   5.360 +	{
   5.361 +		fTitle = aTitle;
   5.362 +		BAlert::SetTitle(aTitle);
   5.363 +	}
   5.364 +};
   5.365 +
   5.366 +#ifdef __cplusplus
   5.367 +extern "C" {
   5.368 +#endif
   5.369 +
   5.370 +int
   5.371 +BE_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
   5.372 +{
   5.373 +	// Initialize button by closed or error value first.
   5.374 +	*buttonid = G_CLOSE_BUTTON_ID;
   5.375 +
   5.376 +	// We need to check "be_app" pointer to "NULL". The "messageboxdata->window" pointer isn't appropriate here
   5.377 +	// because it is possible to create a MessageBox from another thread. This fixes the following errors:
   5.378 +	// "You need a valid BApplication object before interacting with the app_server."
   5.379 +	// "2 BApplication objects were created. Only one is allowed."
   5.380 +	BApplication *application = NULL;
   5.381 +	if (be_app == NULL)
   5.382 +	{
   5.383 +		application = new(std::nothrow) BApplication(signature);
   5.384 +		if (application == NULL)
   5.385 +		{
   5.386 +			return SDL_SetError("Cannot create the BApplication object. Lack of memory?");
   5.387 +		}
   5.388 +	}
   5.389 +
   5.390 +	BE_SDL_MessageBox *SDL_MessageBox = new(std::nothrow) BE_SDL_MessageBox(messageboxdata);
   5.391 +	if (SDL_MessageBox == NULL)
   5.392 +	{
   5.393 +		return SDL_SetError("Cannot create the BE_SDL_MessageBox (BAlert inheritor) object. Lack of memory?");
   5.394 +	}
   5.395 +	const int closeButton = SDL_MessageBox->GetCloseButtonId();
   5.396 +	int pushedButton = SDL_MessageBox->Go();
   5.397 +
   5.398 +	// The close button is equivalent to pressing Escape.
   5.399 +	if (closeButton != G_CLOSE_BUTTON_ID && pushedButton == G_CLOSE_BUTTON_ID)
   5.400 +	{
   5.401 +		pushedButton = closeButton;
   5.402 +	}
   5.403 +
   5.404 +	// It's deleted by itself after the "Go()" method was executed.
   5.405 +	/*
   5.406 +	if (messageBox != NULL)
   5.407 +	{
   5.408 +		delete messageBox;
   5.409 +	}
   5.410 +	*/
   5.411 +	if (application != NULL)
   5.412 +	{
   5.413 +		delete application;
   5.414 +	}
   5.415 +
   5.416 +	// Initialize button by real pushed value then.
   5.417 +	*buttonid = pushedButton;
   5.418 +
   5.419 +	return 0;
   5.420 +}
   5.421 +
   5.422 +#ifdef __cplusplus
   5.423 +}
   5.424 +#endif
   5.425 +
   5.426 +#endif /* SDL_VIDEO_DRIVER_HAIKU */
   5.427 +
   5.428 +/* vi: set ts=4 sw=4 expandtab: */
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/video/haiku/SDL_bmessagebox.h	Mon Nov 11 16:44:40 2019 -0500
     6.3 @@ -0,0 +1,45 @@
     6.4 +/*
     6.5 +  Simple DirectMedia Layer
     6.6 +  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
     6.7 +  Copyright (C) 2018 EXL <exlmotodev@gmail.com>
     6.8 +
     6.9 +  This software is provided 'as-is', without any express or implied
    6.10 +  warranty.  In no event will the authors be held liable for any damages
    6.11 +  arising from the use of this software.
    6.12 +
    6.13 +  Permission is granted to anyone to use this software for any purpose,
    6.14 +  including commercial applications, and to alter it and redistribute it
    6.15 +  freely, subject to the following restrictions:
    6.16 +
    6.17 +  1. The origin of this software must not be misrepresented; you must not
    6.18 +     claim that you wrote the original software. If you use this software
    6.19 +     in a product, an acknowledgment in the product documentation would be
    6.20 +     appreciated but is not required.
    6.21 +  2. Altered source versions must be plainly marked as such, and must not be
    6.22 +     misrepresented as being the original software.
    6.23 +  3. This notice may not be removed or altered from any source distribution.
    6.24 +*/
    6.25 +
    6.26 +#ifndef SDL_BMESSAGEBOX_H
    6.27 +#define SDL_BMESSAGEBOX_H
    6.28 +
    6.29 +#include "../../SDL_internal.h"
    6.30 +
    6.31 +#if SDL_VIDEO_DRIVER_HAIKU
    6.32 +
    6.33 +#ifdef __cplusplus
    6.34 +extern "C" {
    6.35 +#endif
    6.36 +
    6.37 +extern int
    6.38 +BE_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
    6.39 +
    6.40 +#ifdef __cplusplus
    6.41 +}
    6.42 +#endif
    6.43 +
    6.44 +#endif /* SDL_VIDEO_DRIVER_HAIKU */
    6.45 +
    6.46 +#endif
    6.47 +
    6.48 +/* vi: set ts=4 sw=4 expandtab: */
     7.1 --- a/src/video/haiku/SDL_bwindow.cc	Mon Nov 04 11:15:24 2019 +0300
     7.2 +++ b/src/video/haiku/SDL_bwindow.cc	Mon Nov 11 16:44:40 2019 -0500
     7.3 @@ -26,6 +26,8 @@
     7.4  #include "SDL_BWin.h"
     7.5  #include <new>
     7.6  
     7.7 +#include "SDL_syswm.h"
     7.8 +
     7.9  /* Define a path to window's BWIN data */
    7.10  #ifdef __cplusplus
    7.11  extern "C" {
    7.12 @@ -217,7 +219,15 @@
    7.13  SDL_bool HAIKU_GetWindowWMInfo(_THIS, SDL_Window * window,
    7.14                                      struct SDL_SysWMinfo *info) {
    7.15      /* FIXME: What is the point of this? What information should be included? */
    7.16 -    return SDL_FALSE;
    7.17 +	if (info->version.major == SDL_MAJOR_VERSION &&
    7.18 +	    info->version.minor == SDL_MINOR_VERSION) {
    7.19 +	    info->subsystem = SDL_SYSWM_HAIKU;
    7.20 +	    return SDL_TRUE;
    7.21 +	} else {
    7.22 +	    SDL_SetError("Application not compiled with SDL %d.%d",
    7.23 +	                 SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
    7.24 +	    return SDL_FALSE;
    7.25 +	}
    7.26  }
    7.27  
    7.28