Revert "Updated SDL, Bullet and OpenAL soft libs"

This reverts commit 370161cfb1.
This commit is contained in:
AzaezelX 2019-07-08 09:49:44 -05:00
parent 63be684474
commit bc77ff0833
1102 changed files with 62741 additions and 204988 deletions

View file

@ -18,10 +18,6 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_RLEaccel_c_h_
#define SDL_RLEaccel_c_h_
#include "../SDL_internal.h"
/* Useful functions and variables from SDL_RLEaccel.c */
@ -32,7 +28,4 @@ extern int SDLCALL SDL_RLEBlit (SDL_Surface * src, SDL_Rect * srcrect,
extern int SDLCALL SDL_RLEAlphaBlit(SDL_Surface * src, SDL_Rect * srcrect,
SDL_Surface * dst, SDL_Rect * dstrect);
extern void SDL_UnRLESurface(SDL_Surface * surface, int recode);
#endif /* SDL_RLEaccel_c_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -126,7 +126,7 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface * surface);
b = SDL_expand_byte[fmt->Bloss][((Pixel&fmt->Bmask)>>fmt->Bshift)]; \
}
#define RGB_FROM_RGB565(Pixel, r, g, b) \
{ \
{ \
r = SDL_expand_byte[3][((Pixel&0xF800)>>11)]; \
g = SDL_expand_byte[2][((Pixel&0x07E0)>>5)]; \
b = SDL_expand_byte[3][(Pixel&0x001F)]; \
@ -262,18 +262,18 @@ do { \
{ \
switch (bpp) { \
case 1: { \
Uint8 _Pixel; \
Uint8 Pixel; \
\
PIXEL_FROM_RGB(_Pixel, fmt, r, g, b); \
*((Uint8 *)(buf)) = _Pixel; \
PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \
*((Uint8 *)(buf)) = Pixel; \
} \
break; \
\
case 2: { \
Uint16 _Pixel; \
Uint16 Pixel; \
\
PIXEL_FROM_RGB(_Pixel, fmt, r, g, b); \
*((Uint16 *)(buf)) = _Pixel; \
PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \
*((Uint16 *)(buf)) = Pixel; \
} \
break; \
\
@ -291,10 +291,10 @@ do { \
break; \
\
case 4: { \
Uint32 _Pixel; \
Uint32 Pixel; \
\
PIXEL_FROM_RGB(_Pixel, fmt, r, g, b); \
*((Uint32 *)(buf)) = _Pixel; \
PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \
*((Uint32 *)(buf)) = Pixel; \
} \
break; \
} \

View file

@ -49,13 +49,13 @@ Blit1to1(SDL_BlitInfo * info)
while (height--) {
#ifdef USE_DUFFS_LOOP
/* *INDENT-OFF* */
DUFFS_LOOP(
{
*dst = map[*src];
}
dst++;
src++;
, width);
DUFFS_LOOP(
{
*dst = map[*src];
}
dst++;
src++;
, width);
/* *INDENT-ON* */
#else
for (c = width; c; --c) {
@ -72,11 +72,11 @@ Blit1to1(SDL_BlitInfo * info)
/* This is now endian dependent */
#ifndef USE_DUFFS_LOOP
# if ( SDL_BYTEORDER == SDL_LIL_ENDIAN )
# define HI 1
# define LO 0
# define HI 1
# define LO 0
# else /* ( SDL_BYTEORDER == SDL_BIG_ENDIAN ) */
# define HI 0
# define LO 1
# define HI 0
# define LO 1
# endif
#endif
static void
@ -101,14 +101,14 @@ Blit1to2(SDL_BlitInfo * info)
#ifdef USE_DUFFS_LOOP
while (height--) {
/* *INDENT-OFF* */
DUFFS_LOOP(
{
*(Uint16 *)dst = map[*src++];
dst += 2;
},
width);
/* *INDENT-ON* */
/* *INDENT-OFF* */
DUFFS_LOOP(
{
*(Uint16 *)dst = map[*src++];
dst += 2;
},
width);
/* *INDENT-ON* */
src += srcskip;
dst += dstskip;
}
@ -208,18 +208,18 @@ Blit1to3(SDL_BlitInfo * info)
while (height--) {
#ifdef USE_DUFFS_LOOP
/* *INDENT-OFF* */
DUFFS_LOOP(
{
o = *src * 4;
dst[0] = map[o++];
dst[1] = map[o++];
dst[2] = map[o++];
}
src++;
dst += 3;
, width);
/* *INDENT-ON* */
/* *INDENT-OFF* */
DUFFS_LOOP(
{
o = *src * 4;
dst[0] = map[o++];
dst[1] = map[o++];
dst[2] = map[o++];
}
src++;
dst += 3;
, width);
/* *INDENT-ON* */
#else
for (c = width; c; --c) {
o = *src * 4;
@ -257,11 +257,11 @@ Blit1to4(SDL_BlitInfo * info)
while (height--) {
#ifdef USE_DUFFS_LOOP
/* *INDENT-OFF* */
DUFFS_LOOP(
*dst++ = map[*src++];
, width);
/* *INDENT-ON* */
/* *INDENT-OFF* */
DUFFS_LOOP(
*dst++ = map[*src++];
, width);
/* *INDENT-ON* */
#else
for (c = width / 4; c; --c) {
*dst++ = map[*src++];
@ -297,33 +297,33 @@ Blit1to1Key(SDL_BlitInfo * info)
if (palmap) {
while (height--) {
/* *INDENT-OFF* */
DUFFS_LOOP(
{
if ( *src != ckey ) {
*dst = palmap[*src];
}
dst++;
src++;
},
width);
/* *INDENT-ON* */
/* *INDENT-OFF* */
DUFFS_LOOP(
{
if ( *src != ckey ) {
*dst = palmap[*src];
}
dst++;
src++;
},
width);
/* *INDENT-ON* */
src += srcskip;
dst += dstskip;
}
} else {
while (height--) {
/* *INDENT-OFF* */
DUFFS_LOOP(
{
if ( *src != ckey ) {
*dst = *src;
}
dst++;
src++;
},
width);
/* *INDENT-ON* */
/* *INDENT-OFF* */
DUFFS_LOOP(
{
if ( *src != ckey ) {
*dst = *src;
}
dst++;
src++;
},
width);
/* *INDENT-ON* */
src += srcskip;
dst += dstskip;
}
@ -346,17 +346,17 @@ Blit1to2Key(SDL_BlitInfo * info)
dstskip /= 2;
while (height--) {
/* *INDENT-OFF* */
DUFFS_LOOP(
{
if ( *src != ckey ) {
*dstp=palmap[*src];
}
src++;
dstp++;
},
width);
/* *INDENT-ON* */
/* *INDENT-OFF* */
DUFFS_LOOP(
{
if ( *src != ckey ) {
*dstp=palmap[*src];
}
src++;
dstp++;
},
width);
/* *INDENT-ON* */
src += srcskip;
dstp += dstskip;
}
@ -376,20 +376,20 @@ Blit1to3Key(SDL_BlitInfo * info)
int o;
while (height--) {
/* *INDENT-OFF* */
DUFFS_LOOP(
{
if ( *src != ckey ) {
o = *src * 4;
dst[0] = palmap[o++];
dst[1] = palmap[o++];
dst[2] = palmap[o++];
}
src++;
dst += 3;
},
width);
/* *INDENT-ON* */
/* *INDENT-OFF* */
DUFFS_LOOP(
{
if ( *src != ckey ) {
o = *src * 4;
dst[0] = palmap[o++];
dst[1] = palmap[o++];
dst[2] = palmap[o++];
}
src++;
dst += 3;
},
width);
/* *INDENT-ON* */
src += srcskip;
dst += dstskip;
}
@ -411,17 +411,17 @@ Blit1to4Key(SDL_BlitInfo * info)
dstskip /= 4;
while (height--) {
/* *INDENT-OFF* */
DUFFS_LOOP(
{
if ( *src != ckey ) {
*dstp = palmap[*src];
}
src++;
dstp++;
},
width);
/* *INDENT-ON* */
/* *INDENT-OFF* */
DUFFS_LOOP(
{
if ( *src != ckey ) {
*dstp = palmap[*src];
}
src++;
dstp++;
},
width);
/* *INDENT-ON* */
src += srcskip;
dstp += dstskip;
}
@ -489,22 +489,22 @@ Blit1toNAlphaKey(SDL_BlitInfo * info)
dstbpp = dstfmt->BytesPerPixel;
while (height--) {
/* *INDENT-OFF* */
DUFFS_LOOP(
{
if ( *src != ckey ) {
sR = srcpal[*src].r;
sG = srcpal[*src].g;
sB = srcpal[*src].b;
DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA);
ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
}
src++;
dst += dstbpp;
},
width);
/* *INDENT-ON* */
/* *INDENT-OFF* */
DUFFS_LOOP(
{
if ( *src != ckey ) {
sR = srcpal[*src].r;
sG = srcpal[*src].g;
sB = srcpal[*src].b;
DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA);
ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
}
src++;
dst += dstbpp;
},
width);
/* *INDENT-ON* */
src += srcskip;
dst += dstskip;
}

File diff suppressed because it is too large Load diff

View file

@ -2333,31 +2333,6 @@ BlitNtoNKey(SDL_BlitInfo * info)
/* Set up some basic variables */
ckey &= rgbmask;
/* Fastpath: same source/destination format, no Amask, bpp 32, loop is vectorized. ~10x faster */
if (srcfmt->format == dstfmt->format &&
(srcfmt->format == SDL_PIXELFORMAT_RGB888 || srcfmt->format == SDL_PIXELFORMAT_BGR888)) {
Uint32 *src32 = (Uint32*)src;
Uint32 *dst32 = (Uint32*)dst;
srcskip /= sizeof(Uint32);
dstskip /= sizeof(Uint32);
while (height--) {
/* *INDENT-OFF* */
DUFFS_LOOP(
{
if (*src32 != ckey) {
*dst32 = *src32;
}
++src32;
++dst32;
},
width);
/* *INDENT-ON* */
src32 += srcskip;
dst32 += dstskip;
}
return;
}
while (height--) {
/* *INDENT-OFF* */
DUFFS_LOOP(
@ -2405,34 +2380,6 @@ BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info)
dstbpp = dstfmt->BytesPerPixel;
ckey &= rgbmask;
/* Fastpath: same source/destination format, with Amask, bpp 32, loop is vectorized. ~10x faster */
if (srcfmt->format == dstfmt->format &&
(srcfmt->format == SDL_PIXELFORMAT_ARGB8888 ||
srcfmt->format == SDL_PIXELFORMAT_ABGR8888 ||
srcfmt->format == SDL_PIXELFORMAT_BGRA8888 ||
srcfmt->format == SDL_PIXELFORMAT_RGBA8888)) {
Uint32 *src32 = (Uint32*)src;
Uint32 *dst32 = (Uint32*)dst;
srcskip /= sizeof(Uint32);
dstskip /= sizeof(Uint32);
while (height--) {
/* *INDENT-OFF* */
DUFFS_LOOP(
{
if ((*src32 & rgbmask) != ckey) {
*dst32 = *src32;
}
++src32;
++dst32;
},
width);
/* *INDENT-ON* */
src32 += srcskip;
dst32 += dstskip;
}
return;
}
while (height--) {
/* *INDENT-OFF* */
DUFFS_LOOP(

View file

@ -19,11 +19,6 @@
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_blit_copy_h_
#define SDL_blit_copy_h_
void SDL_BlitCopy(SDL_BlitInfo * info);
#endif /* SDL_blit_copy_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -18,14 +18,8 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_blit_slow_h_
#define SDL_blit_slow_h_
#include "../SDL_internal.h"
extern void SDL_Blit_Slow(SDL_BlitInfo * info);
#endif /* SDL_blit_slow_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -406,9 +406,6 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
}
}
_this->egl_data->egl_version_major = egl_version_major;
_this->egl_data->egl_version_minor = egl_version_minor;
if (egl_version_major == 1 && egl_version_minor == 5) {
LOAD_FUNC(eglGetPlatformDisplay);
}
@ -449,64 +446,6 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
return 0;
}
#ifdef DUMP_EGL_CONFIG
#define ATTRIBUTE(_attr) { _attr, #_attr }
typedef struct {
EGLint attribute;
char const* name;
} Attribute;
Attribute attributes[] = {
ATTRIBUTE( EGL_BUFFER_SIZE ),
ATTRIBUTE( EGL_ALPHA_SIZE ),
ATTRIBUTE( EGL_BLUE_SIZE ),
ATTRIBUTE( EGL_GREEN_SIZE ),
ATTRIBUTE( EGL_RED_SIZE ),
ATTRIBUTE( EGL_DEPTH_SIZE ),
ATTRIBUTE( EGL_STENCIL_SIZE ),
ATTRIBUTE( EGL_CONFIG_CAVEAT ),
ATTRIBUTE( EGL_CONFIG_ID ),
ATTRIBUTE( EGL_LEVEL ),
ATTRIBUTE( EGL_MAX_PBUFFER_HEIGHT ),
ATTRIBUTE( EGL_MAX_PBUFFER_WIDTH ),
ATTRIBUTE( EGL_MAX_PBUFFER_PIXELS ),
ATTRIBUTE( EGL_NATIVE_RENDERABLE ),
ATTRIBUTE( EGL_NATIVE_VISUAL_ID ),
ATTRIBUTE( EGL_NATIVE_VISUAL_TYPE ),
ATTRIBUTE( EGL_SAMPLES ),
ATTRIBUTE( EGL_SAMPLE_BUFFERS ),
ATTRIBUTE( EGL_SURFACE_TYPE ),
ATTRIBUTE( EGL_TRANSPARENT_TYPE ),
ATTRIBUTE( EGL_TRANSPARENT_BLUE_VALUE ),
ATTRIBUTE( EGL_TRANSPARENT_GREEN_VALUE ),
ATTRIBUTE( EGL_TRANSPARENT_RED_VALUE ),
ATTRIBUTE( EGL_BIND_TO_TEXTURE_RGB ),
ATTRIBUTE( EGL_BIND_TO_TEXTURE_RGBA ),
ATTRIBUTE( EGL_MIN_SWAP_INTERVAL ),
ATTRIBUTE( EGL_MAX_SWAP_INTERVAL ),
ATTRIBUTE( EGL_LUMINANCE_SIZE ),
ATTRIBUTE( EGL_ALPHA_MASK_SIZE ),
ATTRIBUTE( EGL_COLOR_BUFFER_TYPE ),
ATTRIBUTE( EGL_RENDERABLE_TYPE ),
ATTRIBUTE( EGL_MATCH_NATIVE_PIXMAP ),
ATTRIBUTE( EGL_CONFORMANT ),
};
static void dumpconfig(_THIS, EGLConfig config)
{
int attr;
for (attr = 0 ; attr<sizeof(attributes)/sizeof(Attribute) ; attr++) {
EGLint value;
_this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, config, attributes[attr].attribute, &value);
SDL_Log("\t%-32s: %10d (0x%08x)\n", attributes[attr].name, value, value);
}
}
#endif /* DUMP_EGL_CONFIG */
int
SDL_EGL_ChooseConfig(_THIS)
{
@ -631,10 +570,6 @@ SDL_EGL_ChooseConfig(_THIS)
break; /* we found an exact match! */
}
}
#ifdef DUMP_EGL_CONFIG
dumpconfig(_this, _this->egl_data->egl_config);
#endif
return 0;
}
@ -661,24 +596,6 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
share_context = (EGLContext)SDL_GL_GetCurrentContext();
}
#if SDL_VIDEO_DRIVER_ANDROID
if ((_this->gl_config.flags & SDL_GL_CONTEXT_DEBUG_FLAG) != 0) {
/* If SDL_GL_CONTEXT_DEBUG_FLAG is set but EGL_KHR_debug unsupported, unset.
* This is required because some Android devices like to complain about it
* by "silently" failing, logging a hint which could be easily overlooked:
* E/libEGL (26984): validate_display:255 error 3008 (EGL_BAD_DISPLAY)
* The following explicitly checks for EGL_KHR_debug before EGL 1.5
*/
int egl_version_major = _this->egl_data->egl_version_major;
int egl_version_minor = _this->egl_data->egl_version_minor;
if (((egl_version_major < 1) || (egl_version_major == 1 && egl_version_minor < 5)) &&
!SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_debug")) {
/* SDL profile bits match EGL profile bits. */
_this->gl_config.flags &= ~SDL_GL_CONTEXT_DEBUG_FLAG;
}
}
#endif
/* Set the context version and other attributes. */
if ((major_version < 3 || (minor_version == 0 && profile_es)) &&
_this->gl_config.flags == 0 &&
@ -846,6 +763,7 @@ SDL_EGL_DeleteContext(_THIS, SDL_GLContext context)
}
if (egl_context != NULL && egl_context != EGL_NO_CONTEXT) {
SDL_EGL_MakeCurrent(_this, NULL, NULL);
_this->egl_data->eglDestroyContext(_this->egl_data->egl_display, egl_context);
}
@ -857,7 +775,7 @@ SDL_EGL_CreateSurface(_THIS, NativeWindowType nw)
/* max 2 values plus terminator. */
EGLint attribs[3];
int attr = 0;
EGLSurface * surface;
if (SDL_EGL_ChooseConfig(_this) != 0) {
@ -889,7 +807,7 @@ SDL_EGL_CreateSurface(_THIS, NativeWindowType nw)
return EGL_NO_SURFACE;
}
}
attribs[attr++] = EGL_NONE;
surface = _this->egl_data->eglCreateWindowSurface(

View file

@ -36,7 +36,6 @@ typedef struct SDL_EGL_VideoData
EGLConfig egl_config;
int egl_swapinterval;
int egl_surfacetype;
int egl_version_major, egl_version_minor;
EGLDisplay(EGLAPIENTRY *eglGetDisplay) (NativeDisplayType display);
EGLDisplay(EGLAPIENTRY *eglGetPlatformDisplay) (EGLenum platform,

View file

@ -326,7 +326,7 @@ SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask,
if (Rmask == 0) {
return SDL_PIXELFORMAT_RGB555;
}
/* fallthrough */
/* fallthrough */
case 16:
if (Rmask == 0) {
return SDL_PIXELFORMAT_RGB565;

View file

@ -18,10 +18,6 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_pixels_c_h_
#define SDL_pixels_c_h_
#include "../SDL_internal.h"
/* Useful functions and variables from SDL_pixel.c */
@ -41,6 +37,4 @@ extern void SDL_FreeBlitMap(SDL_BlitMap * map);
extern void SDL_DitherColors(SDL_Color * colors, int bpp);
extern Uint8 SDL_FindColor(SDL_Palette * pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
#endif /* SDL_pixels_c_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -18,14 +18,8 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_rect_c_h_
#define SDL_rect_c_h_
#include "../SDL_internal.h"
extern SDL_bool SDL_GetSpanEnclosingRect(int width, int height, int numrects, const SDL_Rect * rects, SDL_Rect *span);
#endif /* SDL_rect_c_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -36,21 +36,21 @@ extern "C" {
#endif
typedef struct {
struct SDL_ShapeTree *upleft,*upright,*downleft,*downright;
struct SDL_ShapeTree *upleft,*upright,*downleft,*downright;
} SDL_QuadTreeChildren;
typedef union {
SDL_QuadTreeChildren children;
SDL_Rect shape;
SDL_QuadTreeChildren children;
SDL_Rect shape;
} SDL_ShapeUnion;
typedef enum { QuadShape,TransparentShape,OpaqueShape } SDL_ShapeKind;
typedef struct {
SDL_ShapeKind kind;
SDL_ShapeUnion data;
SDL_ShapeKind kind;
SDL_ShapeUnion data;
} SDL_ShapeTree;
typedef void(*SDL_TraversalFunction)(SDL_ShapeTree*,void*);
extern void SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode,SDL_Surface *shape,Uint8* bitmap,Uint8 ppb);

View file

@ -37,7 +37,7 @@ SDL_COMPILE_TIME_ASSERT(surface_size_assumptions,
/*
* Calculate the pad-aligned scanline width of a surface
*/
static int
int
SDL_CalculatePitch(Uint32 format, int width)
{
int pitch;
@ -292,20 +292,6 @@ SDL_SetColorKey(SDL_Surface * surface, int flag, Uint32 key)
return 0;
}
SDL_bool
SDL_HasColorKey(SDL_Surface * surface)
{
if (!surface) {
return SDL_FALSE;
}
if (!(surface->map->info.flags & SDL_COPY_COLORKEY)) {
return SDL_FALSE;
}
return SDL_TRUE;
}
int
SDL_GetColorKey(SDL_Surface * surface, Uint32 * key)
{

View file

@ -119,8 +119,8 @@ struct SDL_Window
!((W)->flags & SDL_WINDOW_MINIMIZED))
/*
* Define the SDL display structure.
* This corresponds to physical monitors attached to the system.
* Define the SDL display structure This corresponds to physical monitors
* attached to the system.
*/
struct SDL_VideoDisplay
{
@ -130,7 +130,6 @@ struct SDL_VideoDisplay
SDL_DisplayMode *display_modes;
SDL_DisplayMode desktop_mode;
SDL_DisplayMode current_mode;
SDL_DisplayOrientation orientation;
SDL_Window *fullscreen_window;
@ -181,16 +180,16 @@ struct SDL_VideoDevice
*/
int (*GetDisplayBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
/*
* Get the usable bounds of a display (bounds minus menubar or whatever)
*/
int (*GetDisplayUsableBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
/*
* Get the dots/pixels-per-inch of a display
*/
int (*GetDisplayDPI) (_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi);
/*
* Get the usable bounds of a display (bounds minus menubar or whatever)
*/
int (*GetDisplayUsableBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
/*
* Get a list of the available display modes for a display.
*/
@ -305,9 +304,6 @@ struct SDL_VideoDevice
/* Hit-testing */
int (*SetWindowHitTest)(SDL_Window * window, SDL_bool enabled);
/* Tell window that app enabled drag'n'drop events */
void (*AcceptDragAndDrop)(SDL_Window * window, SDL_bool accept);
/* * * */
/* Data common to all drivers */
SDL_bool is_dummy;
@ -427,8 +423,6 @@ extern SDL_VideoDevice *SDL_GetVideoDevice(void);
extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode);
extern int SDL_GetIndexOfDisplay(SDL_VideoDisplay *display);
extern SDL_VideoDisplay *SDL_GetDisplay(int displayIndex);
extern SDL_VideoDisplay *SDL_GetDisplayForWindow(SDL_Window *window);
extern void *SDL_GetDisplayDriverData( int displayIndex );
@ -460,8 +454,6 @@ extern void SDL_OnApplicationDidEnterBackground(void);
extern void SDL_OnApplicationWillEnterForeground(void);
extern void SDL_OnApplicationDidBecomeActive(void);
extern void SDL_ToggleDragAndDropSupport(void);
#endif /* SDL_sysvideo_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -641,7 +641,7 @@ SDL_GetNumVideoDisplays(void)
return _this->num_displays;
}
int
static int
SDL_GetIndexOfDisplay(SDL_VideoDisplay *display)
{
int displayIndex;
@ -739,17 +739,6 @@ SDL_GetDisplayDPI(int displayIndex, float * ddpi, float * hdpi, float * vdpi)
return -1;
}
SDL_DisplayOrientation
SDL_GetDisplayOrientation(int displayIndex)
{
SDL_VideoDisplay *display;
CHECK_DISPLAY_INDEX(displayIndex, SDL_ORIENTATION_UNKNOWN);
display = &_this->displays[displayIndex];
return display->orientation;
}
SDL_bool
SDL_AddDisplayMode(SDL_VideoDisplay * display, const SDL_DisplayMode * mode)
{
@ -1011,7 +1000,7 @@ SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode *
/* Actually change the display mode */
if (!_this->SetDisplayMode) {
return SDL_SetError("SDL video driver doesn't support changing display mode");
return SDL_SetError("Video driver doesn't support changing display mode");
}
if (_this->SetDisplayMode(_this, display, &display_mode) < 0) {
return -1;
@ -1020,14 +1009,6 @@ SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode *
return 0;
}
SDL_VideoDisplay *
SDL_GetDisplay(int displayIndex)
{
CHECK_DISPLAY_INDEX(displayIndex, NULL);
return &_this->displays[displayIndex];
}
int
SDL_GetWindowDisplayIndex(SDL_Window * window)
{
@ -1308,15 +1289,8 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
/* Generate a mode change event here */
if (resized) {
#ifndef ANDROID
// Android may not resize the window to exactly what our fullscreen mode is, especially on
// windowed Android environments like the Chromebook or Samsung DeX. Given this, we shouldn't
// use fullscreen_mode.w and fullscreen_mode.h, but rather get our current native size. As such,
// Android's SetWindowFullscreen will generate the window event for us with the proper final size.
SDL_SendWindowEvent(other, SDL_WINDOWEVENT_RESIZED,
fullscreen_mode.w, fullscreen_mode.h);
#endif
} else {
SDL_OnWindowResized(other);
}
@ -1348,45 +1322,11 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
}
#define CREATE_FLAGS \
(SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_SKIP_TASKBAR | SDL_WINDOW_POPUP_MENU | SDL_WINDOW_UTILITY | SDL_WINDOW_TOOLTIP | SDL_WINDOW_VULKAN | SDL_WINDOW_MINIMIZED)
static SDL_INLINE SDL_bool
IsAcceptingDragAndDrop(void)
{
if ((SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) ||
(SDL_GetEventState(SDL_DROPTEXT) == SDL_ENABLE)) {
return SDL_TRUE;
}
return SDL_FALSE;
}
/* prepare a newly-created window */
static SDL_INLINE void
PrepareDragAndDropSupport(SDL_Window *window)
{
if (_this->AcceptDragAndDrop) {
_this->AcceptDragAndDrop(window, IsAcceptingDragAndDrop());
}
}
/* toggle d'n'd for all existing windows. */
void
SDL_ToggleDragAndDropSupport(void)
{
if (_this && _this->AcceptDragAndDrop) {
const SDL_bool enable = IsAcceptingDragAndDrop();
SDL_Window *window;
for (window = _this->windows; window; window = window->next) {
_this->AcceptDragAndDrop(window, enable);
}
}
}
(SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_SKIP_TASKBAR | SDL_WINDOW_POPUP_MENU | SDL_WINDOW_UTILITY | SDL_WINDOW_TOOLTIP | SDL_WINDOW_VULKAN)
static void
SDL_FinishWindowCreation(SDL_Window *window, Uint32 flags)
{
PrepareDragAndDropSupport(window);
if (flags & SDL_WINDOW_MAXIMIZED) {
SDL_MaximizeWindow(window);
}
@ -1443,9 +1383,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
#endif
if (flags & SDL_WINDOW_OPENGL) {
if (!_this->GL_CreateContext) {
SDL_SetError("OpenGL support is either not configured in SDL "
"or not available in current SDL video driver "
"(%s) or platform", _this->name);
SDL_SetError("No OpenGL support in video driver");
return NULL;
}
if (SDL_GL_LoadLibrary(NULL) < 0) {
@ -1456,8 +1394,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
if (flags & SDL_WINDOW_VULKAN) {
if (!_this->Vulkan_CreateSurface) {
SDL_SetError("Vulkan support is either not configured in SDL "
"or not available in current SDL video driver "
"(%s) or platform", _this->name);
"or not available in video driver");
return NULL;
}
if (flags & SDL_WINDOW_OPENGL) {
@ -1540,15 +1477,6 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
return NULL;
}
/* Clear minimized if not on windows, only windows handles it at create rather than FinishWindowCreation,
* but it's important or window focus will get broken on windows!
*/
#if !defined(__WIN32__)
if (window->flags & SDL_WINDOW_MINIMIZED) {
window->flags &= ~SDL_WINDOW_MINIMIZED;
}
#endif
#if __WINRT__ && (NTDDI_VERSION < NTDDI_WIN10)
/* HACK: WinRT 8.x apps can't choose whether or not they are fullscreen
or not. The user can choose this, via OS-provided UI, but this can't
@ -1607,9 +1535,6 @@ SDL_CreateWindowFrom(const void *data)
SDL_DestroyWindow(window);
return NULL;
}
PrepareDragAndDropSupport(window);
return window;
}
@ -1619,9 +1544,7 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
SDL_bool loaded_opengl = SDL_FALSE;
if ((flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) {
return SDL_SetError("OpenGL support is either not configured in SDL "
"or not available in current SDL video driver "
"(%s) or platform", _this->name);
return SDL_SetError("No OpenGL support in video driver");
}
if (window->flags & SDL_WINDOW_FOREIGN) {
@ -2864,7 +2787,7 @@ SDL_GL_LoadLibrary(const char *path)
retval = 0;
} else {
if (!_this->GL_LoadLibrary) {
return SDL_SetError("No dynamic GL support in current SDL video driver (%s)", _this->name);
return SDL_SetError("No dynamic GL support in video driver");
}
retval = _this->GL_LoadLibrary(_this, path);
}
@ -2895,7 +2818,7 @@ SDL_GL_GetProcAddress(const char *proc)
SDL_SetError("No GL driver has been loaded");
}
} else {
SDL_SetError("No dynamic GL support in current SDL video driver (%s)", _this->name);
SDL_SetError("No dynamic GL support in video driver");
}
return func;
}
@ -3851,8 +3774,6 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
if (!messageboxdata) {
return SDL_InvalidParamError("messageboxdata");
} else if (messageboxdata->numbuttons < 0) {
return SDL_SetError("Invalid number of buttons");
}
current_window = SDL_GetKeyboardFocus();
@ -4062,9 +3983,7 @@ int SDL_Vulkan_LoadLibrary(const char *path)
retval = 0;
} else {
if (!_this->Vulkan_LoadLibrary) {
return SDL_SetError("Vulkan support is either not configured in SDL "
"or not available in current SDL video driver "
"(%s) or platform", _this->name);
return SDL_SetError("No Vulkan support in video driver");
}
retval = _this->Vulkan_LoadLibrary(_this, path);
}
@ -4105,14 +4024,11 @@ void SDL_Vulkan_UnloadLibrary(void)
SDL_bool SDL_Vulkan_GetInstanceExtensions(SDL_Window *window, unsigned *count, const char **names)
{
if (window) {
CHECK_WINDOW_MAGIC(window, SDL_FALSE);
CHECK_WINDOW_MAGIC(window, SDL_FALSE);
if (!(window->flags & SDL_WINDOW_VULKAN))
{
SDL_SetError(NOT_A_VULKAN_WINDOW);
return SDL_FALSE;
}
if (!(window->flags & SDL_WINDOW_VULKAN)) {
SDL_SetError(NOT_A_VULKAN_WINDOW);
return SDL_FALSE;
}
if (!count) {

View file

@ -123,10 +123,10 @@ VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList(
{
retval = SDL_calloc(1, sizeof(VkExtensionProperties)); // so we can return non-null
}
else
{
retval = SDL_calloc(count, sizeof(VkExtensionProperties));
}
else
{
retval = SDL_calloc(count, sizeof(VkExtensionProperties));
}
if(!retval)
{
SDL_OutOfMemory();

View file

@ -23,7 +23,6 @@
#include "SDL_endian.h"
#include "SDL_video.h"
#include "SDL_pixels_c.h"
#include "SDL_yuv_c.h"
#include "yuv2rgb/yuv_rgb.h"
@ -90,10 +89,10 @@ static SDL_bool IsPacked4Format(Uint32 format)
}
static int GetYUVPlanes(int width, int height, Uint32 format, const void *yuv, int yuv_pitch,
const Uint8 **y, const Uint8 **u, const Uint8 **v, Uint32 *y_stride, Uint32 *uv_stride)
const Uint8 **y, const Uint8 **u, const Uint8 **v, Uint32 *y_stride, Uint32 *uv_stride)
{
const Uint8 *planes[3] = { NULL, NULL, NULL };
int pitches[3] = { 0, 0, 0 };
const Uint8 *planes[3] = { NULL, NULL, NULL };
int pitches[3] = { 0, 0, 0 };
switch (format) {
case SDL_PIXELFORMAT_YV12:
@ -181,10 +180,10 @@ static int GetYUVPlanes(int width, int height, Uint32 format, const void *yuv, i
static SDL_bool yuv_rgb_sse(
Uint32 src_format, Uint32 dst_format,
Uint32 width, Uint32 height,
const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride,
Uint8 *rgb, Uint32 rgb_stride,
YCbCrType yuv_type)
Uint32 width, Uint32 height,
const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride,
Uint8 *rgb, Uint32 rgb_stride,
YCbCrType yuv_type)
{
#ifdef __SSE2__
if (!SDL_HasSSE2()) {
@ -290,10 +289,10 @@ static SDL_bool yuv_rgb_sse(
static SDL_bool yuv_rgb_std(
Uint32 src_format, Uint32 dst_format,
Uint32 width, Uint32 height,
const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride,
Uint8 *rgb, Uint32 rgb_stride,
YCbCrType yuv_type)
Uint32 width, Uint32 height,
const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride,
Uint8 *rgb, Uint32 rgb_stride,
YCbCrType yuv_type)
{
if (src_format == SDL_PIXELFORMAT_YV12 ||
src_format == SDL_PIXELFORMAT_IYUV) {
@ -396,7 +395,7 @@ SDL_ConvertPixels_YUV_to_RGB(int width, int height,
Uint32 src_format, const void *src, int src_pitch,
Uint32 dst_format, void *dst, int dst_pitch)
{
const Uint8 *y = NULL;
const Uint8 *y = NULL;
const Uint8 *u = NULL;
const Uint8 *v = NULL;
Uint32 y_stride = 0;
@ -554,7 +553,7 @@ SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void *src, int sr
Uint32 y_stride, uv_stride, y_skip, uv_skip;
GetYUVPlanes(width, height, dst_format, dst, dst_pitch,
(const Uint8 **)&plane_y, (const Uint8 **)&plane_u, (const Uint8 **)&plane_v,
(const Uint8 **)&plane_y, (const Uint8 **)&plane_u, (const Uint8 **)&plane_v,
&y_stride, &uv_stride);
plane_interleaved_uv = (plane_y + height * y_stride);
y_skip = (y_stride - width);

View file

@ -18,10 +18,6 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_yuv_c_h_
#define SDL_yuv_c_h_
#include "../SDL_internal.h"
@ -31,6 +27,4 @@ extern int SDL_ConvertPixels_YUV_to_RGB(int width, int height, Uint32 src_format
extern int SDL_ConvertPixels_RGB_to_YUV(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch);
extern int SDL_ConvertPixels_YUV_to_YUV(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch);
#endif /* SDL_yuv_c_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -42,164 +42,15 @@
#define BUTTON_BACK 8
#define BUTTON_FORWARD 16
typedef struct
{
int custom_cursor;
int system_cursor;
} SDL_AndroidCursorData;
/* Last known Android mouse button state (includes all buttons) */
static int last_state;
/* Blank cursor */
static SDL_Cursor *empty_cursor;
static SDL_Cursor *
Android_WrapCursor(int custom_cursor, int system_cursor)
{
SDL_Cursor *cursor;
cursor = SDL_calloc(1, sizeof(*cursor));
if (cursor) {
SDL_AndroidCursorData *data = (SDL_AndroidCursorData*)SDL_calloc(1, sizeof(*data));
if (data) {
data->custom_cursor = custom_cursor;
data->system_cursor = system_cursor;
cursor->driverdata = data;
} else {
SDL_free(cursor);
cursor = NULL;
SDL_OutOfMemory();
}
} else {
SDL_OutOfMemory();
}
return cursor;
}
static SDL_Cursor *
Android_CreateDefaultCursor()
{
return Android_WrapCursor(0, SDL_SYSTEM_CURSOR_ARROW);
}
static SDL_Cursor *
Android_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
{
int custom_cursor;
SDL_Surface *converted;
converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0);
if (!converted) {
return NULL;
}
custom_cursor = Android_JNI_CreateCustomCursor(converted, hot_x, hot_y);
SDL_FreeSurface(converted);
if (!custom_cursor) {
SDL_Unsupported();
return NULL;
}
return Android_WrapCursor(custom_cursor, 0);
}
static SDL_Cursor *
Android_CreateSystemCursor(SDL_SystemCursor id)
{
return Android_WrapCursor(0, id);
}
static void
Android_FreeCursor(SDL_Cursor * cursor)
{
SDL_free(cursor->driverdata);
SDL_free(cursor);
}
static SDL_Cursor *
Android_CreateEmptyCursor()
{
if (!empty_cursor) {
SDL_Surface *empty_surface = SDL_CreateRGBSurfaceWithFormat(0, 1, 1, 32, SDL_PIXELFORMAT_ARGB8888);
if (empty_surface) {
SDL_memset(empty_surface->pixels, 0, empty_surface->h * empty_surface->pitch);
empty_cursor = Android_CreateCursor(empty_surface, 0, 0);
SDL_FreeSurface(empty_surface);
}
}
return empty_cursor;
}
static void
Android_DestroyEmptyCursor()
{
if (empty_cursor) {
Android_FreeCursor(empty_cursor);
empty_cursor = NULL;
}
}
static int
Android_ShowCursor(SDL_Cursor * cursor)
{
if (!cursor) {
cursor = Android_CreateEmptyCursor();
}
if (cursor) {
SDL_AndroidCursorData *data = (SDL_AndroidCursorData*)cursor->driverdata;
if (data->custom_cursor) {
if (!Android_JNI_SetCustomCursor(data->custom_cursor)) {
return SDL_Unsupported();
}
} else {
if (!Android_JNI_SetSystemCursor(data->system_cursor)) {
return SDL_Unsupported();
}
}
return 0;
} else {
/* SDL error set inside Android_CreateEmptyCursor() */
return -1;
}
}
static int
Android_SetRelativeMouseMode(SDL_bool enabled)
{
if (!Android_JNI_SupportsRelativeMouse()) {
return SDL_Unsupported();
}
if (!Android_JNI_SetRelativeMouseEnabled(enabled)) {
return SDL_Unsupported();
}
return 0;
}
void
Android_InitMouse(void)
{
SDL_Mouse *mouse = SDL_GetMouse();
mouse->CreateCursor = Android_CreateCursor;
mouse->CreateSystemCursor = Android_CreateSystemCursor;
mouse->ShowCursor = Android_ShowCursor;
mouse->FreeCursor = Android_FreeCursor;
mouse->SetRelativeMouseMode = Android_SetRelativeMouseMode;
SDL_SetDefaultCursor(Android_CreateDefaultCursor());
last_state = 0;
}
void
Android_QuitMouse(void)
{
Android_DestroyEmptyCursor();
}
/* Translate Android mouse button state to SDL mouse button */
static Uint8
TranslateButton(int state)
@ -220,7 +71,7 @@ TranslateButton(int state)
}
void
Android_OnMouse(int state, int action, float x, float y, SDL_bool relative)
Android_OnMouse(int state, int action, float x, float y)
{
int changes;
Uint8 button;
@ -234,7 +85,7 @@ Android_OnMouse(int state, int action, float x, float y, SDL_bool relative)
changes = state & ~last_state;
button = TranslateButton(changes);
last_state = state;
SDL_SendMouseMotion(Android_Window, 0, relative, x, y);
SDL_SendMouseMotion(Android_Window, 0, 0, x, y);
SDL_SendMouseButton(Android_Window, 0, SDL_PRESSED, button);
break;
@ -242,13 +93,13 @@ Android_OnMouse(int state, int action, float x, float y, SDL_bool relative)
changes = last_state & ~state;
button = TranslateButton(changes);
last_state = state;
SDL_SendMouseMotion(Android_Window, 0, relative, x, y);
SDL_SendMouseMotion(Android_Window, 0, 0, x, y);
SDL_SendMouseButton(Android_Window, 0, SDL_RELEASED, button);
break;
case ACTION_MOVE:
case ACTION_HOVER_MOVE:
SDL_SendMouseMotion(Android_Window, 0, relative, x, y);
SDL_SendMouseMotion(Android_Window, 0, 0, x, y);
break;
case ACTION_SCROLL:

View file

@ -25,8 +25,7 @@
#include "SDL_androidvideo.h"
extern void Android_InitMouse(void);
extern void Android_OnMouse(int button, int action, float x, float y, SDL_bool relative);
extern void Android_QuitMouse(void);
extern void Android_OnMouse( int button, int action, float x, float y);
#endif /* SDL_androidmouse_h_ */

View file

@ -60,10 +60,8 @@ int Android_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float
/* These are filled in with real values in Android_SetScreenResolution on init (before SDL_main()) */
int Android_SurfaceWidth = 0;
int Android_SurfaceHeight = 0;
int Android_DeviceWidth = 0;
int Android_DeviceHeight = 0;
int Android_ScreenWidth = 0;
int Android_ScreenHeight = 0;
Uint32 Android_ScreenFormat = SDL_PIXELFORMAT_UNKNOWN;
static int Android_ScreenRate = 0;
@ -178,8 +176,8 @@ Android_VideoInit(_THIS)
SDL_DisplayMode mode;
mode.format = Android_ScreenFormat;
mode.w = Android_DeviceWidth;
mode.h = Android_DeviceHeight;
mode.w = Android_ScreenWidth;
mode.h = Android_ScreenHeight;
mode.refresh_rate = Android_ScreenRate;
mode.driverdata = NULL;
if (SDL_AddBasicVideoDisplay(&mode) < 0) {
@ -201,7 +199,6 @@ Android_VideoInit(_THIS)
void
Android_VideoQuit(_THIS)
{
Android_QuitMouse();
Android_QuitTouch();
}
@ -212,14 +209,12 @@ Android_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * h
}
void
Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, Uint32 format, float rate)
Android_SetScreenResolution(int width, int height, Uint32 format, float rate)
{
SDL_VideoDevice* device;
SDL_VideoDisplay *display;
Android_SurfaceWidth = surfaceWidth;
Android_SurfaceHeight = surfaceHeight;
Android_DeviceWidth = deviceWidth;
Android_DeviceHeight = deviceHeight;
SDL_VideoDevice* device;
SDL_VideoDisplay *display;
Android_ScreenWidth = width;
Android_ScreenHeight = height;
Android_ScreenFormat = format;
Android_ScreenRate = rate;
@ -234,8 +229,8 @@ Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth
{
display = &device->displays[0];
display->desktop_mode.format = Android_ScreenFormat;
display->desktop_mode.w = Android_DeviceWidth;
display->desktop_mode.h = Android_DeviceHeight;
display->desktop_mode.w = Android_ScreenWidth;
display->desktop_mode.h = Android_ScreenHeight;
display->desktop_mode.refresh_rate = Android_ScreenRate;
}
@ -245,12 +240,12 @@ Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth
display = SDL_GetDisplayForWindow(Android_Window);
display->display_modes[0].format = format;
display->display_modes[0].w = Android_DeviceWidth;
display->display_modes[0].h = Android_DeviceHeight;
display->display_modes[0].w = width;
display->display_modes[0].h = height;
display->display_modes[0].refresh_rate = rate;
display->current_mode = display->display_modes[0];
SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESIZED, surfaceWidth, surfaceHeight);
SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESIZED, width, height);
}
}

View file

@ -28,7 +28,7 @@
#include "../SDL_sysvideo.h"
/* Called by the JNI layer when the screen changes size or format */
extern void Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, Uint32 format, float rate);
extern void Android_SetScreenResolution(int width, int height, Uint32 format, float rate);
/* Private display data */
@ -37,10 +37,8 @@ typedef struct SDL_VideoData
SDL_Rect textRect;
} SDL_VideoData;
extern int Android_SurfaceWidth;
extern int Android_SurfaceHeight;
extern int Android_DeviceWidth;
extern int Android_DeviceHeight;
extern int Android_ScreenWidth;
extern int Android_ScreenHeight;
extern Uint32 Android_ScreenFormat;
extern SDL_sem *Android_PauseSem, *Android_ResumeSem;
extern SDL_Window *Android_Window;

View file

@ -26,8 +26,6 @@
#include "../SDL_sysvideo.h"
#include "../../events/SDL_keyboard_c.h"
#include "../../events/SDL_mouse_c.h"
#include "../../events/SDL_windowevents_c.h"
#include "../../core/android/SDL_android.h"
#include "SDL_androidvideo.h"
#include "SDL_androidwindow.h"
@ -51,8 +49,8 @@ Android_CreateWindow(_THIS, SDL_Window * window)
/* Adjust the window data to match the screen */
window->x = 0;
window->y = 0;
window->w = Android_SurfaceWidth;
window->h = Android_SurfaceHeight;
window->w = Android_ScreenWidth;
window->h = Android_ScreenHeight;
window->flags &= ~SDL_WINDOW_RESIZABLE; /* window is NEVER resizeable */
window->flags &= ~SDL_WINDOW_HIDDEN;
@ -102,36 +100,7 @@ Android_SetWindowTitle(_THIS, SDL_Window * window)
void
Android_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
{
/* If the window is being destroyed don't change visible state */
if (!window->is_destroying) {
Android_JNI_SetWindowStyle(fullscreen);
}
/* Ensure our size matches reality after we've executed the window style change.
*
* It is possible that we've set width and height to the full-size display, but on
* Samsung DeX or Chromebooks or other windowed Android environemtns, our window may
* still not be the full display size.
*/
if (!SDL_IsDeXMode() && !SDL_IsChromebook()) {
return;
}
SDL_WindowData * data = (SDL_WindowData *)window->driverdata;
if (!data || !data->native_window) {
return;
}
int old_w = window->w;
int old_h = window->h;
int new_w = ANativeWindow_getWidth(data->native_window);
int new_h = ANativeWindow_getHeight(data->native_window);
if (old_w != new_w || old_h != new_h) {
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, new_w, new_h);
}
Android_JNI_SetWindowStyle(fullscreen);
}
void

View file

@ -390,8 +390,8 @@ Cocoa_RegisterApp(void)
if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, SDL_FALSE)) {
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
}
}
if ([NSApp mainMenu] == nil) {
CreateApplicationMenus();
}

View file

@ -39,16 +39,16 @@
#define METALVIEW_TAG 255
@interface SDL_cocoametalview : NSView
@interface SDL_cocoametalview : NSView {
NSInteger _tag;
}
- (instancetype)initWithFrame:(NSRect)frame
highDPI:(BOOL)highDPI;
scale:(CGFloat)scale;
/* Override superclass tag so this class can set it. */
@property (assign, readonly) NSInteger tag;
@property (nonatomic) BOOL highDPI;
@end
SDL_cocoametalview* Cocoa_Mtl_AddMetalView(SDL_Window* window);

View file

@ -33,10 +33,13 @@
@implementation SDL_cocoametalview
/* The synthesized getter should be called by super's viewWithTag. */
@synthesize tag = _tag;
/* Return a Metal-compatible layer. */
+ (Class)layerClass
{
return NSClassFromString(@"CAMetalLayer");
return NSClassFromString(@"CAMetalLayer");
}
/* Indicate the view wants to draw using a backing layer instead of drawRect. */
@ -54,48 +57,28 @@
}
- (instancetype)initWithFrame:(NSRect)frame
highDPI:(BOOL)highDPI
scale:(CGFloat)scale
{
if ((self = [super initWithFrame:frame])) {
self.highDPI = highDPI;
if ((self = [super initWithFrame:frame])) {
_tag = METALVIEW_TAG;
self.wantsLayer = YES;
/* Allow resize. */
self.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
[self updateDrawableSize];
}
return self;
}
- (NSInteger)tag
{
return METALVIEW_TAG;
}
- (void)updateDrawableSize
{
CAMetalLayer *metalLayer = (CAMetalLayer *)self.layer;
CGSize size = self.bounds.size;
CGSize backingSize = size;
if (self.highDPI) {
/* Note: NSHighResolutionCapable must be set to true in the app's
* Info.plist in order for the backing size to be high res.
/* Set the desired scale. The default drawableSize of a CAMetalLayer
* is its bounds x its scale so nothing further needs to be done.
*/
backingSize = [self convertSizeToBacking:size];
}
metalLayer.contentsScale = backingSize.height / size.height;
metalLayer.drawableSize = backingSize;
self.layer.contentsScale = scale;
}
return self;
}
/* Set the size of the metal drawables when the view is resized. */
- (void)resizeWithOldSuperviewSize:(NSSize)oldSize
{
[super resizeWithOldSuperviewSize:oldSize];
[self updateDrawableSize];
}
@end
@ -105,10 +88,24 @@ Cocoa_Mtl_AddMetalView(SDL_Window* window)
{
SDL_WindowData* data = (__bridge SDL_WindowData *)window->driverdata;
NSView *view = data->nswindow.contentView;
BOOL highDPI = (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) != 0;
SDL_cocoametalview *metalview;
CGFloat scale = 1.0;
metalview = [[SDL_cocoametalview alloc] initWithFrame:view.frame highDPI:highDPI];
if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
/* Set the scale to the natural scale factor of the screen - then
* the backing dimensions of the Metal view will match the pixel
* dimensions of the screen rather than the dimensions in points
* yielding high resolution on retine displays.
*
* N.B. In order for backingScaleFactor to be > 1,
* NSHighResolutionCapable must be set to true in the app's Info.plist.
*/
NSWindow* nswindow = data->nswindow;
if ([nswindow.screen respondsToSelector:@selector(backingScaleFactor)])
scale = data->nswindow.screen.backingScaleFactor;
}
SDL_cocoametalview *metalview
= [[SDL_cocoametalview alloc] initWithFrame:view.frame scale:scale];
[view addSubview:metalview];
return metalview;
}

View file

@ -432,16 +432,6 @@ Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
}
}
if (x > 0) {
x = SDL_ceil(x);
} else if (x < 0) {
x = SDL_floor(x);
}
if (y > 0) {
y = SDL_ceil(y);
} else if (y < 0) {
y = SDL_floor(y);
}
SDL_SendMouseWheel(window, mouse->mouseID, x, y, direction);
}

View file

@ -211,7 +211,7 @@ Cocoa_InitMouseEventTap(SDL_MouseData* driverdata)
tapdata->thread = SDL_CreateThreadInternal(&Cocoa_MouseTapThread, "Event Tap Loop", 512 * 1024, tapdata);
if (tapdata->thread) {
/* Success - early out. Ownership transferred to thread. */
return;
return;
}
CFRelease(tapdata->tap);
}
@ -237,13 +237,6 @@ Cocoa_QuitMouseEventTap(SDL_MouseData *driverdata)
SDL_MouseEventTapData *tapdata = (SDL_MouseEventTapData*)driverdata->tapdata;
int status;
if (tapdata == NULL) {
/* event tap was already cleaned up (possibly due to CGEventTapCreate
* returning null.)
*/
return;
}
/* Ensure that the runloop has been started first.
* TODO: Move this to InitMouseEventTap, check for error conditions that can
* happen in Cocoa_MouseTapThread, and fall back to the non-EventTap way of

View file

@ -347,12 +347,10 @@ Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
NSView *contentView = [windata->nswindow contentView];
NSRect viewport = [contentView bounds];
if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
/* This gives us the correct viewport for a Retina-enabled view, only
* supported on 10.7+. */
if ([contentView respondsToSelector:@selector(convertRectToBacking:)]) {
viewport = [contentView convertRectToBacking:viewport];
}
/* This gives us the correct viewport for a Retina-enabled view, only
* supported on 10.7+. */
if ([contentView respondsToSelector:@selector(convertRectToBacking:)]) {
viewport = [contentView convertRectToBacking:viewport];
}
if (w) {
@ -410,14 +408,8 @@ Cocoa_GL_SwapWindow(_THIS, SDL_Window * window)
{ @autoreleasepool
{
SDLOpenGLContext* nscontext = (SDLOpenGLContext*)SDL_GL_GetCurrentContext();
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
/* on 10.14 ("Mojave") and later, this deadlocks if two contexts in two
threads try to swap at the same time, so put a mutex around it. */
SDL_LockMutex(videodata->swaplock);
[nscontext flushBuffer];
[nscontext updateIfNeeded];
SDL_UnlockMutex(videodata->swaplock);
return 0;
}}

View file

@ -107,7 +107,7 @@ typedef struct SDL_VideoData
Uint32 screensaver_activity;
BOOL screensaver_use_iopm;
IOPMAssertionID screensaver_assertion;
SDL_mutex *swaplock;
} SDL_VideoData;
/* Utility functions */

View file

@ -105,7 +105,6 @@ Cocoa_CreateDevice(int devindex)
device->DestroyWindow = Cocoa_DestroyWindow;
device->GetWindowWMInfo = Cocoa_GetWindowWMInfo;
device->SetWindowHitTest = Cocoa_SetWindowHitTest;
device->AcceptDragAndDrop = Cocoa_AcceptDragAndDrop;
device->shape_driver.CreateShaper = Cocoa_CreateShaper;
device->shape_driver.SetWindowShape = Cocoa_SetWindowShape;
@ -175,23 +174,15 @@ Cocoa_VideoInit(_THIS)
/* The IOPM assertion API can disable the screensaver as of 10.7. */
data->screensaver_use_iopm = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;
data->swaplock = SDL_CreateMutex();
if (!data->swaplock) {
return -1;
}
return 0;
}
void
Cocoa_VideoQuit(_THIS)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
Cocoa_QuitModes(_this);
Cocoa_QuitKeyboard(_this);
Cocoa_QuitMouse(_this);
SDL_DestroyMutex(data->swaplock);
data->swaplock = NULL;
}
/* This function assumes that it's called from within an autorelease pool */

View file

@ -58,7 +58,8 @@ int Cocoa_Vulkan_LoadLibrary(_THIS, const char *path)
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL;
if (_this->vulkan_config.loader_handle) {
return SDL_SetError("Vulkan/MoltenVK already loaded");
SDL_SetError("Vulkan/MoltenVK already loaded");
return -1;
}
/* Load the Vulkan loader library */
@ -79,7 +80,6 @@ int Cocoa_Vulkan_LoadLibrary(_THIS, const char *path)
_this->vulkan_config.loader_handle = DEFAULT_HANDLE;
} else {
const char** paths;
const char *foundPath = NULL;
int numPaths;
int i;
@ -92,17 +92,18 @@ int Cocoa_Vulkan_LoadLibrary(_THIS, const char *path)
paths = defaultPaths;
numPaths = SDL_arraysize(defaultPaths);
}
for (i = 0; i < numPaths && _this->vulkan_config.loader_handle == NULL; i++) {
foundPath = paths[i];
_this->vulkan_config.loader_handle = SDL_LoadObject(foundPath);
for (i=0; i < numPaths; i++) {
_this->vulkan_config.loader_handle = SDL_LoadObject(paths[i]);
if (_this->vulkan_config.loader_handle)
break;
else
continue;
}
if (i == numPaths)
return -1;
if (_this->vulkan_config.loader_handle == NULL) {
return SDL_SetError("Failed to load Vulkan/MoltenVK library");
}
SDL_strlcpy(_this->vulkan_config.loader_path, foundPath,
SDL_strlcpy(_this->vulkan_config.loader_path, paths[i],
SDL_arraysize(_this->vulkan_config.loader_path));
vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction(
_this->vulkan_config.loader_handle, "vkGetInstanceProcAddr");

View file

@ -148,7 +148,6 @@ extern void Cocoa_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
extern void Cocoa_DestroyWindow(_THIS, SDL_Window * window);
extern SDL_bool Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info);
extern int Cocoa_SetWindowHitTest(SDL_Window *window, SDL_bool enabled);
extern void Cocoa_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept);
#endif /* SDL_cocoawindow_h_ */

View file

@ -241,7 +241,7 @@ ScheduleContextUpdates(SDL_WindowData *data)
static int
GetHintCtrlClickEmulateRightClick()
{
return SDL_GetHintBoolean(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, SDL_FALSE);
return SDL_GetHintBoolean(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, SDL_FALSE);
}
static NSUInteger
@ -908,7 +908,7 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
switch ([theEvent buttonNumber]) {
case 0:
if (([theEvent modifierFlags] & NSEventModifierFlagControl) &&
GetHintCtrlClickEmulateRightClick()) {
GetHintCtrlClickEmulateRightClick()) {
wasCtrlLeft = YES;
button = SDL_BUTTON_RIGHT;
} else {
@ -1143,18 +1143,14 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
- (BOOL)mouseDownCanMoveWindow;
- (void)drawRect:(NSRect)dirtyRect;
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent;
- (BOOL)wantsUpdateLayer;
- (void)updateLayer;
@end
@implementation SDLView
- (void)setSDLWindow:(SDL_Window*)window
{
_sdlWindow = window;
}
/* this is used on older macOS revisions. 10.8 and later use updateLayer. */
- (void)drawRect:(NSRect)dirtyRect
{
/* Force the graphics context to clear to black so we don't get a flash of
@ -1165,21 +1161,6 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
SDL_SendWindowEvent(_sdlWindow, SDL_WINDOWEVENT_EXPOSED, 0, 0);
}
-(BOOL) wantsUpdateLayer
{
return YES;
}
-(void) updateLayer
{
/* Force the graphics context to clear to black so we don't get a flash of
white until the app is ready to draw. In practice on modern macOS, this
only gets called for window creation and other extraordinary events. */
self.layer.backgroundColor = NSColor.blackColor.CGColor;
ScheduleContextUpdates((SDL_WindowData *) _sdlWindow->driverdata);
SDL_SendWindowEvent(_sdlWindow, SDL_WINDOWEVENT_EXPOSED, 0, 0);
}
- (void)rightMouseDown:(NSEvent *)theEvent
{
[[self nextResponder] rightMouseDown:theEvent];
@ -1362,7 +1343,6 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
[contentView setWantsBestResolutionOpenGLSurface:YES];
}
}
#if SDL_VIDEO_OPENGL_ES2
#if SDL_VIDEO_OPENGL_EGL
if ((window->flags & SDL_WINDOW_OPENGL) &&
@ -1374,6 +1354,9 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
[nswindow setContentView:contentView];
[contentView release];
/* Allow files and folders to be dragged onto the window by users */
[nswindow registerForDraggedTypes:[NSArray arrayWithObject:(NSString *)kUTTypeFileURL]];
if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) {
[nswindow release];
return -1;
@ -1881,17 +1864,6 @@ Cocoa_SetWindowHitTest(SDL_Window * window, SDL_bool enabled)
return 0; /* just succeed, the real work is done elsewhere. */
}
void
Cocoa_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept)
{
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
if (accept) {
[data->nswindow registerForDraggedTypes:[NSArray arrayWithObject:(NSString *)kUTTypeFileURL]];
} else {
[data->nswindow unregisterDraggedTypes];
}
}
int
Cocoa_SetWindowOpacity(_THIS, SDL_Window * window, float opacity)
{

View file

@ -324,7 +324,6 @@ static const struct {
{ DSPF_YUY2, SDL_PIXELFORMAT_YUY2 }, /* 16 bit YUV (4 byte/ 2 pixel, macropixel contains CbYCrY [31:0]) */
{ DSPF_UYVY, SDL_PIXELFORMAT_UYVY }, /* 16 bit YUV (4 byte/ 2 pixel, macropixel contains YCbYCr [31:0]) */
{ DSPF_RGB555, SDL_PIXELFORMAT_RGB555 }, /* 16 bit RGB (2 byte, nothing @15, red 5@10, green 5@5, blue 5@0) */
{ DSPF_ABGR, SDL_PIXELFORMAT_ABGR8888 }, /* 32 bit ABGR (4 byte, alpha 8@24, blue 8@16, green 8@8, red 8@0) */
#if (ENABLE_LUT8)
{ DSPF_LUT8, SDL_PIXELFORMAT_INDEX8 }, /* 8 bit LUT (8 bit color and alpha lookup from palette) */
#endif
@ -371,6 +370,7 @@ static const struct {
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR24 },
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR888 },
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_RGBA8888 },
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR8888 },
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_BGRA8888 },
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_ARGB2101010 },
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR4444 },

View file

@ -18,16 +18,10 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_nullevents_c_h_
#define SDL_nullevents_c_h_
#include "../../SDL_internal.h"
#include "SDL_nullvideo.h"
extern void DUMMY_PumpEvents(_THIS);
#endif /* SDL_nullevents_c_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -18,16 +18,10 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_nullframebuffer_c_h_
#define SDL_nullframebuffer_c_h_
#include "../../SDL_internal.h"
extern int SDL_DUMMY_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch);
extern int SDL_DUMMY_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects);
extern void SDL_DUMMY_DestroyWindowFramebuffer(_THIS, SDL_Window * window);
#endif /* SDL_nullframebuffer_c_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -165,7 +165,6 @@ Emscripten_CreateSystemCursor(SDL_SystemCursor id)
cursor_name = "ns-resize";
break;
case SDL_SYSTEM_CURSOR_SIZEALL:
cursor_name = "move";
break;
case SDL_SYSTEM_CURSOR_NO:
cursor_name = "not-allowed";

View file

@ -60,9 +60,7 @@ Emscripten_GLES_LoadLibrary(_THIS, const char *path) {
LOAD_FUNC(eglWaitNative);
LOAD_FUNC(eglWaitGL);
LOAD_FUNC(eglBindAPI);
LOAD_FUNC(eglQueryString);
LOAD_FUNC(eglGetError);
_this->egl_data->egl_display = _this->egl_data->eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (!_this->egl_data->egl_display) {
return SDL_SetError("Could not get EGL display");

View file

@ -88,7 +88,7 @@ class SDL_BWin:public BDirectWindow
_clips = NULL;
#ifdef DRAWTHREAD
_draw_thread_id = spawn_thread(HAIKU_DrawThread, "drawing_thread",
_draw_thread_id = spawn_thread(BE_DrawThread, "drawing_thread",
B_NORMAL_PRIORITY, (void*) this);
resume_thread(_draw_thread_id);
#endif
@ -538,7 +538,7 @@ private:
msg.AddInt32("key-state", keyState);
msg.AddInt32("key-scancode", keyCode);
if (keyUtf8 != NULL) {
msg.AddData("key-utf8", B_INT8_TYPE, (const void*)keyUtf8, len);
msg.AddData("key-utf8", B_INT8_TYPE, (const void*)keyUtf8, len);
}
be_app->PostMessage(&msg);
}

View file

@ -35,55 +35,55 @@
extern "C" {
#endif
int HAIKU_SetClipboardText(_THIS, const char *text) {
BMessage *clip = NULL;
if(be_clipboard->Lock()) {
be_clipboard->Clear();
if((clip = be_clipboard->Data())) {
/* Presumably the string of characters is ascii-format */
ssize_t asciiLength = 0;
for(; text[asciiLength] != 0; ++asciiLength) {}
clip->AddData("text/plain", B_MIME_TYPE, text, asciiLength);
be_clipboard->Commit();
}
be_clipboard->Unlock();
}
return 0;
int BE_SetClipboardText(_THIS, const char *text) {
BMessage *clip = NULL;
if(be_clipboard->Lock()) {
be_clipboard->Clear();
if((clip = be_clipboard->Data())) {
/* Presumably the string of characters is ascii-format */
ssize_t asciiLength = 0;
for(; text[asciiLength] != 0; ++asciiLength) {}
clip->AddData("text/plain", B_MIME_TYPE, text, asciiLength);
be_clipboard->Commit();
}
be_clipboard->Unlock();
}
return 0;
}
char *HAIKU_GetClipboardText(_THIS) {
BMessage *clip = NULL;
const char *text = NULL;
ssize_t length;
char *result;
if(be_clipboard->Lock()) {
if((clip = be_clipboard->Data())) {
/* Presumably the string of characters is ascii-format */
clip->FindData("text/plain", B_MIME_TYPE, (const void**)&text,
&length);
}
be_clipboard->Unlock();
}
if (!text) {
result = SDL_strdup("");
} else {
/* Copy the data and pass on to SDL */
result = (char *)SDL_malloc((length + 1) * sizeof(char));
SDL_strlcpy(result, text, length + 1);
}
return result;
char *BE_GetClipboardText(_THIS) {
BMessage *clip = NULL;
const char *text = NULL;
ssize_t length;
char *result;
if(be_clipboard->Lock()) {
if((clip = be_clipboard->Data())) {
/* Presumably the string of characters is ascii-format */
clip->FindData("text/plain", B_MIME_TYPE, (const void**)&text,
&length);
}
be_clipboard->Unlock();
}
if (!text) {
result = SDL_strdup("");
} else {
/* Copy the data and pass on to SDL */
result = (char *)SDL_malloc((length + 1) * sizeof(char));
SDL_strlcpy(result, text, length + 1);
}
return result;
}
SDL_bool HAIKU_HasClipboardText(_THIS) {
SDL_bool result = SDL_FALSE;
char *text = HAIKU_GetClipboardText(_this);
if (text) {
result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE;
SDL_free(text);
}
return result;
SDL_bool BE_HasClipboardText(_THIS) {
SDL_bool result = SDL_FALSE;
char *text = BE_GetClipboardText(_this);
if (text) {
result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE;
SDL_free(text);
}
return result;
}
#ifdef __cplusplus

View file

@ -24,9 +24,9 @@
#ifndef SDL_BCLIPBOARD_H
#define SDL_BCLIPBOARD_H
extern int HAIKU_SetClipboardText(_THIS, const char *text);
extern char *HAIKU_GetClipboardText(_THIS);
extern SDL_bool HAIKU_HasClipboardText(_THIS);
extern int BE_SetClipboardText(_THIS, const char *text);
extern char *BE_GetClipboardText(_THIS);
extern SDL_bool BE_HasClipboardText(_THIS);
#endif

View file

@ -28,8 +28,8 @@
extern "C" {
#endif
void HAIKU_PumpEvents(_THIS) {
/* Since the event thread is its own thread, this isn't really necessary */
void BE_PumpEvents(_THIS) {
/* Since the event thread is its own thread, this isn't really necessary */
}
#ifdef __cplusplus

View file

@ -28,7 +28,7 @@
extern "C" {
#endif
extern void HAIKU_PumpEvents(_THIS);
extern void BE_PumpEvents(_THIS);
#ifdef __cplusplus
}

View file

@ -36,162 +36,162 @@ extern "C" {
#endif
#ifndef DRAWTHREAD
static int32 HAIKU_UpdateOnce(SDL_Window *window);
static int32 BE_UpdateOnce(SDL_Window *window);
#endif
static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) {
return ((SDL_BWin*)(window->driverdata));
return ((SDL_BWin*)(window->driverdata));
}
static SDL_INLINE SDL_BApp *_GetBeApp() {
return ((SDL_BApp*)be_app);
return ((SDL_BApp*)be_app);
}
int HAIKU_CreateWindowFramebuffer(_THIS, SDL_Window * window,
int BE_CreateWindowFramebuffer(_THIS, SDL_Window * window,
Uint32 * format,
void ** pixels, int *pitch) {
SDL_BWin *bwin = _ToBeWin(window);
BScreen bscreen;
if(!bscreen.IsValid()) {
return -1;
}
SDL_BWin *bwin = _ToBeWin(window);
BScreen bscreen;
if(!bscreen.IsValid()) {
return -1;
}
while(!bwin->Connected()) { snooze(100); }
/* Make sure we have exclusive access to frame buffer data */
bwin->LockBuffer();
while(!bwin->Connected()) { snooze(100); }
/* Make sure we have exclusive access to frame buffer data */
bwin->LockBuffer();
/* format */
display_mode bmode;
bscreen.GetMode(&bmode);
int32 bpp = HAIKU_ColorSpaceToBitsPerPixel(bmode.space);
*format = HAIKU_BPPToSDLPxFormat(bpp);
/* format */
display_mode bmode;
bscreen.GetMode(&bmode);
int32 bpp = BE_ColorSpaceToBitsPerPixel(bmode.space);
*format = BE_BPPToSDLPxFormat(bpp);
/* Create the new bitmap object */
BBitmap *bitmap = bwin->GetBitmap();
/* Create the new bitmap object */
BBitmap *bitmap = bwin->GetBitmap();
if(bitmap) {
delete bitmap;
}
bitmap = new BBitmap(bwin->Bounds(), (color_space)bmode.space,
false, /* Views not accepted */
true); /* Contiguous memory required */
if(bitmap->InitCheck() != B_OK) {
delete bitmap;
return SDL_SetError("Could not initialize back buffer!");
}
if(bitmap) {
delete bitmap;
}
bitmap = new BBitmap(bwin->Bounds(), (color_space)bmode.space,
false, /* Views not accepted */
true); /* Contiguous memory required */
if(bitmap->InitCheck() != B_OK) {
delete bitmap;
return SDL_SetError("Could not initialize back buffer!");
}
bwin->SetBitmap(bitmap);
/* Set the pixel pointer */
*pixels = bitmap->Bits();
bwin->SetBitmap(bitmap);
/* Set the pixel pointer */
*pixels = bitmap->Bits();
/* pitch = width of window, in bytes */
*pitch = bitmap->BytesPerRow();
/* pitch = width of window, in bytes */
*pitch = bitmap->BytesPerRow();
bwin->SetBufferExists(true);
bwin->SetTrashBuffer(false);
bwin->UnlockBuffer();
return 0;
bwin->SetBufferExists(true);
bwin->SetTrashBuffer(false);
bwin->UnlockBuffer();
return 0;
}
int HAIKU_UpdateWindowFramebuffer(_THIS, SDL_Window * window,
int BE_UpdateWindowFramebuffer(_THIS, SDL_Window * window,
const SDL_Rect * rects, int numrects) {
if(!window)
return 0;
if(!window)
return 0;
SDL_BWin *bwin = _ToBeWin(window);
SDL_BWin *bwin = _ToBeWin(window);
#ifdef DRAWTHREAD
bwin->LockBuffer();
bwin->SetBufferDirty(true);
bwin->UnlockBuffer();
#ifdef DRAWTHREAD
bwin->LockBuffer();
bwin->SetBufferDirty(true);
bwin->UnlockBuffer();
#else
bwin->SetBufferDirty(true);
HAIKU_UpdateOnce(window);
bwin->SetBufferDirty(true);
BE_UpdateOnce(window);
#endif
return 0;
return 0;
}
int32 HAIKU_DrawThread(void *data) {
SDL_BWin *bwin = (SDL_BWin*)data;
BScreen bscreen;
if(!bscreen.IsValid()) {
return -1;
}
int32 BE_DrawThread(void *data) {
SDL_BWin *bwin = (SDL_BWin*)data;
BScreen bscreen;
if(!bscreen.IsValid()) {
return -1;
}
while(bwin->ConnectionEnabled()) {
if( bwin->Connected() && bwin->BufferExists() && bwin->BufferIsDirty() ) {
bwin->LockBuffer();
BBitmap *bitmap = NULL;
bitmap = bwin->GetBitmap();
int32 windowPitch = bitmap->BytesPerRow();
int32 bufferPitch = bwin->GetRowBytes();
uint8 *windowpx;
uint8 *bufferpx;
while(bwin->ConnectionEnabled()) {
if( bwin->Connected() && bwin->BufferExists() && bwin->BufferIsDirty() ) {
bwin->LockBuffer();
BBitmap *bitmap = NULL;
bitmap = bwin->GetBitmap();
int32 windowPitch = bitmap->BytesPerRow();
int32 bufferPitch = bwin->GetRowBytes();
uint8 *windowpx;
uint8 *bufferpx;
int32 BPP = bwin->GetBytesPerPx();
int32 windowSub = bwin->GetFbX() * BPP +
bwin->GetFbY() * windowPitch;
clipping_rect *clips = bwin->GetClips();
int32 numClips = bwin->GetNumClips();
int i, y;
int32 BPP = bwin->GetBytesPerPx();
int32 windowSub = bwin->GetFbX() * BPP +
bwin->GetFbY() * windowPitch;
clipping_rect *clips = bwin->GetClips();
int32 numClips = bwin->GetNumClips();
int i, y;
/* Blit each clipping rectangle */
bscreen.WaitForRetrace();
for(i = 0; i < numClips; ++i) {
/* Get addresses of the start of each clipping rectangle */
int32 width = clips[i].right - clips[i].left + 1;
int32 height = clips[i].bottom - clips[i].top + 1;
bufferpx = bwin->GetBufferPx() +
clips[i].top * bufferPitch + clips[i].left * BPP;
windowpx = (uint8*)bitmap->Bits() +
clips[i].top * windowPitch + clips[i].left * BPP -
windowSub;
/* Blit each clipping rectangle */
bscreen.WaitForRetrace();
for(i = 0; i < numClips; ++i) {
/* Get addresses of the start of each clipping rectangle */
int32 width = clips[i].right - clips[i].left + 1;
int32 height = clips[i].bottom - clips[i].top + 1;
bufferpx = bwin->GetBufferPx() +
clips[i].top * bufferPitch + clips[i].left * BPP;
windowpx = (uint8*)bitmap->Bits() +
clips[i].top * windowPitch + clips[i].left * BPP -
windowSub;
/* Copy each row of pixels from the window buffer into the frame
buffer */
for(y = 0; y < height; ++y)
{
/* Copy each row of pixels from the window buffer into the frame
buffer */
for(y = 0; y < height; ++y)
{
if(bwin->CanTrashWindowBuffer()) {
goto escape; /* Break out before the buffer is killed */
}
if(bwin->CanTrashWindowBuffer()) {
goto escape; /* Break out before the buffer is killed */
}
memcpy(bufferpx, windowpx, width * BPP);
bufferpx += bufferPitch;
windowpx += windowPitch;
}
}
memcpy(bufferpx, windowpx, width * BPP);
bufferpx += bufferPitch;
windowpx += windowPitch;
}
}
bwin->SetBufferDirty(false);
bwin->SetBufferDirty(false);
escape:
bwin->UnlockBuffer();
} else {
snooze(16000);
}
}
return B_OK;
bwin->UnlockBuffer();
} else {
snooze(16000);
}
}
return B_OK;
}
void HAIKU_DestroyWindowFramebuffer(_THIS, SDL_Window * window) {
SDL_BWin *bwin = _ToBeWin(window);
bwin->LockBuffer();
/* Free and clear the window buffer */
BBitmap *bitmap = bwin->GetBitmap();
delete bitmap;
bwin->SetBitmap(NULL);
bwin->SetBufferExists(false);
bwin->UnlockBuffer();
void BE_DestroyWindowFramebuffer(_THIS, SDL_Window * window) {
SDL_BWin *bwin = _ToBeWin(window);
bwin->LockBuffer();
/* Free and clear the window buffer */
BBitmap *bitmap = bwin->GetBitmap();
delete bitmap;
bwin->SetBitmap(NULL);
bwin->SetBufferExists(false);
bwin->UnlockBuffer();
}
@ -202,51 +202,51 @@ void HAIKU_DestroyWindowFramebuffer(_THIS, SDL_Window * window) {
* solved, but I doubt it- they were pretty sporadic before now.
*/
#ifndef DRAWTHREAD
static int32 HAIKU_UpdateOnce(SDL_Window *window) {
SDL_BWin *bwin = _ToBeWin(window);
BScreen bscreen;
if(!bscreen.IsValid()) {
return -1;
}
static int32 BE_UpdateOnce(SDL_Window *window) {
SDL_BWin *bwin = _ToBeWin(window);
BScreen bscreen;
if(!bscreen.IsValid()) {
return -1;
}
if(bwin->ConnectionEnabled() && bwin->Connected()) {
bwin->LockBuffer();
int32 windowPitch = window->surface->pitch;
int32 bufferPitch = bwin->GetRowBytes();
uint8 *windowpx;
uint8 *bufferpx;
if(bwin->ConnectionEnabled() && bwin->Connected()) {
bwin->LockBuffer();
int32 windowPitch = window->surface->pitch;
int32 bufferPitch = bwin->GetRowBytes();
uint8 *windowpx;
uint8 *bufferpx;
int32 BPP = bwin->GetBytesPerPx();
uint8 *windowBaseAddress = (uint8*)window->surface->pixels;
int32 windowSub = bwin->GetFbX() * BPP +
bwin->GetFbY() * windowPitch;
clipping_rect *clips = bwin->GetClips();
int32 numClips = bwin->GetNumClips();
int i, y;
int32 BPP = bwin->GetBytesPerPx();
uint8 *windowBaseAddress = (uint8*)window->surface->pixels;
int32 windowSub = bwin->GetFbX() * BPP +
bwin->GetFbY() * windowPitch;
clipping_rect *clips = bwin->GetClips();
int32 numClips = bwin->GetNumClips();
int i, y;
/* Blit each clipping rectangle */
bscreen.WaitForRetrace();
for(i = 0; i < numClips; ++i) {
/* Get addresses of the start of each clipping rectangle */
int32 width = clips[i].right - clips[i].left + 1;
int32 height = clips[i].bottom - clips[i].top + 1;
bufferpx = bwin->GetBufferPx() +
clips[i].top * bufferPitch + clips[i].left * BPP;
windowpx = windowBaseAddress +
clips[i].top * windowPitch + clips[i].left * BPP - windowSub;
/* Blit each clipping rectangle */
bscreen.WaitForRetrace();
for(i = 0; i < numClips; ++i) {
/* Get addresses of the start of each clipping rectangle */
int32 width = clips[i].right - clips[i].left + 1;
int32 height = clips[i].bottom - clips[i].top + 1;
bufferpx = bwin->GetBufferPx() +
clips[i].top * bufferPitch + clips[i].left * BPP;
windowpx = windowBaseAddress +
clips[i].top * windowPitch + clips[i].left * BPP - windowSub;
/* Copy each row of pixels from the window buffer into the frame
buffer */
for(y = 0; y < height; ++y)
{
memcpy(bufferpx, windowpx, width * BPP);
bufferpx += bufferPitch;
windowpx += windowPitch;
}
}
bwin->UnlockBuffer();
}
return 0;
/* Copy each row of pixels from the window buffer into the frame
buffer */
for(y = 0; y < height; ++y)
{
memcpy(bufferpx, windowpx, width * BPP);
bufferpx += bufferPitch;
windowpx += windowPitch;
}
}
bwin->UnlockBuffer();
}
return 0;
}
#endif

View file

@ -30,13 +30,13 @@ extern "C" {
#include "../SDL_sysvideo.h"
extern int HAIKU_CreateWindowFramebuffer(_THIS, SDL_Window * window,
extern int BE_CreateWindowFramebuffer(_THIS, SDL_Window * window,
Uint32 * format,
void ** pixels, int *pitch);
extern int HAIKU_UpdateWindowFramebuffer(_THIS, SDL_Window * window,
extern int BE_UpdateWindowFramebuffer(_THIS, SDL_Window * window,
const SDL_Rect * rects, int numrects);
extern void HAIKU_DestroyWindowFramebuffer(_THIS, SDL_Window * window);
extern int32 HAIKU_DrawThread(void *data);
extern void BE_DestroyWindowFramebuffer(_THIS, SDL_Window * window);
extern int32 BE_DrawThread(void *data);
#ifdef __cplusplus
}

View file

@ -41,144 +41,144 @@ extern "C" {
static SDL_Scancode keymap[KEYMAP_SIZE];
static int8 keystate[KEYMAP_SIZE];
void HAIKU_InitOSKeymap(void) {
for( uint i = 0; i < SDL_TABLESIZE(keymap); ++i ) {
keymap[i] = SDL_SCANCODE_UNKNOWN;
}
void BE_InitOSKeymap(void) {
for( uint i = 0; i < SDL_TABLESIZE(keymap); ++i ) {
keymap[i] = SDL_SCANCODE_UNKNOWN;
}
for( uint i = 0; i < KEYMAP_SIZE; ++i ) {
keystate[i] = SDL_RELEASED;
}
for( uint i = 0; i < KEYMAP_SIZE; ++i ) {
keystate[i] = SDL_RELEASED;
}
keymap[0x01] = SDL_GetScancodeFromKey(SDLK_ESCAPE);
keymap[B_F1_KEY] = SDL_GetScancodeFromKey(SDLK_F1);
keymap[B_F2_KEY] = SDL_GetScancodeFromKey(SDLK_F2);
keymap[B_F3_KEY] = SDL_GetScancodeFromKey(SDLK_F3);
keymap[B_F4_KEY] = SDL_GetScancodeFromKey(SDLK_F4);
keymap[B_F5_KEY] = SDL_GetScancodeFromKey(SDLK_F5);
keymap[B_F6_KEY] = SDL_GetScancodeFromKey(SDLK_F6);
keymap[B_F7_KEY] = SDL_GetScancodeFromKey(SDLK_F7);
keymap[B_F8_KEY] = SDL_GetScancodeFromKey(SDLK_F8);
keymap[B_F9_KEY] = SDL_GetScancodeFromKey(SDLK_F9);
keymap[B_F10_KEY] = SDL_GetScancodeFromKey(SDLK_F10);
keymap[B_F11_KEY] = SDL_GetScancodeFromKey(SDLK_F11);
keymap[B_F12_KEY] = SDL_GetScancodeFromKey(SDLK_F12);
keymap[B_PRINT_KEY] = SDL_GetScancodeFromKey(SDLK_PRINTSCREEN);
keymap[B_SCROLL_KEY] = SDL_GetScancodeFromKey(SDLK_SCROLLLOCK);
keymap[B_PAUSE_KEY] = SDL_GetScancodeFromKey(SDLK_PAUSE);
keymap[0x11] = SDL_GetScancodeFromKey(SDLK_BACKQUOTE);
keymap[0x12] = SDL_GetScancodeFromKey(SDLK_1);
keymap[0x13] = SDL_GetScancodeFromKey(SDLK_2);
keymap[0x14] = SDL_GetScancodeFromKey(SDLK_3);
keymap[0x15] = SDL_GetScancodeFromKey(SDLK_4);
keymap[0x16] = SDL_GetScancodeFromKey(SDLK_5);
keymap[0x17] = SDL_GetScancodeFromKey(SDLK_6);
keymap[0x18] = SDL_GetScancodeFromKey(SDLK_7);
keymap[0x19] = SDL_GetScancodeFromKey(SDLK_8);
keymap[0x1a] = SDL_GetScancodeFromKey(SDLK_9);
keymap[0x1b] = SDL_GetScancodeFromKey(SDLK_0);
keymap[0x1c] = SDL_GetScancodeFromKey(SDLK_MINUS);
keymap[0x1d] = SDL_GetScancodeFromKey(SDLK_EQUALS);
keymap[0x1e] = SDL_GetScancodeFromKey(SDLK_BACKSPACE);
keymap[0x1f] = SDL_GetScancodeFromKey(SDLK_INSERT);
keymap[0x20] = SDL_GetScancodeFromKey(SDLK_HOME);
keymap[0x21] = SDL_GetScancodeFromKey(SDLK_PAGEUP);
keymap[0x22] = SDL_GetScancodeFromKey(SDLK_NUMLOCKCLEAR);
keymap[0x23] = SDL_GetScancodeFromKey(SDLK_KP_DIVIDE);
keymap[0x24] = SDL_GetScancodeFromKey(SDLK_KP_MULTIPLY);
keymap[0x25] = SDL_GetScancodeFromKey(SDLK_KP_MINUS);
keymap[0x26] = SDL_GetScancodeFromKey(SDLK_TAB);
keymap[0x27] = SDL_GetScancodeFromKey(SDLK_q);
keymap[0x28] = SDL_GetScancodeFromKey(SDLK_w);
keymap[0x29] = SDL_GetScancodeFromKey(SDLK_e);
keymap[0x2a] = SDL_GetScancodeFromKey(SDLK_r);
keymap[0x2b] = SDL_GetScancodeFromKey(SDLK_t);
keymap[0x2c] = SDL_GetScancodeFromKey(SDLK_y);
keymap[0x2d] = SDL_GetScancodeFromKey(SDLK_u);
keymap[0x2e] = SDL_GetScancodeFromKey(SDLK_i);
keymap[0x2f] = SDL_GetScancodeFromKey(SDLK_o);
keymap[0x30] = SDL_GetScancodeFromKey(SDLK_p);
keymap[0x31] = SDL_GetScancodeFromKey(SDLK_LEFTBRACKET);
keymap[0x32] = SDL_GetScancodeFromKey(SDLK_RIGHTBRACKET);
keymap[0x33] = SDL_GetScancodeFromKey(SDLK_BACKSLASH);
keymap[0x34] = SDL_GetScancodeFromKey(SDLK_DELETE);
keymap[0x35] = SDL_GetScancodeFromKey(SDLK_END);
keymap[0x36] = SDL_GetScancodeFromKey(SDLK_PAGEDOWN);
keymap[0x37] = SDL_GetScancodeFromKey(SDLK_KP_7);
keymap[0x38] = SDL_GetScancodeFromKey(SDLK_KP_8);
keymap[0x39] = SDL_GetScancodeFromKey(SDLK_KP_9);
keymap[0x3a] = SDL_GetScancodeFromKey(SDLK_KP_PLUS);
keymap[0x3b] = SDL_GetScancodeFromKey(SDLK_CAPSLOCK);
keymap[0x3c] = SDL_GetScancodeFromKey(SDLK_a);
keymap[0x3d] = SDL_GetScancodeFromKey(SDLK_s);
keymap[0x3e] = SDL_GetScancodeFromKey(SDLK_d);
keymap[0x3f] = SDL_GetScancodeFromKey(SDLK_f);
keymap[0x40] = SDL_GetScancodeFromKey(SDLK_g);
keymap[0x41] = SDL_GetScancodeFromKey(SDLK_h);
keymap[0x42] = SDL_GetScancodeFromKey(SDLK_j);
keymap[0x43] = SDL_GetScancodeFromKey(SDLK_k);
keymap[0x44] = SDL_GetScancodeFromKey(SDLK_l);
keymap[0x45] = SDL_GetScancodeFromKey(SDLK_SEMICOLON);
keymap[0x46] = SDL_GetScancodeFromKey(SDLK_QUOTE);
keymap[0x47] = SDL_GetScancodeFromKey(SDLK_RETURN);
keymap[0x48] = SDL_GetScancodeFromKey(SDLK_KP_4);
keymap[0x49] = SDL_GetScancodeFromKey(SDLK_KP_5);
keymap[0x4a] = SDL_GetScancodeFromKey(SDLK_KP_6);
keymap[0x4b] = SDL_GetScancodeFromKey(SDLK_LSHIFT);
keymap[0x4c] = SDL_GetScancodeFromKey(SDLK_z);
keymap[0x4d] = SDL_GetScancodeFromKey(SDLK_x);
keymap[0x4e] = SDL_GetScancodeFromKey(SDLK_c);
keymap[0x4f] = SDL_GetScancodeFromKey(SDLK_v);
keymap[0x50] = SDL_GetScancodeFromKey(SDLK_b);
keymap[0x51] = SDL_GetScancodeFromKey(SDLK_n);
keymap[0x52] = SDL_GetScancodeFromKey(SDLK_m);
keymap[0x53] = SDL_GetScancodeFromKey(SDLK_COMMA);
keymap[0x54] = SDL_GetScancodeFromKey(SDLK_PERIOD);
keymap[0x55] = SDL_GetScancodeFromKey(SDLK_SLASH);
keymap[0x56] = SDL_GetScancodeFromKey(SDLK_RSHIFT);
keymap[0x57] = SDL_GetScancodeFromKey(SDLK_UP);
keymap[0x58] = SDL_GetScancodeFromKey(SDLK_KP_1);
keymap[0x59] = SDL_GetScancodeFromKey(SDLK_KP_2);
keymap[0x5a] = SDL_GetScancodeFromKey(SDLK_KP_3);
keymap[0x5b] = SDL_GetScancodeFromKey(SDLK_KP_ENTER);
keymap[0x5c] = SDL_GetScancodeFromKey(SDLK_LCTRL);
keymap[0x5d] = SDL_GetScancodeFromKey(SDLK_LALT);
keymap[0x5e] = SDL_GetScancodeFromKey(SDLK_SPACE);
keymap[0x5f] = SDL_GetScancodeFromKey(SDLK_RALT);
keymap[0x60] = SDL_GetScancodeFromKey(SDLK_RCTRL);
keymap[0x61] = SDL_GetScancodeFromKey(SDLK_LEFT);
keymap[0x62] = SDL_GetScancodeFromKey(SDLK_DOWN);
keymap[0x63] = SDL_GetScancodeFromKey(SDLK_RIGHT);
keymap[0x64] = SDL_GetScancodeFromKey(SDLK_KP_0);
keymap[0x65] = SDL_GetScancodeFromKey(SDLK_KP_PERIOD);
keymap[0x66] = SDL_GetScancodeFromKey(SDLK_LGUI);
keymap[0x67] = SDL_GetScancodeFromKey(SDLK_RGUI);
keymap[0x68] = SDL_GetScancodeFromKey(SDLK_MENU);
keymap[0x69] = SDL_GetScancodeFromKey(SDLK_2); /* SDLK_EURO */
keymap[0x6a] = SDL_GetScancodeFromKey(SDLK_KP_EQUALS);
keymap[0x6b] = SDL_GetScancodeFromKey(SDLK_POWER);
keymap[0x01] = SDL_GetScancodeFromKey(SDLK_ESCAPE);
keymap[B_F1_KEY] = SDL_GetScancodeFromKey(SDLK_F1);
keymap[B_F2_KEY] = SDL_GetScancodeFromKey(SDLK_F2);
keymap[B_F3_KEY] = SDL_GetScancodeFromKey(SDLK_F3);
keymap[B_F4_KEY] = SDL_GetScancodeFromKey(SDLK_F4);
keymap[B_F5_KEY] = SDL_GetScancodeFromKey(SDLK_F5);
keymap[B_F6_KEY] = SDL_GetScancodeFromKey(SDLK_F6);
keymap[B_F7_KEY] = SDL_GetScancodeFromKey(SDLK_F7);
keymap[B_F8_KEY] = SDL_GetScancodeFromKey(SDLK_F8);
keymap[B_F9_KEY] = SDL_GetScancodeFromKey(SDLK_F9);
keymap[B_F10_KEY] = SDL_GetScancodeFromKey(SDLK_F10);
keymap[B_F11_KEY] = SDL_GetScancodeFromKey(SDLK_F11);
keymap[B_F12_KEY] = SDL_GetScancodeFromKey(SDLK_F12);
keymap[B_PRINT_KEY] = SDL_GetScancodeFromKey(SDLK_PRINTSCREEN);
keymap[B_SCROLL_KEY] = SDL_GetScancodeFromKey(SDLK_SCROLLLOCK);
keymap[B_PAUSE_KEY] = SDL_GetScancodeFromKey(SDLK_PAUSE);
keymap[0x11] = SDL_GetScancodeFromKey(SDLK_BACKQUOTE);
keymap[0x12] = SDL_GetScancodeFromKey(SDLK_1);
keymap[0x13] = SDL_GetScancodeFromKey(SDLK_2);
keymap[0x14] = SDL_GetScancodeFromKey(SDLK_3);
keymap[0x15] = SDL_GetScancodeFromKey(SDLK_4);
keymap[0x16] = SDL_GetScancodeFromKey(SDLK_5);
keymap[0x17] = SDL_GetScancodeFromKey(SDLK_6);
keymap[0x18] = SDL_GetScancodeFromKey(SDLK_7);
keymap[0x19] = SDL_GetScancodeFromKey(SDLK_8);
keymap[0x1a] = SDL_GetScancodeFromKey(SDLK_9);
keymap[0x1b] = SDL_GetScancodeFromKey(SDLK_0);
keymap[0x1c] = SDL_GetScancodeFromKey(SDLK_MINUS);
keymap[0x1d] = SDL_GetScancodeFromKey(SDLK_EQUALS);
keymap[0x1e] = SDL_GetScancodeFromKey(SDLK_BACKSPACE);
keymap[0x1f] = SDL_GetScancodeFromKey(SDLK_INSERT);
keymap[0x20] = SDL_GetScancodeFromKey(SDLK_HOME);
keymap[0x21] = SDL_GetScancodeFromKey(SDLK_PAGEUP);
keymap[0x22] = SDL_GetScancodeFromKey(SDLK_NUMLOCKCLEAR);
keymap[0x23] = SDL_GetScancodeFromKey(SDLK_KP_DIVIDE);
keymap[0x24] = SDL_GetScancodeFromKey(SDLK_KP_MULTIPLY);
keymap[0x25] = SDL_GetScancodeFromKey(SDLK_KP_MINUS);
keymap[0x26] = SDL_GetScancodeFromKey(SDLK_TAB);
keymap[0x27] = SDL_GetScancodeFromKey(SDLK_q);
keymap[0x28] = SDL_GetScancodeFromKey(SDLK_w);
keymap[0x29] = SDL_GetScancodeFromKey(SDLK_e);
keymap[0x2a] = SDL_GetScancodeFromKey(SDLK_r);
keymap[0x2b] = SDL_GetScancodeFromKey(SDLK_t);
keymap[0x2c] = SDL_GetScancodeFromKey(SDLK_y);
keymap[0x2d] = SDL_GetScancodeFromKey(SDLK_u);
keymap[0x2e] = SDL_GetScancodeFromKey(SDLK_i);
keymap[0x2f] = SDL_GetScancodeFromKey(SDLK_o);
keymap[0x30] = SDL_GetScancodeFromKey(SDLK_p);
keymap[0x31] = SDL_GetScancodeFromKey(SDLK_LEFTBRACKET);
keymap[0x32] = SDL_GetScancodeFromKey(SDLK_RIGHTBRACKET);
keymap[0x33] = SDL_GetScancodeFromKey(SDLK_BACKSLASH);
keymap[0x34] = SDL_GetScancodeFromKey(SDLK_DELETE);
keymap[0x35] = SDL_GetScancodeFromKey(SDLK_END);
keymap[0x36] = SDL_GetScancodeFromKey(SDLK_PAGEDOWN);
keymap[0x37] = SDL_GetScancodeFromKey(SDLK_KP_7);
keymap[0x38] = SDL_GetScancodeFromKey(SDLK_KP_8);
keymap[0x39] = SDL_GetScancodeFromKey(SDLK_KP_9);
keymap[0x3a] = SDL_GetScancodeFromKey(SDLK_KP_PLUS);
keymap[0x3b] = SDL_GetScancodeFromKey(SDLK_CAPSLOCK);
keymap[0x3c] = SDL_GetScancodeFromKey(SDLK_a);
keymap[0x3d] = SDL_GetScancodeFromKey(SDLK_s);
keymap[0x3e] = SDL_GetScancodeFromKey(SDLK_d);
keymap[0x3f] = SDL_GetScancodeFromKey(SDLK_f);
keymap[0x40] = SDL_GetScancodeFromKey(SDLK_g);
keymap[0x41] = SDL_GetScancodeFromKey(SDLK_h);
keymap[0x42] = SDL_GetScancodeFromKey(SDLK_j);
keymap[0x43] = SDL_GetScancodeFromKey(SDLK_k);
keymap[0x44] = SDL_GetScancodeFromKey(SDLK_l);
keymap[0x45] = SDL_GetScancodeFromKey(SDLK_SEMICOLON);
keymap[0x46] = SDL_GetScancodeFromKey(SDLK_QUOTE);
keymap[0x47] = SDL_GetScancodeFromKey(SDLK_RETURN);
keymap[0x48] = SDL_GetScancodeFromKey(SDLK_KP_4);
keymap[0x49] = SDL_GetScancodeFromKey(SDLK_KP_5);
keymap[0x4a] = SDL_GetScancodeFromKey(SDLK_KP_6);
keymap[0x4b] = SDL_GetScancodeFromKey(SDLK_LSHIFT);
keymap[0x4c] = SDL_GetScancodeFromKey(SDLK_z);
keymap[0x4d] = SDL_GetScancodeFromKey(SDLK_x);
keymap[0x4e] = SDL_GetScancodeFromKey(SDLK_c);
keymap[0x4f] = SDL_GetScancodeFromKey(SDLK_v);
keymap[0x50] = SDL_GetScancodeFromKey(SDLK_b);
keymap[0x51] = SDL_GetScancodeFromKey(SDLK_n);
keymap[0x52] = SDL_GetScancodeFromKey(SDLK_m);
keymap[0x53] = SDL_GetScancodeFromKey(SDLK_COMMA);
keymap[0x54] = SDL_GetScancodeFromKey(SDLK_PERIOD);
keymap[0x55] = SDL_GetScancodeFromKey(SDLK_SLASH);
keymap[0x56] = SDL_GetScancodeFromKey(SDLK_RSHIFT);
keymap[0x57] = SDL_GetScancodeFromKey(SDLK_UP);
keymap[0x58] = SDL_GetScancodeFromKey(SDLK_KP_1);
keymap[0x59] = SDL_GetScancodeFromKey(SDLK_KP_2);
keymap[0x5a] = SDL_GetScancodeFromKey(SDLK_KP_3);
keymap[0x5b] = SDL_GetScancodeFromKey(SDLK_KP_ENTER);
keymap[0x5c] = SDL_GetScancodeFromKey(SDLK_LCTRL);
keymap[0x5d] = SDL_GetScancodeFromKey(SDLK_LALT);
keymap[0x5e] = SDL_GetScancodeFromKey(SDLK_SPACE);
keymap[0x5f] = SDL_GetScancodeFromKey(SDLK_RALT);
keymap[0x60] = SDL_GetScancodeFromKey(SDLK_RCTRL);
keymap[0x61] = SDL_GetScancodeFromKey(SDLK_LEFT);
keymap[0x62] = SDL_GetScancodeFromKey(SDLK_DOWN);
keymap[0x63] = SDL_GetScancodeFromKey(SDLK_RIGHT);
keymap[0x64] = SDL_GetScancodeFromKey(SDLK_KP_0);
keymap[0x65] = SDL_GetScancodeFromKey(SDLK_KP_PERIOD);
keymap[0x66] = SDL_GetScancodeFromKey(SDLK_LGUI);
keymap[0x67] = SDL_GetScancodeFromKey(SDLK_RGUI);
keymap[0x68] = SDL_GetScancodeFromKey(SDLK_MENU);
keymap[0x69] = SDL_GetScancodeFromKey(SDLK_2); /* SDLK_EURO */
keymap[0x6a] = SDL_GetScancodeFromKey(SDLK_KP_EQUALS);
keymap[0x6b] = SDL_GetScancodeFromKey(SDLK_POWER);
}
SDL_Scancode HAIKU_GetScancodeFromBeKey(int32 bkey) {
if(bkey > 0 && bkey < (int32)SDL_TABLESIZE(keymap)) {
return keymap[bkey];
} else {
return SDL_SCANCODE_UNKNOWN;
}
SDL_Scancode BE_GetScancodeFromBeKey(int32 bkey) {
if(bkey > 0 && bkey < (int32)SDL_TABLESIZE(keymap)) {
return keymap[bkey];
} else {
return SDL_SCANCODE_UNKNOWN;
}
}
int8 HAIKU_GetKeyState(int32 bkey) {
if(bkey > 0 && bkey < KEYMAP_SIZE) {
return keystate[bkey];
} else {
return SDL_RELEASED;
}
int8 BE_GetKeyState(int32 bkey) {
if(bkey > 0 && bkey < KEYMAP_SIZE) {
return keystate[bkey];
} else {
return SDL_RELEASED;
}
}
void HAIKU_SetKeyState(int32 bkey, int8 state) {
if(bkey > 0 && bkey < KEYMAP_SIZE) {
keystate[bkey] = state;
}
void BE_SetKeyState(int32 bkey, int8 state) {
if(bkey > 0 && bkey < KEYMAP_SIZE) {
keystate[bkey] = state;
}
}
#ifdef __cplusplus

View file

@ -30,10 +30,10 @@ extern "C" {
#include "../../../include/SDL_keyboard.h"
extern void HAIKU_InitOSKeymap(void);
extern SDL_Scancode HAIKU_GetScancodeFromBeKey(int32 bkey);
extern int8 HAIKU_GetKeyState(int32 bkey);
extern void HAIKU_SetKeyState(int32 bkey, int8 state);
extern void BE_InitOSKeymap(void);
extern SDL_Scancode BE_GetScancodeFromBeKey(int32 bkey);
extern int8 BE_GetKeyState(int32 bkey);
extern void BE_SetKeyState(int32 bkey, int8 state);
#ifdef __cplusplus
}

View file

@ -44,30 +44,30 @@ extern "C" {
/* This wrapper is here so that the driverdata can be freed without freeing
the display_mode structure */
struct SDL_DisplayModeData {
display_mode *bmode;
display_mode *bmode;
};
#endif
static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) {
return ((SDL_BWin*)(window->driverdata));
return ((SDL_BWin*)(window->driverdata));
}
static SDL_INLINE SDL_BApp *_GetBeApp() {
return ((SDL_BApp*)be_app);
return ((SDL_BApp*)be_app);
}
static SDL_INLINE display_mode * _ExtractBMode(SDL_DisplayMode *mode) {
#if WRAP_BMODE
return ((SDL_DisplayModeData*)mode->driverdata)->bmode;
return ((SDL_DisplayModeData*)mode->driverdata)->bmode;
#else
return (display_mode*)(mode->driverdata);
return (display_mode*)(mode->driverdata);
#endif
}
/* Copied from haiku/trunk/src/preferences/screen/ScreenMode.cpp */
static float get_refresh_rate(display_mode &mode) {
return float(mode.timing.pixel_clock * 1000)
/ float(mode.timing.h_total * mode.timing.v_total);
return float(mode.timing.pixel_clock * 1000)
/ float(mode.timing.h_total * mode.timing.v_total);
}
@ -76,252 +76,252 @@ static float get_refresh_rate(display_mode &mode) {
* This is a useful debugging tool. Uncomment and insert into code as needed.
*/
void _SpoutModeData(display_mode *bmode) {
printf("BMode:\n");
printf("\tw,h = (%i,%i)\n", bmode->virtual_width, bmode->virtual_height);
printf("\th,v = (%i,%i)\n", bmode->h_display_start,
bmode->v_display_start);
if(bmode->flags) {
printf("\tFlags:\n");
if(bmode->flags & B_SCROLL) {
printf("\t\tB_SCROLL\n");
}
if(bmode->flags & B_8_BIT_DAC) {
printf("\t\tB_8_BIT_DAC\n");
}
if(bmode->flags & B_HARDWARE_CURSOR) {
printf("\t\tB_HARDWARE_CURSOR\n");
}
if(bmode->flags & B_PARALLEL_ACCESS) {
printf("\t\tB_PARALLEL_ACCESS\n");
}
if(bmode->flags & B_DPMS) {
printf("\t\tB_DPMS\n");
}
if(bmode->flags & B_IO_FB_NA) {
printf("\t\tB_IO_FB_NA\n");
}
}
printf("\tTiming:\n");
printf("\t\tpx clock: %i\n", bmode->timing.pixel_clock);
printf("\t\th - display: %i sync start: %i sync end: %i total: %i\n",
bmode->timing.h_display, bmode->timing.h_sync_start,
bmode->timing.h_sync_end, bmode->timing.h_total);
printf("\t\tv - display: %i sync start: %i sync end: %i total: %i\n",
bmode->timing.v_display, bmode->timing.v_sync_start,
bmode->timing.v_sync_end, bmode->timing.v_total);
if(bmode->timing.flags) {
printf("\t\tFlags:\n");
if(bmode->timing.flags & B_BLANK_PEDESTAL) {
printf("\t\t\tB_BLANK_PEDESTAL\n");
}
if(bmode->timing.flags & B_TIMING_INTERLACED) {
printf("\t\t\tB_TIMING_INTERLACED\n");
}
if(bmode->timing.flags & B_POSITIVE_HSYNC) {
printf("\t\t\tB_POSITIVE_HSYNC\n");
}
if(bmode->timing.flags & B_POSITIVE_VSYNC) {
printf("\t\t\tB_POSITIVE_VSYNC\n");
}
if(bmode->timing.flags & B_SYNC_ON_GREEN) {
printf("\t\t\tB_SYNC_ON_GREEN\n");
}
}
printf("BMode:\n");
printf("\tw,h = (%i,%i)\n", bmode->virtual_width, bmode->virtual_height);
printf("\th,v = (%i,%i)\n", bmode->h_display_start,
bmode->v_display_start);
if(bmode->flags) {
printf("\tFlags:\n");
if(bmode->flags & B_SCROLL) {
printf("\t\tB_SCROLL\n");
}
if(bmode->flags & B_8_BIT_DAC) {
printf("\t\tB_8_BIT_DAC\n");
}
if(bmode->flags & B_HARDWARE_CURSOR) {
printf("\t\tB_HARDWARE_CURSOR\n");
}
if(bmode->flags & B_PARALLEL_ACCESS) {
printf("\t\tB_PARALLEL_ACCESS\n");
}
if(bmode->flags & B_DPMS) {
printf("\t\tB_DPMS\n");
}
if(bmode->flags & B_IO_FB_NA) {
printf("\t\tB_IO_FB_NA\n");
}
}
printf("\tTiming:\n");
printf("\t\tpx clock: %i\n", bmode->timing.pixel_clock);
printf("\t\th - display: %i sync start: %i sync end: %i total: %i\n",
bmode->timing.h_display, bmode->timing.h_sync_start,
bmode->timing.h_sync_end, bmode->timing.h_total);
printf("\t\tv - display: %i sync start: %i sync end: %i total: %i\n",
bmode->timing.v_display, bmode->timing.v_sync_start,
bmode->timing.v_sync_end, bmode->timing.v_total);
if(bmode->timing.flags) {
printf("\t\tFlags:\n");
if(bmode->timing.flags & B_BLANK_PEDESTAL) {
printf("\t\t\tB_BLANK_PEDESTAL\n");
}
if(bmode->timing.flags & B_TIMING_INTERLACED) {
printf("\t\t\tB_TIMING_INTERLACED\n");
}
if(bmode->timing.flags & B_POSITIVE_HSYNC) {
printf("\t\t\tB_POSITIVE_HSYNC\n");
}
if(bmode->timing.flags & B_POSITIVE_VSYNC) {
printf("\t\t\tB_POSITIVE_VSYNC\n");
}
if(bmode->timing.flags & B_SYNC_ON_GREEN) {
printf("\t\t\tB_SYNC_ON_GREEN\n");
}
}
}
#endif
int32 HAIKU_ColorSpaceToBitsPerPixel(uint32 colorspace)
int32 BE_ColorSpaceToBitsPerPixel(uint32 colorspace)
{
int bitsperpixel;
int bitsperpixel;
bitsperpixel = 0;
switch (colorspace) {
case B_CMAP8:
bitsperpixel = 8;
break;
case B_RGB15:
case B_RGBA15:
case B_RGB15_BIG:
case B_RGBA15_BIG:
bitsperpixel = 15;
break;
case B_RGB16:
case B_RGB16_BIG:
bitsperpixel = 16;
break;
case B_RGB32:
case B_RGBA32:
case B_RGB32_BIG:
case B_RGBA32_BIG:
bitsperpixel = 32;
break;
default:
break;
}
return(bitsperpixel);
bitsperpixel = 0;
switch (colorspace) {
case B_CMAP8:
bitsperpixel = 8;
break;
case B_RGB15:
case B_RGBA15:
case B_RGB15_BIG:
case B_RGBA15_BIG:
bitsperpixel = 15;
break;
case B_RGB16:
case B_RGB16_BIG:
bitsperpixel = 16;
break;
case B_RGB32:
case B_RGBA32:
case B_RGB32_BIG:
case B_RGBA32_BIG:
bitsperpixel = 32;
break;
default:
break;
}
return(bitsperpixel);
}
int32 HAIKU_BPPToSDLPxFormat(int32 bpp) {
/* Translation taken from SDL_windowsmodes.c */
switch (bpp) {
case 32:
return SDL_PIXELFORMAT_RGB888;
break;
case 24: /* May not be supported by Haiku */
return SDL_PIXELFORMAT_RGB24;
break;
case 16:
return SDL_PIXELFORMAT_RGB565;
break;
case 15:
return SDL_PIXELFORMAT_RGB555;
break;
case 8:
return SDL_PIXELFORMAT_INDEX8;
break;
case 4: /* May not be supported by Haiku */
return SDL_PIXELFORMAT_INDEX4LSB;
break;
}
int32 BE_BPPToSDLPxFormat(int32 bpp) {
/* Translation taken from SDL_windowsmodes.c */
switch (bpp) {
case 32:
return SDL_PIXELFORMAT_RGB888;
break;
case 24: /* May not be supported by Haiku */
return SDL_PIXELFORMAT_RGB24;
break;
case 16:
return SDL_PIXELFORMAT_RGB565;
break;
case 15:
return SDL_PIXELFORMAT_RGB555;
break;
case 8:
return SDL_PIXELFORMAT_INDEX8;
break;
case 4: /* May not be supported by Haiku */
return SDL_PIXELFORMAT_INDEX4LSB;
break;
}
/* May never get here, but safer and needed to shut up compiler */
SDL_SetError("Invalid bpp value");
return 0;
/* May never get here, but safer and needed to shut up compiler */
SDL_SetError("Invalid bpp value");
return 0;
}
static void _BDisplayModeToSdlDisplayMode(display_mode *bmode,
SDL_DisplayMode *mode) {
mode->w = bmode->virtual_width;
mode->h = bmode->virtual_height;
mode->refresh_rate = (int)get_refresh_rate(*bmode);
SDL_DisplayMode *mode) {
mode->w = bmode->virtual_width;
mode->h = bmode->virtual_height;
mode->refresh_rate = (int)get_refresh_rate(*bmode);
#if WRAP_BMODE
SDL_DisplayModeData *data = (SDL_DisplayModeData*)SDL_calloc(1,
sizeof(SDL_DisplayModeData));
data->bmode = bmode;
mode->driverdata = data;
SDL_DisplayModeData *data = (SDL_DisplayModeData*)SDL_calloc(1,
sizeof(SDL_DisplayModeData));
data->bmode = bmode;
mode->driverdata = data;
#else
mode->driverdata = bmode;
mode->driverdata = bmode;
#endif
/* Set the format */
int32 bpp = HAIKU_ColorSpaceToBitsPerPixel(bmode->space);
mode->format = HAIKU_BPPToSDLPxFormat(bpp);
/* Set the format */
int32 bpp = BE_ColorSpaceToBitsPerPixel(bmode->space);
mode->format = BE_BPPToSDLPxFormat(bpp);
}
/* Later, there may be more than one monitor available */
static void _AddDisplay(BScreen *screen) {
SDL_VideoDisplay display;
SDL_DisplayMode *mode = (SDL_DisplayMode*)SDL_calloc(1,
sizeof(SDL_DisplayMode));
display_mode *bmode = (display_mode*)SDL_calloc(1, sizeof(display_mode));
screen->GetMode(bmode);
SDL_VideoDisplay display;
SDL_DisplayMode *mode = (SDL_DisplayMode*)SDL_calloc(1,
sizeof(SDL_DisplayMode));
display_mode *bmode = (display_mode*)SDL_calloc(1, sizeof(display_mode));
screen->GetMode(bmode);
_BDisplayModeToSdlDisplayMode(bmode, mode);
SDL_zero(display);
display.desktop_mode = *mode;
display.current_mode = *mode;
SDL_AddVideoDisplay(&display);
_BDisplayModeToSdlDisplayMode(bmode, mode);
SDL_zero(display);
display.desktop_mode = *mode;
display.current_mode = *mode;
SDL_AddVideoDisplay(&display);
}
/*
* Functions called by SDL
*/
int HAIKU_InitModes(_THIS) {
BScreen screen;
int BE_InitModes(_THIS) {
BScreen screen;
/* TODO: When Haiku supports multiple display screens, call
_AddDisplayScreen() for each of them. */
_AddDisplay(&screen);
return 0;
/* TODO: When Haiku supports multiple display screens, call
_AddDisplayScreen() for each of them. */
_AddDisplay(&screen);
return 0;
}
int HAIKU_QuitModes(_THIS) {
/* FIXME: Nothing really needs to be done here at the moment? */
return 0;
int BE_QuitModes(_THIS) {
/* FIXME: Nothing really needs to be done here at the moment? */
return 0;
}
int HAIKU_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) {
BScreen bscreen;
BRect rc = bscreen.Frame();
rect->x = (int)rc.left;
rect->y = (int)rc.top;
rect->w = (int)rc.Width() + 1;
rect->h = (int)rc.Height() + 1;
return 0;
int BE_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) {
BScreen bscreen;
BRect rc = bscreen.Frame();
rect->x = (int)rc.left;
rect->y = (int)rc.top;
rect->w = (int)rc.Width() + 1;
rect->h = (int)rc.Height() + 1;
return 0;
}
void HAIKU_GetDisplayModes(_THIS, SDL_VideoDisplay *display) {
/* Get the current screen */
BScreen bscreen;
void BE_GetDisplayModes(_THIS, SDL_VideoDisplay *display) {
/* Get the current screen */
BScreen bscreen;
/* Iterate through all of the modes */
SDL_DisplayMode mode;
display_mode this_bmode;
display_mode *bmodes;
uint32 count, i;
/* Get graphics-hardware supported modes */
bscreen.GetModeList(&bmodes, &count);
bscreen.GetMode(&this_bmode);
for(i = 0; i < count; ++i) {
// FIXME: Apparently there are errors with colorspace changes
if (bmodes[i].space == this_bmode.space) {
_BDisplayModeToSdlDisplayMode(&bmodes[i], &mode);
SDL_AddDisplayMode(display, &mode);
}
}
free(bmodes);
/* Iterate through all of the modes */
SDL_DisplayMode mode;
display_mode this_bmode;
display_mode *bmodes;
uint32 count, i;
/* Get graphics-hardware supported modes */
bscreen.GetModeList(&bmodes, &count);
bscreen.GetMode(&this_bmode);
for(i = 0; i < count; ++i) {
// FIXME: Apparently there are errors with colorspace changes
if (bmodes[i].space == this_bmode.space) {
_BDisplayModeToSdlDisplayMode(&bmodes[i], &mode);
SDL_AddDisplayMode(display, &mode);
}
}
free(bmodes);
}
int HAIKU_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode){
/* Get the current screen */
BScreen bscreen;
if(!bscreen.IsValid()) {
printf(__FILE__": %d - ERROR: BAD SCREEN\n", __LINE__);
}
int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode){
/* Get the current screen */
BScreen bscreen;
if(!bscreen.IsValid()) {
printf(__FILE__": %d - ERROR: BAD SCREEN\n", __LINE__);
}
/* Set the mode using the driver data */
display_mode *bmode = _ExtractBMode(mode);
/* Set the mode using the driver data */
display_mode *bmode = _ExtractBMode(mode);
/* FIXME: Is the first option always going to be the right one? */
uint32 c = 0, i;
display_mode *bmode_list;
bscreen.GetModeList(&bmode_list, &c);
for(i = 0; i < c; ++i) {
if( bmode_list[i].space == bmode->space &&
bmode_list[i].virtual_width == bmode->virtual_width &&
bmode_list[i].virtual_height == bmode->virtual_height ) {
bmode = &bmode_list[i];
break;
}
}
/* FIXME: Is the first option always going to be the right one? */
uint32 c = 0, i;
display_mode *bmode_list;
bscreen.GetModeList(&bmode_list, &c);
for(i = 0; i < c; ++i) {
if( bmode_list[i].space == bmode->space &&
bmode_list[i].virtual_width == bmode->virtual_width &&
bmode_list[i].virtual_height == bmode->virtual_height ) {
bmode = &bmode_list[i];
break;
}
}
if(bscreen.SetMode(bmode) != B_OK) {
return SDL_SetError("Bad video mode");
}
free(bmode_list);
if(bscreen.SetMode(bmode) != B_OK) {
return SDL_SetError("Bad video mode");
}
free(bmode_list);
#if SDL_VIDEO_OPENGL
/* FIXME: Is there some way to reboot the OpenGL context? This doesn't
help */
// HAIKU_GL_RebootContexts(_this);
/* FIXME: Is there some way to reboot the OpenGL context? This doesn't
help */
// BE_GL_RebootContexts(_this);
#endif
return 0;
return 0;
}
#ifdef __cplusplus

View file

@ -28,15 +28,15 @@ extern "C" {
#include "../SDL_sysvideo.h"
extern int32 HAIKU_ColorSpaceToBitsPerPixel(uint32 colorspace);
extern int32 HAIKU_BPPToSDLPxFormat(int32 bpp);
extern int32 BE_ColorSpaceToBitsPerPixel(uint32 colorspace);
extern int32 BE_BPPToSDLPxFormat(int32 bpp);
extern int HAIKU_InitModes(_THIS);
extern int HAIKU_QuitModes(_THIS);
extern int HAIKU_GetDisplayBounds(_THIS, SDL_VideoDisplay *display,
extern int BE_InitModes(_THIS);
extern int BE_QuitModes(_THIS);
extern int BE_GetDisplayBounds(_THIS, SDL_VideoDisplay *display,
SDL_Rect *rect);
extern void HAIKU_GetDisplayModes(_THIS, SDL_VideoDisplay *display);
extern int HAIKU_SetDisplayMode(_THIS, SDL_VideoDisplay *display,
extern void BE_GetDisplayModes(_THIS, SDL_VideoDisplay *display);
extern int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display,
SDL_DisplayMode *mode);
#ifdef __cplusplus

View file

@ -44,7 +44,7 @@ static SDL_INLINE SDL_BApp *_GetBeApp() {
}
/* Passing a NULL path means load pointers from the application */
int HAIKU_GL_LoadLibrary(_THIS, const char *path)
int BE_GL_LoadLibrary(_THIS, const char *path)
{
/* FIXME: Is this working correctly? */
image_info info;
@ -63,7 +63,7 @@ int HAIKU_GL_LoadLibrary(_THIS, const char *path)
return 0;
}
void *HAIKU_GL_GetProcAddress(_THIS, const char *proc)
void *BE_GL_GetProcAddress(_THIS, const char *proc)
{
if (_this->gl_config.dll_handle != NULL) {
void *location = NULL;
@ -86,19 +86,19 @@ void *HAIKU_GL_GetProcAddress(_THIS, const char *proc)
int HAIKU_GL_SwapWindow(_THIS, SDL_Window * window) {
int BE_GL_SwapWindow(_THIS, SDL_Window * window) {
_ToBeWin(window)->SwapBuffers();
return 0;
}
int HAIKU_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) {
int BE_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) {
SDL_BWin* win = (SDL_BWin*)context;
_GetBeApp()->SetCurrentContext(win ? win->GetGLView() : NULL);
return 0;
}
SDL_GLContext HAIKU_GL_CreateContext(_THIS, SDL_Window * window) {
SDL_GLContext BE_GL_CreateContext(_THIS, SDL_Window * window) {
/* FIXME: Not sure what flags should be included here; may want to have
most of them */
SDL_BWin *bwin = _ToBeWin(window);
@ -127,24 +127,24 @@ SDL_GLContext HAIKU_GL_CreateContext(_THIS, SDL_Window * window) {
return (SDL_GLContext)(bwin);
}
void HAIKU_GL_DeleteContext(_THIS, SDL_GLContext context) {
void BE_GL_DeleteContext(_THIS, SDL_GLContext context) {
/* Currently, automatically unlocks the view */
((SDL_BWin*)context)->RemoveGLView();
}
int HAIKU_GL_SetSwapInterval(_THIS, int interval) {
int BE_GL_SetSwapInterval(_THIS, int interval) {
/* TODO: Implement this, if necessary? */
return SDL_Unsupported();
}
int HAIKU_GL_GetSwapInterval(_THIS) {
int BE_GL_GetSwapInterval(_THIS) {
/* TODO: Implement this, if necessary? */
return 0;
}
void HAIKU_GL_UnloadLibrary(_THIS) {
void BE_GL_UnloadLibrary(_THIS) {
/* TODO: Implement this, if necessary? */
}
@ -152,7 +152,7 @@ void HAIKU_GL_UnloadLibrary(_THIS) {
/* FIXME: This function is meant to clear the OpenGL context when the video
mode changes (see SDL_bmodes.cc), but it doesn't seem to help, and is not
currently in use. */
void HAIKU_GL_RebootContexts(_THIS) {
void BE_GL_RebootContexts(_THIS) {
SDL_Window *window = _this->windows;
while(window) {
SDL_BWin *bwin = _ToBeWin(window);

View file

@ -31,18 +31,18 @@ extern "C" {
#include "../SDL_sysvideo.h"
extern int HAIKU_GL_LoadLibrary(_THIS, const char *path); /* FIXME */
extern void *HAIKU_GL_GetProcAddress(_THIS, const char *proc); /* FIXME */
extern void HAIKU_GL_UnloadLibrary(_THIS); /* TODO */
extern int HAIKU_GL_MakeCurrent(_THIS, SDL_Window * window,
extern int BE_GL_LoadLibrary(_THIS, const char *path); /* FIXME */
extern void *BE_GL_GetProcAddress(_THIS, const char *proc); /* FIXME */
extern void BE_GL_UnloadLibrary(_THIS); /* TODO */
extern int BE_GL_MakeCurrent(_THIS, SDL_Window * window,
SDL_GLContext context);
extern int HAIKU_GL_SetSwapInterval(_THIS, int interval); /* TODO */
extern int HAIKU_GL_GetSwapInterval(_THIS); /* TODO */
extern int HAIKU_GL_SwapWindow(_THIS, SDL_Window * window);
extern SDL_GLContext HAIKU_GL_CreateContext(_THIS, SDL_Window * window);
extern void HAIKU_GL_DeleteContext(_THIS, SDL_GLContext context);
extern int BE_GL_SetSwapInterval(_THIS, int interval); /* TODO */
extern int BE_GL_GetSwapInterval(_THIS); /* TODO */
extern int BE_GL_SwapWindow(_THIS, SDL_Window * window);
extern SDL_GLContext BE_GL_CreateContext(_THIS, SDL_Window * window);
extern void BE_GL_DeleteContext(_THIS, SDL_GLContext context);
extern void HAIKU_GL_RebootContexts(_THIS);
extern void BE_GL_RebootContexts(_THIS);
#ifdef __cplusplus
}

View file

@ -37,17 +37,17 @@ extern "C" {
#include "SDL_bevents.h"
/* FIXME: Undefined functions */
// #define HAIKU_PumpEvents NULL
#define HAIKU_StartTextInput NULL
#define HAIKU_StopTextInput NULL
#define HAIKU_SetTextInputRect NULL
// #define BE_PumpEvents NULL
#define BE_StartTextInput NULL
#define BE_StopTextInput NULL
#define BE_SetTextInputRect NULL
// #define HAIKU_DeleteDevice NULL
// #define BE_DeleteDevice NULL
/* End undefined functions */
static SDL_VideoDevice *
HAIKU_CreateDevice(int devindex)
BE_CreateDevice(int devindex)
{
SDL_VideoDevice *device;
/*SDL_VideoData *data;*/
@ -56,114 +56,115 @@ HAIKU_CreateDevice(int devindex)
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
device->driverdata = NULL; /* FIXME: Is this the cause of some of the
SDL_Quit() errors? */
SDL_Quit() errors? */
/* TODO: Figure out if any initialization needs to go here */
/* Set the function pointers */
device->VideoInit = HAIKU_VideoInit;
device->VideoQuit = HAIKU_VideoQuit;
device->GetDisplayBounds = HAIKU_GetDisplayBounds;
device->GetDisplayModes = HAIKU_GetDisplayModes;
device->SetDisplayMode = HAIKU_SetDisplayMode;
device->PumpEvents = HAIKU_PumpEvents;
device->VideoInit = BE_VideoInit;
device->VideoQuit = BE_VideoQuit;
device->GetDisplayBounds = BE_GetDisplayBounds;
device->GetDisplayModes = BE_GetDisplayModes;
device->SetDisplayMode = BE_SetDisplayMode;
device->PumpEvents = BE_PumpEvents;
device->CreateSDLWindow = HAIKU_CreateWindow;
device->CreateSDLWindowFrom = HAIKU_CreateWindowFrom;
device->SetWindowTitle = HAIKU_SetWindowTitle;
device->SetWindowIcon = HAIKU_SetWindowIcon;
device->SetWindowPosition = HAIKU_SetWindowPosition;
device->SetWindowSize = HAIKU_SetWindowSize;
device->ShowWindow = HAIKU_ShowWindow;
device->HideWindow = HAIKU_HideWindow;
device->RaiseWindow = HAIKU_RaiseWindow;
device->MaximizeWindow = HAIKU_MaximizeWindow;
device->MinimizeWindow = HAIKU_MinimizeWindow;
device->RestoreWindow = HAIKU_RestoreWindow;
device->SetWindowBordered = HAIKU_SetWindowBordered;
device->SetWindowResizable = HAIKU_SetWindowResizable;
device->SetWindowFullscreen = HAIKU_SetWindowFullscreen;
device->SetWindowGammaRamp = HAIKU_SetWindowGammaRamp;
device->GetWindowGammaRamp = HAIKU_GetWindowGammaRamp;
device->SetWindowGrab = HAIKU_SetWindowGrab;
device->DestroyWindow = HAIKU_DestroyWindow;
device->GetWindowWMInfo = HAIKU_GetWindowWMInfo;
device->CreateWindowFramebuffer = HAIKU_CreateWindowFramebuffer;
device->UpdateWindowFramebuffer = HAIKU_UpdateWindowFramebuffer;
device->DestroyWindowFramebuffer = HAIKU_DestroyWindowFramebuffer;
device->CreateSDLWindow = BE_CreateWindow;
device->CreateSDLWindowFrom = BE_CreateWindowFrom;
device->SetWindowTitle = BE_SetWindowTitle;
device->SetWindowIcon = BE_SetWindowIcon;
device->SetWindowPosition = BE_SetWindowPosition;
device->SetWindowSize = BE_SetWindowSize;
device->ShowWindow = BE_ShowWindow;
device->HideWindow = BE_HideWindow;
device->RaiseWindow = BE_RaiseWindow;
device->MaximizeWindow = BE_MaximizeWindow;
device->MinimizeWindow = BE_MinimizeWindow;
device->RestoreWindow = BE_RestoreWindow;
device->SetWindowBordered = BE_SetWindowBordered;
device->SetWindowResizable = BE_SetWindowResizable;
device->SetWindowFullscreen = BE_SetWindowFullscreen;
device->SetWindowGammaRamp = BE_SetWindowGammaRamp;
device->GetWindowGammaRamp = BE_GetWindowGammaRamp;
device->SetWindowGrab = BE_SetWindowGrab;
device->DestroyWindow = BE_DestroyWindow;
device->GetWindowWMInfo = BE_GetWindowWMInfo;
device->CreateWindowFramebuffer = BE_CreateWindowFramebuffer;
device->UpdateWindowFramebuffer = BE_UpdateWindowFramebuffer;
device->DestroyWindowFramebuffer = BE_DestroyWindowFramebuffer;
device->shape_driver.CreateShaper = NULL;
device->shape_driver.SetWindowShape = NULL;
device->shape_driver.ResizeWindowShape = NULL;
#if SDL_VIDEO_OPENGL
device->GL_LoadLibrary = HAIKU_GL_LoadLibrary;
device->GL_GetProcAddress = HAIKU_GL_GetProcAddress;
device->GL_UnloadLibrary = HAIKU_GL_UnloadLibrary;
device->GL_CreateContext = HAIKU_GL_CreateContext;
device->GL_MakeCurrent = HAIKU_GL_MakeCurrent;
device->GL_SetSwapInterval = HAIKU_GL_SetSwapInterval;
device->GL_GetSwapInterval = HAIKU_GL_GetSwapInterval;
device->GL_SwapWindow = HAIKU_GL_SwapWindow;
device->GL_DeleteContext = HAIKU_GL_DeleteContext;
device->GL_LoadLibrary = BE_GL_LoadLibrary;
device->GL_GetProcAddress = BE_GL_GetProcAddress;
device->GL_UnloadLibrary = BE_GL_UnloadLibrary;
device->GL_CreateContext = BE_GL_CreateContext;
device->GL_MakeCurrent = BE_GL_MakeCurrent;
device->GL_SetSwapInterval = BE_GL_SetSwapInterval;
device->GL_GetSwapInterval = BE_GL_GetSwapInterval;
device->GL_SwapWindow = BE_GL_SwapWindow;
device->GL_DeleteContext = BE_GL_DeleteContext;
#endif
device->StartTextInput = HAIKU_StartTextInput;
device->StopTextInput = HAIKU_StopTextInput;
device->SetTextInputRect = HAIKU_SetTextInputRect;
device->StartTextInput = BE_StartTextInput;
device->StopTextInput = BE_StopTextInput;
device->SetTextInputRect = BE_SetTextInputRect;
device->SetClipboardText = HAIKU_SetClipboardText;
device->GetClipboardText = HAIKU_GetClipboardText;
device->HasClipboardText = HAIKU_HasClipboardText;
device->SetClipboardText = BE_SetClipboardText;
device->GetClipboardText = BE_GetClipboardText;
device->HasClipboardText = BE_HasClipboardText;
device->free = HAIKU_DeleteDevice;
device->free = BE_DeleteDevice;
return device;
}
VideoBootStrap HAIKU_bootstrap = {
"haiku", "Haiku graphics",
HAIKU_Available, HAIKU_CreateDevice
"haiku", "Haiku graphics",
BE_Available, BE_CreateDevice
};
void HAIKU_DeleteDevice(SDL_VideoDevice * device)
void BE_DeleteDevice(SDL_VideoDevice * device)
{
SDL_free(device->driverdata);
SDL_free(device);
SDL_free(device->driverdata);
SDL_free(device);
}
int HAIKU_VideoInit(_THIS)
int BE_VideoInit(_THIS)
{
/* Initialize the Be Application for appserver interaction */
if (SDL_InitBeApp() < 0) {
return -1;
}
/* Initialize video modes */
HAIKU_InitModes(_this);
/* Init the keymap */
HAIKU_InitOSKeymap();
/* Initialize the Be Application for appserver interaction */
if (SDL_InitBeApp() < 0) {
return -1;
}
/* Initialize video modes */
BE_InitModes(_this);
/* Init the keymap */
BE_InitOSKeymap();
#if SDL_VIDEO_OPENGL
/* testgl application doesn't load library, just tries to load symbols */
/* is it correct? if so we have to load library here */
HAIKU_GL_LoadLibrary(_this, NULL);
BE_GL_LoadLibrary(_this, NULL);
#endif
/* We're done! */
/* We're done! */
return (0);
}
int HAIKU_Available(void)
int BE_Available(void)
{
return (1);
}
void HAIKU_VideoQuit(_THIS)
void BE_VideoQuit(_THIS)
{
HAIKU_QuitModes(_this);
BE_QuitModes(_this);
SDL_QuitBeApp();
}

View file

@ -30,10 +30,10 @@ extern "C" {
#include "../SDL_sysvideo.h"
extern void HAIKU_VideoQuit(_THIS);
extern int HAIKU_VideoInit(_THIS);
extern void HAIKU_DeleteDevice(_THIS);
extern int HAIKU_Available(void);
extern void BE_VideoQuit(_THIS);
extern int BE_VideoInit(_THIS);
extern void BE_DeleteDevice(_THIS);
extern int BE_Available(void);
#ifdef __cplusplus
}

View file

@ -32,36 +32,36 @@ extern "C" {
#endif
static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) {
return ((SDL_BWin*)(window->driverdata));
return ((SDL_BWin*)(window->driverdata));
}
static SDL_INLINE SDL_BApp *_GetBeApp() {
return ((SDL_BApp*)be_app);
return ((SDL_BApp*)be_app);
}
static int _InitWindow(_THIS, SDL_Window *window) {
uint32 flags = 0;
window_look look = B_TITLED_WINDOW_LOOK;
uint32 flags = 0;
window_look look = B_TITLED_WINDOW_LOOK;
BRect bounds(
BRect bounds(
window->x,
window->y,
window->x + window->w - 1, //BeWindows have an off-by-one px w/h thing
window->x + window->w - 1, //BeWindows have an off-by-one px w/h thing
window->y + window->h - 1
);
if(window->flags & SDL_WINDOW_FULLSCREEN) {
/* TODO: Add support for this flag */
printf(__FILE__": %d!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n",__LINE__);
/* TODO: Add support for this flag */
printf(__FILE__": %d!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n",__LINE__);
}
if(window->flags & SDL_WINDOW_OPENGL) {
/* TODO: Add support for this flag */
/* TODO: Add support for this flag */
}
if(!(window->flags & SDL_WINDOW_RESIZABLE)) {
flags |= B_NOT_RESIZABLE | B_NOT_ZOOMABLE;
flags |= B_NOT_RESIZABLE | B_NOT_ZOOMABLE;
}
if(window->flags & SDL_WINDOW_BORDERLESS) {
look = B_NO_BORDER_WINDOW_LOOK;
look = B_NO_BORDER_WINDOW_LOOK;
}
SDL_BWin *bwin = new(std::nothrow) SDL_BWin(bounds, look, flags);
@ -75,39 +75,39 @@ static int _InitWindow(_THIS, SDL_Window *window) {
return 0;
}
int HAIKU_CreateWindow(_THIS, SDL_Window *window) {
int BE_CreateWindow(_THIS, SDL_Window *window) {
if (_InitWindow(_this, window) < 0) {
return -1;
}
/* Start window loop */
/* Start window loop */
_ToBeWin(window)->Show();
return 0;
}
int HAIKU_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) {
int BE_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) {
SDL_BWin *otherBWin = (SDL_BWin*)data;
if(!otherBWin->LockLooper())
return -1;
/* Create the new window and initialize its members */
window->x = (int)otherBWin->Frame().left;
window->y = (int)otherBWin->Frame().top;
window->w = (int)otherBWin->Frame().Width();
window->h = (int)otherBWin->Frame().Height();
/* Set SDL flags */
if(!(otherBWin->Flags() & B_NOT_RESIZABLE)) {
window->flags |= SDL_WINDOW_RESIZABLE;
}
/* If we are out of memory, return the error code */
SDL_BWin *otherBWin = (SDL_BWin*)data;
if(!otherBWin->LockLooper())
return -1;
/* Create the new window and initialize its members */
window->x = (int)otherBWin->Frame().left;
window->y = (int)otherBWin->Frame().top;
window->w = (int)otherBWin->Frame().Width();
window->h = (int)otherBWin->Frame().Height();
/* Set SDL flags */
if(!(otherBWin->Flags() & B_NOT_RESIZABLE)) {
window->flags |= SDL_WINDOW_RESIZABLE;
}
/* If we are out of memory, return the error code */
if (_InitWindow(_this, window) < 0) {
return -1;
}
/* TODO: Add any other SDL-supported window attributes here */
/* TODO: Add any other SDL-supported window attributes here */
_ToBeWin(window)->SetTitle(otherBWin->Title());
/* Start window loop and unlock the other window */
@ -117,107 +117,107 @@ int HAIKU_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) {
return 0;
}
void HAIKU_SetWindowTitle(_THIS, SDL_Window * window) {
BMessage msg(BWIN_SET_TITLE);
msg.AddString("window-title", window->title);
_ToBeWin(window)->PostMessage(&msg);
void BE_SetWindowTitle(_THIS, SDL_Window * window) {
BMessage msg(BWIN_SET_TITLE);
msg.AddString("window-title", window->title);
_ToBeWin(window)->PostMessage(&msg);
}
void HAIKU_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) {
/* FIXME: Icons not supported by Haiku */
void BE_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) {
/* FIXME: Icons not supported by Haiku */
}
void HAIKU_SetWindowPosition(_THIS, SDL_Window * window) {
BMessage msg(BWIN_MOVE_WINDOW);
msg.AddInt32("window-x", window->x);
msg.AddInt32("window-y", window->y);
_ToBeWin(window)->PostMessage(&msg);
void BE_SetWindowPosition(_THIS, SDL_Window * window) {
BMessage msg(BWIN_MOVE_WINDOW);
msg.AddInt32("window-x", window->x);
msg.AddInt32("window-y", window->y);
_ToBeWin(window)->PostMessage(&msg);
}
void HAIKU_SetWindowSize(_THIS, SDL_Window * window) {
BMessage msg(BWIN_RESIZE_WINDOW);
msg.AddInt32("window-w", window->w - 1);
msg.AddInt32("window-h", window->h - 1);
_ToBeWin(window)->PostMessage(&msg);
void BE_SetWindowSize(_THIS, SDL_Window * window) {
BMessage msg(BWIN_RESIZE_WINDOW);
msg.AddInt32("window-w", window->w - 1);
msg.AddInt32("window-h", window->h - 1);
_ToBeWin(window)->PostMessage(&msg);
}
void HAIKU_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered) {
BMessage msg(BWIN_SET_BORDERED);
msg.AddBool("window-border", bordered != SDL_FALSE);
_ToBeWin(window)->PostMessage(&msg);
void BE_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered) {
BMessage msg(BWIN_SET_BORDERED);
msg.AddBool("window-border", bordered != SDL_FALSE);
_ToBeWin(window)->PostMessage(&msg);
}
void HAIKU_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable) {
BMessage msg(BWIN_SET_RESIZABLE);
msg.AddBool("window-resizable", resizable != SDL_FALSE);
_ToBeWin(window)->PostMessage(&msg);
void BE_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable) {
BMessage msg(BWIN_SET_RESIZABLE);
msg.AddBool("window-resizable", resizable != SDL_FALSE);
_ToBeWin(window)->PostMessage(&msg);
}
void HAIKU_ShowWindow(_THIS, SDL_Window * window) {
BMessage msg(BWIN_SHOW_WINDOW);
_ToBeWin(window)->PostMessage(&msg);
void BE_ShowWindow(_THIS, SDL_Window * window) {
BMessage msg(BWIN_SHOW_WINDOW);
_ToBeWin(window)->PostMessage(&msg);
}
void HAIKU_HideWindow(_THIS, SDL_Window * window) {
BMessage msg(BWIN_HIDE_WINDOW);
_ToBeWin(window)->PostMessage(&msg);
void BE_HideWindow(_THIS, SDL_Window * window) {
BMessage msg(BWIN_HIDE_WINDOW);
_ToBeWin(window)->PostMessage(&msg);
}
void HAIKU_RaiseWindow(_THIS, SDL_Window * window) {
BMessage msg(BWIN_SHOW_WINDOW); /* Activate this window and move to front */
_ToBeWin(window)->PostMessage(&msg);
void BE_RaiseWindow(_THIS, SDL_Window * window) {
BMessage msg(BWIN_SHOW_WINDOW); /* Activate this window and move to front */
_ToBeWin(window)->PostMessage(&msg);
}
void HAIKU_MaximizeWindow(_THIS, SDL_Window * window) {
BMessage msg(BWIN_MAXIMIZE_WINDOW);
_ToBeWin(window)->PostMessage(&msg);
void BE_MaximizeWindow(_THIS, SDL_Window * window) {
BMessage msg(BWIN_MAXIMIZE_WINDOW);
_ToBeWin(window)->PostMessage(&msg);
}
void HAIKU_MinimizeWindow(_THIS, SDL_Window * window) {
BMessage msg(BWIN_MINIMIZE_WINDOW);
_ToBeWin(window)->PostMessage(&msg);
void BE_MinimizeWindow(_THIS, SDL_Window * window) {
BMessage msg(BWIN_MINIMIZE_WINDOW);
_ToBeWin(window)->PostMessage(&msg);
}
void HAIKU_RestoreWindow(_THIS, SDL_Window * window) {
BMessage msg(BWIN_RESTORE_WINDOW);
_ToBeWin(window)->PostMessage(&msg);
void BE_RestoreWindow(_THIS, SDL_Window * window) {
BMessage msg(BWIN_RESTORE_WINDOW);
_ToBeWin(window)->PostMessage(&msg);
}
void HAIKU_SetWindowFullscreen(_THIS, SDL_Window * window,
SDL_VideoDisplay * display, SDL_bool fullscreen) {
/* Haiku tracks all video display information */
BMessage msg(BWIN_FULLSCREEN);
msg.AddBool("fullscreen", fullscreen);
_ToBeWin(window)->PostMessage(&msg);
void BE_SetWindowFullscreen(_THIS, SDL_Window * window,
SDL_VideoDisplay * display, SDL_bool fullscreen) {
/* Haiku tracks all video display information */
BMessage msg(BWIN_FULLSCREEN);
msg.AddBool("fullscreen", fullscreen);
_ToBeWin(window)->PostMessage(&msg);
}
int HAIKU_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) {
/* FIXME: Not Haiku supported */
return -1;
int BE_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) {
/* FIXME: Not Haiku supported */
return -1;
}
int HAIKU_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp) {
/* FIXME: Not Haiku supported */
return -1;
int BE_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp) {
/* FIXME: Not Haiku supported */
return -1;
}
void HAIKU_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) {
/* TODO: Implement this! */
void BE_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) {
/* TODO: Implement this! */
}
void HAIKU_DestroyWindow(_THIS, SDL_Window * window) {
_ToBeWin(window)->LockLooper(); /* This MUST be locked */
_GetBeApp()->ClearID(_ToBeWin(window));
_ToBeWin(window)->Quit();
window->driverdata = NULL;
void BE_DestroyWindow(_THIS, SDL_Window * window) {
_ToBeWin(window)->LockLooper(); /* This MUST be locked */
_GetBeApp()->ClearID(_ToBeWin(window));
_ToBeWin(window)->Quit();
window->driverdata = NULL;
}
SDL_bool HAIKU_GetWindowWMInfo(_THIS, SDL_Window * window,
SDL_bool BE_GetWindowWMInfo(_THIS, SDL_Window * window,
struct SDL_SysWMinfo *info) {
/* FIXME: What is the point of this? What information should be included? */
return SDL_FALSE;
/* FIXME: What is the point of this? What information should be included? */
return SDL_FALSE;
}

View file

@ -26,26 +26,26 @@
#include "../SDL_sysvideo.h"
extern int HAIKU_CreateWindow(_THIS, SDL_Window *window);
extern int HAIKU_CreateWindowFrom(_THIS, SDL_Window * window, const void *data);
extern void HAIKU_SetWindowTitle(_THIS, SDL_Window * window);
extern void HAIKU_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
extern void HAIKU_SetWindowPosition(_THIS, SDL_Window * window);
extern void HAIKU_SetWindowSize(_THIS, SDL_Window * window);
extern void HAIKU_ShowWindow(_THIS, SDL_Window * window);
extern void HAIKU_HideWindow(_THIS, SDL_Window * window);
extern void HAIKU_RaiseWindow(_THIS, SDL_Window * window);
extern void HAIKU_MaximizeWindow(_THIS, SDL_Window * window);
extern void HAIKU_MinimizeWindow(_THIS, SDL_Window * window);
extern void HAIKU_RestoreWindow(_THIS, SDL_Window * window);
extern void HAIKU_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered);
extern void HAIKU_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable);
extern void HAIKU_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
extern int HAIKU_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
extern int HAIKU_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
extern void HAIKU_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
extern void HAIKU_DestroyWindow(_THIS, SDL_Window * window);
extern SDL_bool HAIKU_GetWindowWMInfo(_THIS, SDL_Window * window,
extern int BE_CreateWindow(_THIS, SDL_Window *window);
extern int BE_CreateWindowFrom(_THIS, SDL_Window * window, const void *data);
extern void BE_SetWindowTitle(_THIS, SDL_Window * window);
extern void BE_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
extern void BE_SetWindowPosition(_THIS, SDL_Window * window);
extern void BE_SetWindowSize(_THIS, SDL_Window * window);
extern void BE_ShowWindow(_THIS, SDL_Window * window);
extern void BE_HideWindow(_THIS, SDL_Window * window);
extern void BE_RaiseWindow(_THIS, SDL_Window * window);
extern void BE_MaximizeWindow(_THIS, SDL_Window * window);
extern void BE_MinimizeWindow(_THIS, SDL_Window * window);
extern void BE_RestoreWindow(_THIS, SDL_Window * window);
extern void BE_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered);
extern void BE_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable);
extern void BE_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
extern int BE_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
extern int BE_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
extern void BE_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
extern void BE_DestroyWindow(_THIS, SDL_Window * window);
extern SDL_bool BE_GetWindowWMInfo(_THIS, SDL_Window * window,
struct SDL_SysWMinfo *info);

View file

@ -487,12 +487,12 @@ KMSDRM_MoveCursor(SDL_Cursor * cursor)
That's why we move the cursor graphic ONLY. */
if (mouse != NULL && mouse->cur_cursor != NULL && mouse->cur_cursor->driverdata != NULL) {
curdata = (KMSDRM_CursorData *) mouse->cur_cursor->driverdata;
drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(curdata->bo));
ret = KMSDRM_drmModeMoveCursor(drm_fd, curdata->crtc_id, mouse->x, mouse->y);
drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(curdata->bo));
ret = KMSDRM_drmModeMoveCursor(drm_fd, curdata->crtc_id, mouse->x, mouse->y);
if (ret) {
SDL_SetError("drmModeMoveCursor() failed.");
}
if (ret) {
SDL_SetError("drmModeMoveCursor() failed.");
}
}
}

View file

@ -50,23 +50,23 @@ KMSDRM_GLES_SetupCrtc(_THIS, SDL_Window * window) {
KMSDRM_FBInfo *fb_info;
if (!(_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, wdata->egl_surface))) {
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "eglSwapBuffers failed on CRTC setup");
return SDL_FALSE;
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "eglSwapBuffers failed on CRTC setup");
return SDL_FALSE;
}
wdata->crtc_bo = KMSDRM_gbm_surface_lock_front_buffer(wdata->gs);
if (wdata->crtc_bo == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not lock GBM surface front buffer on CRTC setup");
return SDL_FALSE;
wdata->next_bo = KMSDRM_gbm_surface_lock_front_buffer(wdata->gs);
if (wdata->next_bo == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not lock GBM surface front buffer on CRTC setup");
return SDL_FALSE;
}
fb_info = KMSDRM_FBFromBO(_this, wdata->crtc_bo);
fb_info = KMSDRM_FBFromBO(_this, wdata->next_bo);
if (fb_info == NULL) {
return SDL_FALSE;
return SDL_FALSE;
}
if(KMSDRM_drmModeSetCrtc(vdata->drm_fd, displaydata->crtc_id, fb_info->fb_id,
0, 0, &vdata->saved_conn_id, 1, &displaydata->cur_mode) != 0) {
0, 0, &vdata->saved_conn_id, 1, &displaydata->cur_mode) != 0) {
SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "Could not set up CRTC to a GBM buffer");
return SDL_FALSE;
@ -153,14 +153,14 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) {
} else {
/* Queue page flip at vsync */
/* Have we already setup the CRTC to one of the GBM buffers? Do so if we have not,
/* Have we already setup the CRTC to one of the GBM buffers? Do so if we have not,
or FlipPage won't work in some cases. */
if (!wdata->crtc_ready) {
if (!wdata->crtc_ready) {
if(!KMSDRM_GLES_SetupCrtc(_this, window)) {
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not set up CRTC for doing vsync-ed pageflips");
return 0;
}
}
}
/* SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "drmModePageFlip(%d, %u, %u, DRM_MODE_PAGE_FLIP_EVENT, &wdata->waiting_for_flip)",
vdata->drm_fd, displaydata->crtc_id, fb_info->fb_id); */

View file

@ -41,27 +41,20 @@
#include "SDL_kmsdrmopengles.h"
#include "SDL_kmsdrmmouse.h"
#include "SDL_kmsdrmdyn.h"
#include <sys/stat.h>
#include <dirent.h>
#include <errno.h>
#define KMSDRM_DRI_PATH "/dev/dri/"
#define KMSDRM_DRI_CARD_0 "/dev/dri/card0"
static int
check_modestting(int devindex)
KMSDRM_Available(void)
{
SDL_bool available = SDL_FALSE;
char device[512];
int drm_fd;
int available = 0;
SDL_snprintf(device, sizeof (device), "%scard%d", KMSDRM_DRI_PATH, devindex);
drm_fd = open(device, O_RDWR | O_CLOEXEC);
int drm_fd = open(KMSDRM_DRI_CARD_0, O_RDWR | O_CLOEXEC);
if (drm_fd >= 0) {
if (SDL_KMSDRM_LoadSymbols()) {
drmModeRes *resources = KMSDRM_drmModeGetResources(drm_fd);
if (resources != NULL) {
available = SDL_TRUE;
available = 1;
KMSDRM_drmModeFreeResources(resources);
}
SDL_KMSDRM_UnloadSymbols();
@ -72,66 +65,6 @@ check_modestting(int devindex)
return available;
}
static int get_dricount(void)
{
int devcount = 0;
struct dirent *res;
struct stat sb;
DIR *folder;
if (!(stat(KMSDRM_DRI_PATH, &sb) == 0
&& S_ISDIR(sb.st_mode))) {
printf("The path %s cannot be opened or is not available\n",
KMSDRM_DRI_PATH);
return 0;
}
if (access(KMSDRM_DRI_PATH, F_OK) == -1) {
printf("The path %s cannot be opened\n",
KMSDRM_DRI_PATH);
return 0;
}
folder = opendir(KMSDRM_DRI_PATH);
if (folder) {
while ((res = readdir(folder))) {
if (res->d_type == DT_CHR) {
devcount++;
}
}
closedir(folder);
}
return devcount;
}
static int
get_driindex(void)
{
const int devcount = get_dricount();
int i;
for (i = 0; i < devcount; i++) {
if (check_modestting(i)) {
return i;
}
}
return -ENOENT;
}
static int
KMSDRM_Available(void)
{
int ret = -ENOENT;
ret = get_driindex();
if (ret >= 0)
return 1;
return ret;
}
static void
KMSDRM_Destroy(SDL_VideoDevice * device)
{
@ -150,11 +83,7 @@ KMSDRM_Create(int devindex)
SDL_VideoDevice *device;
SDL_VideoData *vdata;
if (!devindex || (devindex > 99)) {
devindex = get_driindex();
}
if (devindex < 0) {
if (devindex < 0 || devindex > 99) {
SDL_SetError("devindex (%d) must be between 0 and 99.\n", devindex);
return NULL;
}
@ -637,10 +566,6 @@ KMSDRM_DestroyWindow(_THIS, SDL_Window * window)
if(data) {
/* Wait for any pending page flips and unlock buffer */
KMSDRM_WaitPageFlip(_this, data, -1);
if (data->crtc_bo != NULL) {
KMSDRM_gbm_surface_release_buffer(data->gs, data->crtc_bo);
data->crtc_bo = NULL;
}
if (data->next_bo != NULL) {
KMSDRM_gbm_surface_release_buffer(data->gs, data->next_bo);
data->next_bo = NULL;

View file

@ -62,7 +62,6 @@ typedef struct SDL_WindowData
struct gbm_surface *gs;
struct gbm_bo *current_bo;
struct gbm_bo *next_bo;
struct gbm_bo *crtc_bo;
SDL_bool waiting_for_flip;
SDL_bool crtc_ready;
SDL_bool double_buffer;

View file

@ -343,17 +343,17 @@ RPI_DestroyWindow(_THIS, SDL_Window * window)
SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
if(data) {
if (data->double_buffer) {
/* Wait for vsync, and then stop vsync callbacks and destroy related stuff, if needed */
SDL_LockMutex(data->vsync_cond_mutex);
SDL_CondWait(data->vsync_cond, data->vsync_cond_mutex);
SDL_UnlockMutex(data->vsync_cond_mutex);
if (data->double_buffer) {
/* Wait for vsync, and then stop vsync callbacks and destroy related stuff, if needed */
SDL_LockMutex(data->vsync_cond_mutex);
SDL_CondWait(data->vsync_cond, data->vsync_cond_mutex);
SDL_UnlockMutex(data->vsync_cond_mutex);
vc_dispmanx_vsync_callback(displaydata->dispman_display, NULL, NULL);
vc_dispmanx_vsync_callback(displaydata->dispman_display, NULL, NULL);
SDL_DestroyCond(data->vsync_cond);
SDL_DestroyMutex(data->vsync_cond_mutex);
}
SDL_DestroyCond(data->vsync_cond);
SDL_DestroyMutex(data->vsync_cond_mutex);
}
#if SDL_VIDEO_OPENGL_EGL
if (data->egl_surface != EGL_NO_SURFACE) {

View file

@ -445,7 +445,30 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
#if !TARGET_OS_TV
- (void)application:(UIApplication *)application didChangeStatusBarOrientation:(UIInterfaceOrientation)oldStatusBarOrientation
{
SDL_OnApplicationDidChangeStatusBarOrientation();
BOOL isLandscape = UIInterfaceOrientationIsLandscape(application.statusBarOrientation);
SDL_VideoDevice *_this = SDL_GetVideoDevice();
if (_this && _this->num_displays > 0) {
SDL_DisplayMode *desktopmode = &_this->displays[0].desktop_mode;
SDL_DisplayMode *currentmode = &_this->displays[0].current_mode;
/* The desktop display mode should be kept in sync with the screen
* orientation so that updating a window's fullscreen state to
* SDL_WINDOW_FULLSCREEN_DESKTOP keeps the window dimensions in the
* correct orientation. */
if (isLandscape != (desktopmode->w > desktopmode->h)) {
int height = desktopmode->w;
desktopmode->w = desktopmode->h;
desktopmode->h = height;
}
/* Same deal with the current mode + SDL_GetCurrentDisplayMode. */
if (isLandscape != (currentmode->w > currentmode->h)) {
int height = currentmode->w;
currentmode->w = currentmode->h;
currentmode->h = height;
}
}
}
#endif

View file

@ -109,7 +109,6 @@ UIKit_ShowMessageBoxAlertController(const SDL_MessageBoxData *messageboxdata, in
alertwindow.hidden = YES;
}
#if !TARGET_OS_TV
/* Force the main SDL window to re-evaluate home indicator state */
SDL_Window *focus = SDL_GetFocusWindow();
if (focus) {
@ -121,7 +120,6 @@ UIKit_ShowMessageBoxAlertController(const SDL_MessageBoxData *messageboxdata, in
}
}
}
#endif /* !TARGET_OS_TV */
*buttonid = messageboxdata->buttons[clickedindex].buttonid;
return YES;

View file

@ -49,8 +49,9 @@
{
if ((self = [super initWithFrame:frame])) {
self.tag = METALVIEW_TAG;
/* Set the desired scale. The default drawableSize of a CAMetalLayer
* is its bounds x its scale so nothing further needs to be done. */
self.layer.contentsScale = scale;
[self updateDrawableSize];
}
return self;
@ -60,15 +61,6 @@
- (void)layoutSubviews
{
[super layoutSubviews];
[self updateDrawableSize];
}
- (void)updateDrawableSize
{
CGSize size = self.bounds.size;
size.width *= self.layer.contentsScale;
size.height *= self.layer.contentsScale;
((CAMetalLayer *)self.layer).drawableSize = size;
}
@end
@ -80,9 +72,9 @@ UIKit_Mtl_AddMetalView(SDL_Window* window)
SDL_uikitview *view = (SDL_uikitview*)data.uiwindow.rootViewController.view;
CGFloat scale = 1.0;
if ([view isKindOfClass:[SDL_uikitmetalview class]]) {
return (SDL_uikitmetalview *)view;
}
if ([view isKindOfClass:[SDL_uikitmetalview class]]) {
return (SDL_uikitmetalview *)view;
}
if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
/* Set the scale to the natural scale factor of the screen - then

View file

@ -45,10 +45,6 @@ extern int UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMo
extern void UIKit_QuitModes(_THIS);
extern int UIKit_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
#if !TARGET_OS_TV
extern void SDL_OnApplicationDidChangeStatusBarOrientation(void);
#endif
#endif /* SDL_uikitmodes_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -25,8 +25,6 @@
#include "SDL_assert.h"
#include "SDL_uikitmodes.h"
#include "../../events/SDL_events_c.h"
@implementation SDL_DisplayData
@synthesize uiscreen;
@ -190,9 +188,6 @@ UIKit_InitModes(_THIS)
return -1;
}
}
#if !TARGET_OS_TV
SDL_OnApplicationDidChangeStatusBarOrientation();
#endif
}
return 0;
@ -324,57 +319,6 @@ UIKit_QuitModes(_THIS)
}
}
#if !TARGET_OS_TV
void SDL_OnApplicationDidChangeStatusBarOrientation()
{
BOOL isLandscape = UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
SDL_VideoDisplay *display = SDL_GetDisplay(0);
if (display) {
SDL_DisplayMode *desktopmode = &display->desktop_mode;
SDL_DisplayMode *currentmode = &display->current_mode;
SDL_DisplayOrientation orientation = SDL_ORIENTATION_UNKNOWN;
/* The desktop display mode should be kept in sync with the screen
* orientation so that updating a window's fullscreen state to
* SDL_WINDOW_FULLSCREEN_DESKTOP keeps the window dimensions in the
* correct orientation. */
if (isLandscape != (desktopmode->w > desktopmode->h)) {
int height = desktopmode->w;
desktopmode->w = desktopmode->h;
desktopmode->h = height;
}
/* Same deal with the current mode + SDL_GetCurrentDisplayMode. */
if (isLandscape != (currentmode->w > currentmode->h)) {
int height = currentmode->w;
currentmode->w = currentmode->h;
currentmode->h = height;
}
switch ([UIApplication sharedApplication].statusBarOrientation) {
case UIInterfaceOrientationPortrait:
orientation = SDL_ORIENTATION_PORTRAIT;
break;
case UIInterfaceOrientationPortraitUpsideDown:
orientation = SDL_ORIENTATION_PORTRAIT_FLIPPED;
break;
case UIInterfaceOrientationLandscapeLeft:
/* Bug: UIInterfaceOrientationLandscapeLeft/Right are reversed - http://openradar.appspot.com/7216046 */
orientation = SDL_ORIENTATION_LANDSCAPE_FLIPPED;
break;
case UIInterfaceOrientationLandscapeRight:
/* Bug: UIInterfaceOrientationLandscapeLeft/Right are reversed - http://openradar.appspot.com/7216046 */
orientation = SDL_ORIENTATION_LANDSCAPE;
break;
default:
break;
}
SDL_SendDisplayEvent(display, SDL_DISPLAYEVENT_ORIENTATION, orientation);
}
}
#endif /* !TARGET_OS_TV */
#endif /* SDL_VIDEO_DRIVER_UIKIT */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -101,7 +101,7 @@
SDL_SetError("sRGB drawables are not supported.");
return nil;
}
} else if (rBits >= 8 || gBits >= 8 || bBits >= 8 || aBits > 0) {
} else if (rBits >= 8 || gBits >= 8 || bBits >= 8) {
/* if user specifically requests rbg888 or some color format higher than 16bpp */
colorFormat = kEAGLColorFormatRGBA8;
colorBufferFormat = GL_RGBA8;

View file

@ -233,17 +233,6 @@ void SDL_NSLog(const char *text)
NSLog(@"%s", text);
}
/*
* iOS Tablet detection
*
* This doesn't really have aything to do with the interfaces of the SDL video
* subsystem, but we need to stuff this into an Objective-C source code file.
*/
SDL_bool SDL_IsIPad(void)
{
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
}
#endif /* SDL_VIDEO_DRIVER_UIKIT */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -252,34 +252,34 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
- (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event
{
if (!SDL_AppleTVRemoteOpenedAsJoystick) {
for (UIPress *press in presses) {
SDL_Scancode scancode = [self scancodeFromPressType:press.type];
SDL_SendKeyboardKey(SDL_PRESSED, scancode);
}
}
if (!SDL_AppleTVRemoteOpenedAsJoystick) {
for (UIPress *press in presses) {
SDL_Scancode scancode = [self scancodeFromPressType:press.type];
SDL_SendKeyboardKey(SDL_PRESSED, scancode);
}
}
[super pressesBegan:presses withEvent:event];
}
- (void)pressesEnded:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event
{
if (!SDL_AppleTVRemoteOpenedAsJoystick) {
for (UIPress *press in presses) {
SDL_Scancode scancode = [self scancodeFromPressType:press.type];
SDL_SendKeyboardKey(SDL_RELEASED, scancode);
}
}
if (!SDL_AppleTVRemoteOpenedAsJoystick) {
for (UIPress *press in presses) {
SDL_Scancode scancode = [self scancodeFromPressType:press.type];
SDL_SendKeyboardKey(SDL_RELEASED, scancode);
}
}
[super pressesEnded:presses withEvent:event];
}
- (void)pressesCancelled:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event
{
if (!SDL_AppleTVRemoteOpenedAsJoystick) {
for (UIPress *press in presses) {
SDL_Scancode scancode = [self scancodeFromPressType:press.type];
SDL_SendKeyboardKey(SDL_RELEASED, scancode);
}
}
if (!SDL_AppleTVRemoteOpenedAsJoystick) {
for (UIPress *press in presses) {
SDL_Scancode scancode = [self scancodeFromPressType:press.type];
SDL_SendKeyboardKey(SDL_RELEASED, scancode);
}
}
[super pressesCancelled:presses withEvent:event];
}

View file

@ -74,8 +74,6 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o
#if SDL_IPHONE_KEYBOARD
UITextField *textField;
BOOL rotatingOrientation;
NSString *changeText;
NSString *obligateForBackspace;
#endif
}
@ -252,12 +250,10 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o
/* Set ourselves up as a UITextFieldDelegate */
- (void)initKeyboard
{
changeText = nil;
obligateForBackspace = @" "; /* 64 space */
textField = [[UITextField alloc] initWithFrame:CGRectZero];
textField.delegate = self;
/* placeholder so there is something to delete! */
textField.text = obligateForBackspace;
textField.text = @" ";
/* set UITextInputTrait properties, mostly to defaults */
textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
@ -271,12 +267,11 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o
textField.hidden = YES;
keyboardVisible = NO;
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
#if !TARGET_OS_TV
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[center addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
#endif
[center addObserver:self selector:@selector(textFieldTextDidChange:) name:UITextFieldTextDidChangeNotification object:nil];
}
- (void)setView:(UIView *)view
@ -315,12 +310,11 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o
- (void)deinitKeyboard
{
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
#if !TARGET_OS_TV
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center removeObserver:self name:UIKeyboardWillShowNotification object:nil];
[center removeObserver:self name:UIKeyboardWillHideNotification object:nil];
#endif
[center removeObserver:self name:UITextFieldTextDidChangeNotification object:nil];
}
/* reveal onscreen virtual keyboard */
@ -360,50 +354,6 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o
[self setKeyboardHeight:0];
}
- (void)textFieldTextDidChange:(NSNotification *)notification
{
if (changeText!=nil && textField.markedTextRange == nil)
{
NSUInteger len = changeText.length;
if (len > 0) {
/* Go through all the characters in the string we've been sent and
* convert them to key presses */
int i;
for (i = 0; i < len; i++) {
unichar c = [changeText characterAtIndex:i];
SDL_Scancode code;
Uint16 mod;
if (c < 127) {
/* Figure out the SDL_Scancode and SDL_keymod for this unichar */
code = unicharToUIKeyInfoTable[c].code;
mod = unicharToUIKeyInfoTable[c].mod;
} else {
/* We only deal with ASCII right now */
code = SDL_SCANCODE_UNKNOWN;
mod = 0;
}
if (mod & KMOD_SHIFT) {
/* If character uses shift, press shift down */
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
}
/* send a keydown and keyup even for the character */
SDL_SendKeyboardKey(SDL_PRESSED, code);
SDL_SendKeyboardKey(SDL_RELEASED, code);
if (mod & KMOD_SHIFT) {
/* If character uses shift, press shift back up */
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
}
}
SDL_SendKeyboardText([changeText UTF8String]);
}
changeText = nil;
}
}
- (void)updateKeyboard
{
CGAffineTransform t = self.view.transform;
@ -442,20 +392,49 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o
- (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSUInteger len = string.length;
if (len == 0) {
changeText = nil;
if (textField.markedTextRange == nil) {
/* it wants to replace text with nothing, ie a delete */
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_BACKSPACE);
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_BACKSPACE);
}
if (textField.text.length < 16) {
textField.text = obligateForBackspace;
}
/* it wants to replace text with nothing, ie a delete */
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_BACKSPACE);
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_BACKSPACE);
} else {
changeText = string;
/* go through all the characters in the string we've been sent and
* convert them to key presses */
int i;
for (i = 0; i < len; i++) {
unichar c = [string characterAtIndex:i];
Uint16 mod = 0;
SDL_Scancode code;
if (c < 127) {
/* figure out the SDL_Scancode and SDL_keymod for this unichar */
code = unicharToUIKeyInfoTable[c].code;
mod = unicharToUIKeyInfoTable[c].mod;
} else {
/* we only deal with ASCII right now */
code = SDL_SCANCODE_UNKNOWN;
mod = 0;
}
if (mod & KMOD_SHIFT) {
/* If character uses shift, press shift down */
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
}
/* send a keydown and keyup even for the character */
SDL_SendKeyboardKey(SDL_PRESSED, code);
SDL_SendKeyboardKey(SDL_RELEASED, code);
if (mod & KMOD_SHIFT) {
/* If character uses shift, press shift back up */
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
}
}
SDL_SendKeyboardText([string UTF8String]);
}
return YES;
return NO; /* don't allow the edit! (keep placeholder text there) */
}
/* Terminates the editing session */
@ -519,7 +498,7 @@ UIKit_IsScreenKeyboardShown(_THIS, SDL_Window *window)
@autoreleasepool {
SDL_uikitviewcontroller *vc = GetWindowViewController(window);
if (vc != nil) {
return vc.keyboardVisible;
return vc.isKeyboardVisible;
}
return SDL_FALSE;
}

View file

@ -40,7 +40,6 @@
#include "pointer-constraints-unstable-v1-client-protocol.h"
#include "relative-pointer-unstable-v1-client-protocol.h"
#include "xdg-shell-client-protocol.h"
#include "xdg-shell-unstable-v6-client-protocol.h"
#include <linux/input.h>
@ -178,8 +177,6 @@ Wayland_PumpEvents(_THIS)
{
SDL_VideoData *d = _this->driverdata;
WAYLAND_wl_display_flush(d->display);
if (SDL_IOReady(WAYLAND_wl_display_get_fd(d->display), SDL_FALSE, 0)) {
WAYLAND_wl_display_dispatch(d->display);
}
@ -266,9 +263,7 @@ ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial)
switch (rc) {
case SDL_HITTEST_DRAGGABLE:
if (input->display->shell.xdg) {
xdg_toplevel_move(window_data->shell_surface.xdg.roleobj.toplevel, input->seat, serial);
} else if (input->display->shell.zxdg) {
if (input->display->shell.zxdg) {
zxdg_toplevel_v6_move(window_data->shell_surface.zxdg.roleobj.toplevel, input->seat, serial);
} else {
wl_shell_surface_move(window_data->shell_surface.wl, input->seat, serial);
@ -283,9 +278,7 @@ ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial)
case SDL_HITTEST_RESIZE_BOTTOM:
case SDL_HITTEST_RESIZE_BOTTOMLEFT:
case SDL_HITTEST_RESIZE_LEFT:
if (input->display->shell.xdg) {
xdg_toplevel_resize(window_data->shell_surface.xdg.roleobj.toplevel, input->seat, serial, directions_zxdg[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
} else if (input->display->shell.zxdg) {
if (input->display->shell.zxdg) {
zxdg_toplevel_v6_resize(window_data->shell_surface.zxdg.roleobj.toplevel, input->seat, serial, directions_zxdg[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
} else {
wl_shell_surface_resize(window_data->shell_surface.wl, input->seat, serial, directions_wl[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
@ -749,7 +742,7 @@ static const struct wl_data_offer_listener data_offer_listener = {
static void
data_device_handle_data_offer(void *data, struct wl_data_device *wl_data_device,
struct wl_data_offer *id)
struct wl_data_offer *id)
{
SDL_WaylandDataOffer *data_offer = NULL;
@ -767,7 +760,7 @@ data_device_handle_data_offer(void *data, struct wl_data_device *wl_data_device,
static void
data_device_handle_enter(void *data, struct wl_data_device *wl_data_device,
uint32_t serial, struct wl_surface *surface,
uint32_t serial, struct wl_surface *surface,
wl_fixed_t x, wl_fixed_t y, struct wl_data_offer *id)
{
SDL_WaylandDataDevice *data_device = data;
@ -810,7 +803,7 @@ data_device_handle_leave(void *data, struct wl_data_device *wl_data_device)
static void
data_device_handle_motion(void *data, struct wl_data_device *wl_data_device,
uint32_t time, wl_fixed_t x, wl_fixed_t y)
uint32_t time, wl_fixed_t x, wl_fixed_t y)
{
}
@ -849,7 +842,7 @@ data_device_handle_drop(void *data, struct wl_data_device *wl_data_device)
static void
data_device_handle_selection(void *data, struct wl_data_device *wl_data_device,
struct wl_data_offer *id)
struct wl_data_offer *id)
{
SDL_WaylandDataDevice *data_device = data;
SDL_WaylandDataOffer *offer = NULL;

View file

@ -89,9 +89,9 @@ touch_handle_touch(void *data,
*/
SDL_TouchID deviceId = 1;
if (SDL_AddTouch(deviceId, "qt_touch_extension") < 0) {
SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__);
}
if (SDL_AddTouch(deviceId, "qt_touch_extension") < 0) {
SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__);
}
switch (touchState) {
case QtWaylandTouchPointPressed:

View file

@ -19,13 +19,13 @@
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_waylandtouch_h_
#define SDL_waylandtouch_h_
#include "../../SDL_internal.h"
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
#ifndef SDL_waylandtouch_h_
#define SDL_waylandtouch_h_
#include "SDL_waylandvideo.h"
#include <stdint.h>
#include <stddef.h>
@ -347,6 +347,6 @@ qt_windowmanager_open_url(struct qt_windowmanager *qt_windowmanager, uint32_t re
QT_WINDOWMANAGER_OPEN_URL, remaining, url);
}
#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
#endif /* SDL_waylandtouch_h_ */
#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */

View file

@ -45,7 +45,6 @@
#include "SDL_waylanddyn.h"
#include <wayland-util.h>
#include "xdg-shell-client-protocol.h"
#include "xdg-shell-unstable-v6-client-protocol.h"
#define WAYLANDVID_DRIVER_NAME "wayland"
@ -68,10 +67,10 @@ static char *
get_classname()
{
/* !!! FIXME: this is probably wrong, albeit harmless in many common cases. From protocol spec:
"The surface class identifies the general class of applications
to which the surface belongs. A common convention is to use the
file name (or the full path if it is a non-standard location) of
the application's .desktop file as the class." */
"The surface class identifies the general class of applications
to which the surface belongs. A common convention is to use the
file name (or the full path if it is a non-standard location) of
the application's .desktop file as the class." */
char *spot;
#if defined(__LINUX__) || defined(__FREEBSD__)
@ -328,17 +327,6 @@ static const struct zxdg_shell_v6_listener shell_listener_zxdg = {
};
static void
handle_ping_xdg_wm_base(void *data, struct xdg_wm_base *xdg, uint32_t serial)
{
xdg_wm_base_pong(xdg, serial);
}
static const struct xdg_wm_base_listener shell_listener_xdg = {
handle_ping_xdg_wm_base
};
static void
display_handle_global(void *data, struct wl_registry *registry, uint32_t id,
const char *interface, uint32_t version)
@ -351,9 +339,6 @@ display_handle_global(void *data, struct wl_registry *registry, uint32_t id,
Wayland_add_display(d, id);
} else if (strcmp(interface, "wl_seat") == 0) {
Wayland_display_add_input(d, id);
} else if (strcmp(interface, "xdg_wm_base") == 0) {
d->shell.xdg = wl_registry_bind(d->registry, id, &xdg_wm_base_interface, 1);
xdg_wm_base_add_listener(d->shell.xdg, &shell_listener_xdg, NULL);
} else if (strcmp(interface, "zxdg_shell_v6") == 0) {
d->shell.zxdg = wl_registry_bind(d->registry, id, &zxdg_shell_v6_interface, 1);
zxdg_shell_v6_add_listener(d->shell.zxdg, &shell_listener_zxdg, NULL);
@ -490,9 +475,6 @@ Wayland_VideoQuit(_THIS)
if (data->shell.wl)
wl_shell_destroy(data->shell.wl);
if (data->shell.xdg)
xdg_wm_base_destroy(data->shell.xdg);
if (data->shell.zxdg)
zxdg_shell_v6_destroy(data->shell.zxdg);

View file

@ -24,16 +24,6 @@
#ifndef SDL_waylandvideo_h_
#define SDL_waylandvideo_h_
/*
!!! FIXME: xdg_wm_base is the stable replacement for zxdg_shell_v6. While it's
!!! FIXME: harmless to leave it here, consider deleting the obsolete codepath
!!! FIXME: soon, since Wayland (with xdg_wm_base) will probably be mainline
!!! FIXME: by the time people are relying on this SDL target. It's available
!!! FIXME: in Ubuntu 18.04 (and other distros).
*/
#include <EGL/egl.h>
#include "wayland-util.h"
@ -54,7 +44,7 @@ typedef struct {
struct wl_cursor_theme *cursor_theme;
struct wl_pointer *pointer;
struct {
struct xdg_wm_base *xdg;
/* !!! FIXME: add stable xdg_shell from 1.12 */
struct zxdg_shell_v6 *zxdg;
struct wl_shell *wl;
} shell;

View file

@ -33,7 +33,6 @@
#include "SDL_waylanddyn.h"
#include "SDL_hints.h"
#include "xdg-shell-client-protocol.h"
#include "xdg-shell-unstable-v6-client-protocol.h"
/* On modern desktops, we probably will use the xdg-shell protocol instead
@ -79,15 +78,19 @@ handle_configure_wl_shell_surface(void *data, struct wl_shell_surface *shell_sur
}
}
WAYLAND_wl_egl_window_resize(wind->egl_window, width, height, 0, 0);
region = wl_compositor_create_region(wind->waylandData->compositor);
wl_region_add(region, 0, 0, width, height);
wl_surface_set_opaque_region(wind->surface, region);
wl_region_destroy(region);
if (width == window->w && height == window->h) {
return;
}
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, width, height);
window->w = width;
window->h = height;
WAYLAND_wl_egl_window_resize(wind->egl_window, window->w, window->h, 0, 0);
region = wl_compositor_create_region(wind->waylandData->compositor);
wl_region_add(region, 0, 0, window->w, window->h);
wl_surface_set_opaque_region(wind->surface, region);
wl_region_destroy(region);
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, window->w, window->h);
}
static void
@ -110,15 +113,13 @@ handle_configure_zxdg_shell_surface(void *data, struct zxdg_surface_v6 *zxdg, ui
SDL_WindowData *wind = (SDL_WindowData *)data;
SDL_Window *window = wind->sdlwindow;
struct wl_region *region;
wind->shell_surface.zxdg.initial_configure_seen = SDL_TRUE;
WAYLAND_wl_egl_window_resize(wind->egl_window, window->w, window->h, 0, 0);
region = wl_compositor_create_region(wind->waylandData->compositor);
wl_region_add(region, 0, 0, window->w, window->h);
wl_surface_set_opaque_region(wind->surface, region);
wl_region_destroy(region);
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, window->w, window->h);
zxdg_surface_v6_ack_configure(zxdg, serial);
}
@ -129,85 +130,10 @@ static const struct zxdg_surface_v6_listener shell_surface_listener_zxdg = {
static void
handle_configure_zxdg_toplevel(void *data,
struct zxdg_toplevel_v6 *zxdg_toplevel_v6,
int32_t width,
int32_t height,
struct wl_array *states)
{
SDL_WindowData *wind = (SDL_WindowData *)data;
SDL_Window *window = wind->sdlwindow;
/* wl_shell_surface spec states that this is a suggestion.
Ignore if less than or greater than max/min size. */
if (width == 0 || height == 0) {
return;
}
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
if ((window->flags & SDL_WINDOW_RESIZABLE)) {
if (window->max_w > 0) {
width = SDL_min(width, window->max_w);
}
width = SDL_max(width, window->min_w);
if (window->max_h > 0) {
height = SDL_min(height, window->max_h);
}
height = SDL_max(height, window->min_h);
} else {
return;
}
}
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, width, height);
window->w = width;
window->h = height;
}
static void
handle_close_zxdg_toplevel(void *data, struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
{
SDL_WindowData *window = (SDL_WindowData *)data;
SDL_SendWindowEvent(window->sdlwindow, SDL_WINDOWEVENT_CLOSE, 0, 0);
}
static const struct zxdg_toplevel_v6_listener toplevel_listener_zxdg = {
handle_configure_zxdg_toplevel,
handle_close_zxdg_toplevel
};
static void
handle_configure_xdg_shell_surface(void *data, struct xdg_surface *xdg, uint32_t serial)
{
SDL_WindowData *wind = (SDL_WindowData *)data;
SDL_Window *window = wind->sdlwindow;
struct wl_region *region;
wind->shell_surface.xdg.initial_configure_seen = SDL_TRUE;
WAYLAND_wl_egl_window_resize(wind->egl_window, window->w, window->h, 0, 0);
region = wl_compositor_create_region(wind->waylandData->compositor);
wl_region_add(region, 0, 0, window->w, window->h);
wl_surface_set_opaque_region(wind->surface, region);
wl_region_destroy(region);
xdg_surface_ack_configure(xdg, serial);
}
static const struct xdg_surface_listener shell_surface_listener_xdg = {
handle_configure_xdg_shell_surface
};
static void
handle_configure_xdg_toplevel(void *data,
struct xdg_toplevel *xdg_toplevel,
int32_t width,
int32_t height,
struct wl_array *states)
struct zxdg_toplevel_v6 *zxdg_toplevel_v6,
int32_t width,
int32_t height,
struct wl_array *states)
{
SDL_WindowData *wind = (SDL_WindowData *)data;
SDL_Window *window = wind->sdlwindow;
@ -239,26 +165,23 @@ handle_configure_xdg_toplevel(void *data,
return;
}
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, width, height);
window->w = width;
window->h = height;
}
static void
handle_close_xdg_toplevel(void *data, struct xdg_toplevel *xdg_toplevel)
handle_close_zxdg_toplevel(void *data, struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
{
SDL_WindowData *window = (SDL_WindowData *)data;
SDL_SendWindowEvent(window->sdlwindow, SDL_WINDOWEVENT_CLOSE, 0, 0);
}
static const struct xdg_toplevel_listener toplevel_listener_xdg = {
handle_configure_xdg_toplevel,
handle_close_xdg_toplevel
static const struct zxdg_toplevel_v6_listener toplevel_listener_zxdg = {
handle_configure_zxdg_toplevel,
handle_close_zxdg_toplevel
};
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
static void
handle_onscreen_visibility(void *data,
@ -331,13 +254,7 @@ SetFullscreen(_THIS, SDL_Window * window, struct wl_output *output)
const SDL_VideoData *viddata = (const SDL_VideoData *) _this->driverdata;
SDL_WindowData *wind = window->driverdata;
if (viddata->shell.xdg) {
if (output) {
xdg_toplevel_set_fullscreen(wind->shell_surface.xdg.roleobj.toplevel, output);
} else {
xdg_toplevel_unset_fullscreen(wind->shell_surface.xdg.roleobj.toplevel);
}
} else if (viddata->shell.zxdg) {
if (viddata->shell.zxdg) {
if (output) {
zxdg_toplevel_v6_set_fullscreen(wind->shell_surface.zxdg.roleobj.toplevel, output);
} else {
@ -442,8 +359,7 @@ Wayland_RestoreWindow(_THIS, SDL_Window * window)
SDL_WindowData *wind = window->driverdata;
const SDL_VideoData *viddata = (const SDL_VideoData *) _this->driverdata;
if (viddata->shell.xdg) {
} else if (viddata->shell.zxdg) {
if (viddata->shell.zxdg) {
} else {
wl_shell_surface_set_toplevel(wind->shell_surface.wl);
}
@ -457,9 +373,7 @@ Wayland_MaximizeWindow(_THIS, SDL_Window * window)
SDL_WindowData *wind = window->driverdata;
SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata;
if (viddata->shell.xdg) {
xdg_toplevel_set_maximized(wind->shell_surface.xdg.roleobj.toplevel);
} else if (viddata->shell.zxdg) {
if (viddata->shell.zxdg) {
zxdg_toplevel_v6_set_maximized(wind->shell_surface.zxdg.roleobj.toplevel);
} else {
wl_shell_surface_set_maximized(wind->shell_surface.wl, NULL);
@ -500,13 +414,7 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window)
wl_compositor_create_surface(c->compositor);
wl_surface_set_user_data(data->surface, data);
if (c->shell.xdg) {
data->shell_surface.xdg.surface = xdg_wm_base_get_xdg_surface(c->shell.xdg, data->surface);
/* !!! FIXME: add popup role */
data->shell_surface.xdg.roleobj.toplevel = xdg_surface_get_toplevel(data->shell_surface.xdg.surface);
xdg_toplevel_add_listener(data->shell_surface.xdg.roleobj.toplevel, &toplevel_listener_xdg, data);
xdg_toplevel_set_app_id(data->shell_surface.xdg.roleobj.toplevel, c->classname);
} else if (c->shell.zxdg) {
if (c->shell.zxdg) {
data->shell_surface.zxdg.surface = zxdg_shell_v6_get_xdg_surface(c->shell.zxdg, data->surface);
/* !!! FIXME: add popup role */
data->shell_surface.zxdg.roleobj.toplevel = zxdg_surface_v6_get_toplevel(data->shell_surface.zxdg.surface);
@ -537,12 +445,7 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window)
return SDL_SetError("failed to create a window surface");
}
if (c->shell.xdg) {
if (data->shell_surface.xdg.surface) {
xdg_surface_set_user_data(data->shell_surface.xdg.surface, data);
xdg_surface_add_listener(data->shell_surface.xdg.surface, &shell_surface_listener_xdg, data);
}
} else if (c->shell.zxdg) {
if (c->shell.zxdg) {
if (data->shell_surface.zxdg.surface) {
zxdg_surface_v6_set_user_data(data->shell_surface.zxdg.surface, data);
zxdg_surface_v6_add_listener(data->shell_surface.zxdg.surface, &shell_surface_listener_zxdg, data);
@ -574,24 +477,6 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window)
wl_surface_commit(data->surface);
WAYLAND_wl_display_flush(c->display);
/* we have to wait until the surface gets a "configure" event, or
use of this surface will fail. This is a new rule for xdg_shell. */
if (c->shell.xdg) {
if (data->shell_surface.xdg.surface) {
while (!data->shell_surface.xdg.initial_configure_seen) {
WAYLAND_wl_display_flush(c->display);
WAYLAND_wl_display_dispatch(c->display);
}
}
} else if (c->shell.zxdg) {
if (data->shell_surface.zxdg.surface) {
while (!data->shell_surface.zxdg.initial_configure_seen) {
WAYLAND_wl_display_flush(c->display);
WAYLAND_wl_display_dispatch(c->display);
}
}
}
return 0;
}
@ -615,9 +500,7 @@ void Wayland_SetWindowTitle(_THIS, SDL_Window * window)
SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata;
if (window->title != NULL) {
if (viddata->shell.xdg) {
xdg_toplevel_set_title(wind->shell_surface.xdg.roleobj.toplevel, window->title);
} else if (viddata->shell.zxdg) {
if (viddata->shell.zxdg) {
zxdg_toplevel_v6_set_title(wind->shell_surface.zxdg.roleobj.toplevel, window->title);
} else {
wl_shell_surface_set_title(wind->shell_surface.wl, window->title);
@ -636,14 +519,7 @@ void Wayland_DestroyWindow(_THIS, SDL_Window *window)
SDL_EGL_DestroySurface(_this, wind->egl_surface);
WAYLAND_wl_egl_window_destroy(wind->egl_window);
if (data->shell.xdg) {
if (wind->shell_surface.xdg.roleobj.toplevel) {
xdg_toplevel_destroy(wind->shell_surface.xdg.roleobj.toplevel);
}
if (wind->shell_surface.zxdg.surface) {
xdg_surface_destroy(wind->shell_surface.xdg.surface);
}
} else if (data->shell.zxdg) {
if (data->shell.zxdg) {
if (wind->shell_surface.zxdg.roleobj.toplevel) {
zxdg_toplevel_v6_destroy(wind->shell_surface.zxdg.roleobj.toplevel);
}

View file

@ -37,24 +37,14 @@ typedef struct {
struct zxdg_toplevel_v6 *toplevel;
struct zxdg_popup_v6 *popup;
} roleobj;
SDL_bool initial_configure_seen;
} SDL_zxdg_shell_surface;
typedef struct {
struct xdg_surface *surface;
union {
struct xdg_toplevel *toplevel;
struct xdg_popup *popup;
} roleobj;
SDL_bool initial_configure_seen;
} SDL_xdg_shell_surface;
typedef struct {
SDL_Window *sdlwindow;
SDL_VideoData *waylandData;
struct wl_surface *surface;
union {
SDL_xdg_shell_surface xdg;
/* !!! FIXME: add stable xdg_shell from 1.12 */
SDL_zxdg_shell_surface zxdg;
struct wl_shell_surface *wl;
} shell_surface;

View file

@ -228,7 +228,9 @@ WIN_CheckWParamMouseButton(SDL_bool bwParamMousePressed, SDL_bool bSDLMousePress
/* Ignore the button click for activation */
if (!bwParamMousePressed) {
data->focus_click_pending &= ~SDL_BUTTON(button);
WIN_UpdateClipCursor(data->window);
if (!data->focus_click_pending) {
WIN_UpdateClipCursor(data->window);
}
}
if (WIN_ShouldIgnoreFocusClick()) {
return;
@ -414,23 +416,11 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
break;
case WM_NCACTIVATE:
{
/* Don't immediately clip the cursor in case we're clicking minimize/maximize buttons */
data->skip_update_clipcursor = SDL_TRUE;
}
break;
case WM_ACTIVATE:
{
POINT cursorPos;
BOOL minimized;
/* Don't mark the window as shown if it's activated before being shown */
if (!IsWindowVisible(hwnd)) {
break;
}
minimized = HIWORD(wParam);
if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) {
if (LOWORD(wParam) == WA_CLICKACTIVE) {
@ -470,8 +460,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
SDL_ToggleModState(KMOD_CAPS, (GetKeyState(VK_CAPITAL) & 0x0001) != 0);
SDL_ToggleModState(KMOD_NUM, (GetKeyState(VK_NUMLOCK) & 0x0001) != 0);
} else {
RECT rect;
data->in_window_deactivation = SDL_TRUE;
if (SDL_GetKeyboardFocus() == data->window) {
@ -479,10 +467,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
WIN_ResetDeadKeys();
}
if (GetClipCursor(&rect) && SDL_memcmp(&rect, &data->cursor_clipped_rect, sizeof(rect) == 0)) {
ClipCursor(NULL);
SDL_zero(data->cursor_clipped_rect);
}
ClipCursor(NULL);
data->in_window_deactivation = SDL_FALSE;
}
@ -663,7 +648,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
break;
case WM_UNICHAR:
if (wParam == UNICODE_NOCHAR) {
if ( wParam == UNICODE_NOCHAR ) {
returnCode = 1;
break;
}
@ -671,8 +656,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_CHAR:
{
char text[5];
if (WIN_ConvertUTF32toUTF8((UINT32)wParam, text)) {
SDL_SendKeyboardText(text);
if ( WIN_ConvertUTF32toUTF8( (UINT32)wParam, text ) ) {
SDL_SendKeyboardText( text );
}
}
returnCode = 0;
@ -1037,20 +1022,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
}
static void WIN_UpdateClipCursorForWindows()
{
SDL_VideoDevice *_this = SDL_GetVideoDevice();
SDL_Window *window;
if (_this) {
for (window = _this->windows; window; window = window->next) {
if (window->driverdata) {
WIN_UpdateClipCursor(window);
}
}
}
}
/* A message hook called before TranslateMessage() */
static SDL_WindowsMessageHook g_WindowsMessageHook = NULL;
static void *g_WindowsMessageHookData = NULL;
@ -1096,9 +1067,6 @@ WIN_PumpEvents(_THIS)
if ((keystate[SDL_SCANCODE_RSHIFT] == SDL_PRESSED) && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RSHIFT);
}
/* Update the clipping rect in case someone else has stolen it */
WIN_UpdateClipCursorForWindows();
}
/* to work around #3931, a bug introduced in Win10 Fall Creators Update (build nr. 16299)
@ -1126,9 +1094,9 @@ IsWin10FCUorNewer(void)
SDL_zero(info);
info.dwOSVersionInfoSize = sizeof(info);
if (getVersionPtr(&info) == 0) { /* STATUS_SUCCESS == 0 */
if ((info.dwMajorVersion == 10 && info.dwMinorVersion == 0 && info.dwBuildNumber >= 16299) ||
(info.dwMajorVersion == 10 && info.dwMinorVersion > 0) ||
(info.dwMajorVersion > 10))
if ( (info.dwMajorVersion == 10 && info.dwMinorVersion == 0 && info.dwBuildNumber >= 16299)
|| (info.dwMajorVersion == 10 && info.dwMinorVersion > 0)
|| (info.dwMajorVersion > 10) )
{
return SDL_TRUE;
}

View file

@ -22,52 +22,16 @@
#if SDL_VIDEO_DRIVER_WINDOWS
#ifdef HAVE_LIMITS_H
#include <limits.h>
#else
#ifndef SIZE_MAX
#define SIZE_MAX ((size_t)-1)
#endif
#endif
#include "../../core/windows/SDL_windows.h"
#include "SDL_assert.h"
#include "SDL_windowsvideo.h"
#include "SDL_windowstaskdialog.h"
#ifndef SS_EDITCONTROL
#define SS_EDITCONTROL 0x2000
#endif
#ifndef IDOK
#define IDOK 1
#endif
#ifndef IDCANCEL
#define IDCANCEL 2
#endif
/* Custom dialog return codes */
#define IDCLOSED 20
#define IDINVALPTRINIT 50
#define IDINVALPTRCOMMAND 51
#define IDINVALPTRSETFOCUS 52
#define IDINVALPTRDLGITEM 53
/* First button ID */
#define IDBUTTONINDEX0 100
#define DLGITEMTYPEBUTTON 0x0080
#define DLGITEMTYPESTATIC 0x0082
/* Windows only sends the lower 16 bits of the control ID when a button
* gets clicked. There are also some predefined and custom IDs that lower
* the available number further. 2^16 - 101 buttons should be enough for
* everyone, no need to make the code more complex.
*/
#define MAX_BUTTONS (0xffff - 100)
/* Display a Windows message box */
#pragma pack(push, 1)
@ -106,79 +70,15 @@ typedef struct
Uint8 *data;
size_t size;
size_t used;
WORD numbuttons;
} WIN_DialogData;
static SDL_bool GetButtonIndex(const SDL_MessageBoxData *messageboxdata, Uint32 flags, size_t *i)
{
for (*i = 0; *i < (size_t)messageboxdata->numbuttons; ++*i) {
if (messageboxdata->buttons[*i].flags & flags) {
return SDL_TRUE;
}
}
return SDL_FALSE;
}
static INT_PTR MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
const SDL_MessageBoxData *messageboxdata;
size_t buttonindex;
switch ( iMessage ) {
case WM_INITDIALOG:
if (lParam == 0) {
EndDialog(hDlg, IDINVALPTRINIT);
return TRUE;
}
messageboxdata = (const SDL_MessageBoxData *)lParam;
SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam);
if (GetButtonIndex(messageboxdata, SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, &buttonindex)) {
/* Focus on the first default return-key button */
HWND buttonctl = GetDlgItem(hDlg, (int)(IDBUTTONINDEX0 + buttonindex));
if (buttonctl == NULL) {
EndDialog(hDlg, IDINVALPTRDLGITEM);
}
PostMessage(hDlg, WM_NEXTDLGCTL, (WPARAM)buttonctl, TRUE);
} else {
/* Give the focus to the dialog window instead */
SetFocus(hDlg);
}
return FALSE;
case WM_SETFOCUS:
messageboxdata = (const SDL_MessageBoxData *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
if (messageboxdata == NULL) {
EndDialog(hDlg, IDINVALPTRSETFOCUS);
return TRUE;
}
/* Let the default button be focused if there is one. Otherwise, prevent any initial focus. */
if (GetButtonIndex(messageboxdata, SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, &buttonindex)) {
return FALSE;
}
return TRUE;
case WM_COMMAND:
messageboxdata = (const SDL_MessageBoxData *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
if (messageboxdata == NULL) {
EndDialog(hDlg, IDINVALPTRCOMMAND);
return TRUE;
}
/* Return the ID of the button that was pushed */
if (wParam == IDOK) {
if (GetButtonIndex(messageboxdata, SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, &buttonindex)) {
EndDialog(hDlg, IDBUTTONINDEX0 + buttonindex);
}
} else if (wParam == IDCANCEL) {
if (GetButtonIndex(messageboxdata, SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, &buttonindex)) {
EndDialog(hDlg, IDBUTTONINDEX0 + buttonindex);
} else {
/* Closing of window was requested by user or system. It would be rude not to comply. */
EndDialog(hDlg, IDCLOSED);
}
} else if (wParam >= IDBUTTONINDEX0 && (int)wParam - IDBUTTONINDEX0 < messageboxdata->numbuttons) {
EndDialog(hDlg, wParam);
}
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
default:
@ -189,30 +89,15 @@ static INT_PTR MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPA
static SDL_bool ExpandDialogSpace(WIN_DialogData *dialog, size_t space)
{
/* Growing memory in 64 KiB steps. */
const size_t sizestep = 0x10000;
size_t size = dialog->size;
if (size == 0) {
/* Start with 4 KiB or a multiple of 64 KiB to fit the data. */
size = 0x1000;
if (SIZE_MAX - sizestep < space) {
size = space;
} else if (space > size) {
size = (space + sizestep) & ~(sizestep - 1);
size = space;
} else {
while ((dialog->used + space) > size) {
size *= 2;
}
} else if (SIZE_MAX - dialog->used < space) {
SDL_OutOfMemory();
return SDL_FALSE;
} else if (SIZE_MAX - (dialog->used + space) < sizestep) {
/* Close to the maximum. */
size = dialog->used + space;
} else if (size < dialog->used + space) {
/* Round up to the next 64 KiB block. */
size = dialog->used + space;
size += sizestep - size % sizestep;
}
if (size > dialog->size) {
void *data = SDL_realloc(dialog->data, size);
if (!data) {
@ -290,7 +175,7 @@ static void Vec2ToDLU(short *x, short *y)
}
static SDL_bool AddDialogControl(WIN_DialogData *dialog, WORD type, DWORD style, DWORD exStyle, int x, int y, int w, int h, int id, const char *caption, WORD ordinal)
static SDL_bool AddDialogControl(WIN_DialogData *dialog, WORD type, DWORD style, DWORD exStyle, int x, int y, int w, int h, int id, const char *caption)
{
DLGITEMTEMPLATEEX item;
WORD marker = 0xFFFF;
@ -320,54 +205,32 @@ static SDL_bool AddDialogControl(WIN_DialogData *dialog, WORD type, DWORD style,
if (!AddDialogData(dialog, &type, sizeof(type))) {
return SDL_FALSE;
}
if (type == DLGITEMTYPEBUTTON || (type == DLGITEMTYPESTATIC && caption != NULL)) {
if (!AddDialogString(dialog, caption)) {
return SDL_FALSE;
}
} else {
if (!AddDialogData(dialog, &marker, sizeof(marker))) {
return SDL_FALSE;
}
if (!AddDialogData(dialog, &ordinal, sizeof(ordinal))) {
return SDL_FALSE;
}
if (!AddDialogString(dialog, caption)) {
return SDL_FALSE;
}
if (!AddDialogData(dialog, &extraData, sizeof(extraData))) {
return SDL_FALSE;
}
if (type == DLGITEMTYPEBUTTON) {
dialog->numbuttons++;
}
++dialog->lpDialog->cDlgItems;
return SDL_TRUE;
}
static SDL_bool AddDialogStaticText(WIN_DialogData *dialog, int x, int y, int w, int h, const char *text)
static SDL_bool AddDialogStatic(WIN_DialogData *dialog, int x, int y, int w, int h, const char *text)
{
DWORD style = WS_VISIBLE | WS_CHILD | SS_LEFT | SS_NOPREFIX | SS_EDITCONTROL | WS_GROUP;
return AddDialogControl(dialog, DLGITEMTYPESTATIC, style, 0, x, y, w, h, -1, text, 0);
}
static SDL_bool AddDialogStaticIcon(WIN_DialogData *dialog, int x, int y, int w, int h, Uint16 ordinal)
{
DWORD style = WS_VISIBLE | WS_CHILD | SS_ICON | WS_GROUP;
return AddDialogControl(dialog, DLGITEMTYPESTATIC, style, 0, x, y, w, h, -2, NULL, ordinal);
DWORD style = WS_VISIBLE | WS_CHILD | SS_LEFT | SS_NOPREFIX | SS_EDITCONTROL;
return AddDialogControl(dialog, 0x0082, style, 0, x, y, w, h, -1, text);
}
static SDL_bool AddDialogButton(WIN_DialogData *dialog, int x, int y, int w, int h, const char *text, int id, SDL_bool isDefault)
{
DWORD style = WS_VISIBLE | WS_CHILD | WS_TABSTOP;
DWORD style = WS_VISIBLE | WS_CHILD;
if (isDefault) {
style |= BS_DEFPUSHBUTTON;
} else {
style |= BS_PUSHBUTTON;
}
/* The first button marks the start of the group. */
if (dialog->numbuttons == 0) {
style |= WS_GROUP;
}
return AddDialogControl(dialog, DLGITEMTYPEBUTTON, style, 0, x, y, w, h, IDBUTTONINDEX0 + dialog->numbuttons, text, 0);
return AddDialogControl(dialog, 0x0080, style, 0, x, y, w, h, id, text);
}
static void FreeDialogData(WIN_DialogData *dialog)
@ -478,87 +341,17 @@ static WIN_DialogData *CreateDialogData(int w, int h, const char *caption)
return dialog;
}
/* Escaping ampersands is necessary to disable mnemonics in dialog controls.
* The caller provides a char** for dst and a size_t* for dstlen where the
* address of the work buffer and its size will be stored. Their values must be
* NULL and 0 on the first call. src is the string to be escaped. On error, the
* function returns NULL and, on success, returns a pointer to the escaped
* sequence as a read-only string that is valid until the next call or until the
* work buffer is freed. Once all strings have been processed, it's the caller's
* responsibilty to free the work buffer with SDL_free, even on errors.
*/
static const char *EscapeAmpersands(char **dst, size_t *dstlen, const char *src)
{
char *newdst;
size_t ampcount = 0;
size_t srclen = 0;
if (src == NULL) {
return NULL;
}
while (src[srclen]) {
if (src[srclen] == '&') {
ampcount++;
}
srclen++;
}
srclen++;
if (ampcount == 0) {
/* Nothing to do. */
return src;
}
if (SIZE_MAX - srclen < ampcount) {
return NULL;
}
if (*dst == NULL || *dstlen < srclen + ampcount) {
/* Allocating extra space in case the next strings are a bit longer. */
size_t extraspace = SIZE_MAX - (srclen + ampcount);
if (extraspace > 512) {
extraspace = 512;
}
*dstlen = srclen + ampcount + extraspace;
SDL_free(*dst);
*dst = NULL;
newdst = SDL_malloc(*dstlen);
if (newdst == NULL) {
return NULL;
}
*dst = newdst;
} else {
newdst = *dst;
}
/* The escape character is the ampersand itself. */
while (srclen--) {
if (*src == '&') {
*newdst++ = '&';
}
*newdst++ = *src++;
}
return *dst;
}
/* This function is called if a Task Dialog is unsupported. */
static int
WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
int
WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
{
WIN_DialogData *dialog;
int i, x, y, retval;
int i, x, y;
const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons;
HFONT DialogFont;
SIZE Size;
RECT TextSize;
wchar_t* wmessage;
TEXTMETRIC TM;
HDC FontDC;
INT_PTR result;
char *ampescape = NULL;
size_t ampescapesize = 0;
Uint16 defbuttoncount = 0;
Uint16 icon = 0;
HWND ParentWindow = NULL;
@ -566,25 +359,7 @@ WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
const int ButtonHeight = 26;
const int TextMargin = 16;
const int ButtonMargin = 12;
const int IconWidth = GetSystemMetrics(SM_CXICON);
const int IconHeight = GetSystemMetrics(SM_CYICON);
const int IconMargin = 20;
if (messageboxdata->numbuttons > MAX_BUTTONS) {
return SDL_SetError("Number of butons exceeds limit of %d", MAX_BUTTONS);
}
switch (messageboxdata->flags) {
case SDL_MESSAGEBOX_ERROR:
icon = (Uint16)(size_t)IDI_ERROR;
break;
case SDL_MESSAGEBOX_WARNING:
icon = (Uint16)(size_t)IDI_WARNING;
break;
case SDL_MESSAGEBOX_INFORMATION:
icon = (Uint16)(size_t)IDI_INFORMATION;
break;
}
/* Jan 25th, 2013 - dant@fleetsa.com
*
@ -618,7 +393,7 @@ WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
* In order to get text dimensions we need to have a DC with the desired font.
* I'm assuming a dialog box in SDL is rare enough we can to the create.
*/
FontDC = CreateCompatibleDC(0);
HDC FontDC = CreateCompatibleDC(0);
{
/* Create a duplicate of the font used in system message boxes. */
@ -653,13 +428,11 @@ WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
/* Measure the *pixel* size of the string. */
wmessage = WIN_UTF8ToString(messageboxdata->message);
SDL_zero(TextSize);
DrawText(FontDC, wmessage, -1, &TextSize, DT_CALCRECT | DT_LEFT | DT_NOPREFIX | DT_EDITCONTROL);
DrawText(FontDC, wmessage, -1, &TextSize, DT_CALCRECT);
/* Add margins and some padding for hangs, etc. */
TextSize.left += TextMargin;
TextSize.right += TextMargin + 2;
TextSize.top += TextMargin;
TextSize.bottom += TextMargin + 2;
/* Add some padding for hangs, etc. */
TextSize.right += 2;
TextSize.bottom += 2;
/* Done with the DC, and the string */
DeleteDC(FontDC);
@ -671,22 +444,10 @@ WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
Size.cx += TextMargin * 2;
Size.cy += TextMargin * 2;
/* Make dialog wider and shift text over for the icon. */
if (icon) {
Size.cx += IconMargin + IconWidth;
TextSize.left += IconMargin + IconWidth;
TextSize.right += IconMargin + IconWidth;
}
/* Ensure the size is wide enough for all of the buttons. */
if (Size.cx < messageboxdata->numbuttons * (ButtonWidth + ButtonMargin) + ButtonMargin)
Size.cx = messageboxdata->numbuttons * (ButtonWidth + ButtonMargin) + ButtonMargin;
/* Reset the height to the icon size if it is actually bigger than the text. */
if (icon && Size.cy < IconMargin * 2 + IconHeight) {
Size.cy = IconMargin * 2 + IconHeight;
}
/* Add vertical space for the buttons and border. */
Size.cy += ButtonHeight + TextMargin;
@ -695,12 +456,7 @@ WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
return -1;
}
if (icon && ! AddDialogStaticIcon(dialog, IconMargin, IconMargin, IconWidth, IconHeight, icon)) {
FreeDialogData(dialog);
return -1;
}
if (!AddDialogStaticText(dialog, TextSize.left, TextSize.top, TextSize.right - TextSize.left, TextSize.bottom - TextSize.top, messageboxdata->message)) {
if (!AddDialogStatic(dialog, TextMargin, TextMargin, TextSize.right - TextSize.left, TextSize.bottom - TextSize.top, messageboxdata->message)) {
FreeDialogData(dialog);
return -1;
}
@ -709,25 +465,19 @@ WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
x = Size.cx - (ButtonWidth + ButtonMargin) * messageboxdata->numbuttons;
y = Size.cy - ButtonHeight - ButtonMargin;
for (i = messageboxdata->numbuttons - 1; i >= 0; --i) {
SDL_bool isdefault = SDL_FALSE;
const char *buttontext;
SDL_bool isDefault;
if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
defbuttoncount++;
if (defbuttoncount == 1) {
isdefault = SDL_TRUE;
}
isDefault = SDL_TRUE;
} else {
isDefault = SDL_FALSE;
}
buttontext = EscapeAmpersands(&ampescape, &ampescapesize, buttons[i].text);
if (buttontext == NULL || !AddDialogButton(dialog, x, y, ButtonWidth, ButtonHeight, buttontext, buttons[i].buttonid, isdefault)) {
if (!AddDialogButton(dialog, x, y, ButtonWidth, ButtonHeight, buttons[i].text, buttons[i].buttonid, isDefault)) {
FreeDialogData(dialog);
SDL_free(ampescape);
return -1;
}
x += ButtonWidth + ButtonMargin;
}
SDL_free(ampescape);
/* If we have a parent window, get the Instance and HWND for them
* so that our little dialog gets exclusive focus at all times. */
@ -735,169 +485,10 @@ WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
ParentWindow = ((SDL_WindowData*)messageboxdata->window->driverdata)->hwnd;
}
result = DialogBoxIndirectParam(NULL, (DLGTEMPLATE*)dialog->lpDialog, ParentWindow, (DLGPROC)MessageBoxDialogProc, (LPARAM)messageboxdata);
if (result >= IDBUTTONINDEX0 && result - IDBUTTONINDEX0 < messageboxdata->numbuttons) {
*buttonid = messageboxdata->buttons[(messageboxdata->numbuttons - 1) - (result - IDBUTTONINDEX0)].buttonid;
retval = 0;
} else if (result == IDCLOSED) {
/* Dialog window closed by user or system. */
/* This could use a special return code. */
retval = 0;
*buttonid = -1;
} else {
if (result == 0) {
SDL_SetError("Invalid parent window handle");
} else if (result == -1) {
SDL_SetError("The message box encountered an error.");
} else if (result == IDINVALPTRINIT || result == IDINVALPTRSETFOCUS || result == IDINVALPTRCOMMAND) {
SDL_SetError("Invalid message box pointer in dialog procedure");
} else if (result == IDINVALPTRDLGITEM) {
SDL_SetError("Couldn't find dialog control of the default enter-key button");
} else {
SDL_SetError("An unknown error occured");
}
retval = -1;
}
*buttonid = (int)DialogBoxIndirect(NULL, (DLGTEMPLATE*)dialog->lpDialog, ParentWindow, (DLGPROC)MessageBoxDialogProc);
FreeDialogData(dialog);
return retval;
}
/* TaskDialogIndirect procedure
* This is because SDL targets Windows XP (0x501), so this is not defined in the platform SDK.
*/
typedef HRESULT(FAR WINAPI *TASKDIALOGINDIRECTPROC)(const TASKDIALOGCONFIG *pTaskConfig, int *pnButton, int *pnRadioButton, BOOL *pfVerificationFlagChecked);
int
WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
{
HWND ParentWindow = NULL;
wchar_t *wmessage;
wchar_t *wtitle;
TASKDIALOGCONFIG TaskConfig;
TASKDIALOG_BUTTON *pButtons;
TASKDIALOG_BUTTON *pButton;
HMODULE hComctl32;
TASKDIALOGINDIRECTPROC pfnTaskDialogIndirect;
HRESULT hr;
char *ampescape = NULL;
size_t ampescapesize = 0;
int nButton;
int nCancelButton;
int i;
if (SIZE_MAX / sizeof(TASKDIALOG_BUTTON) < messageboxdata->numbuttons) {
return SDL_OutOfMemory();
}
/* If we cannot load comctl32.dll use the old messagebox! */
hComctl32 = LoadLibrary(TEXT("Comctl32.dll"));
if (hComctl32 == NULL) {
return WIN_ShowOldMessageBox(messageboxdata, buttonid);
}
/* If TaskDialogIndirect doesn't exist use the old messagebox!
This will fail prior to Windows Vista.
The manifest file in the application may require targeting version 6 of comctl32.dll, even
when we use LoadLibrary here!
If you don't want to bother with manifests, put this #pragma in your app's source code somewhere:
pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
*/
pfnTaskDialogIndirect = (TASKDIALOGINDIRECTPROC) GetProcAddress(hComctl32, "TaskDialogIndirect");
if (pfnTaskDialogIndirect == NULL) {
FreeLibrary(hComctl32);
return WIN_ShowOldMessageBox(messageboxdata, buttonid);
}
/* If we have a parent window, get the Instance and HWND for them
so that our little dialog gets exclusive focus at all times. */
if (messageboxdata->window) {
ParentWindow = ((SDL_WindowData *) messageboxdata->window->driverdata)->hwnd;
}
wmessage = WIN_UTF8ToString(messageboxdata->message);
wtitle = WIN_UTF8ToString(messageboxdata->title);
SDL_zero(TaskConfig);
TaskConfig.cbSize = sizeof (TASKDIALOGCONFIG);
TaskConfig.hwndParent = ParentWindow;
TaskConfig.dwFlags = TDF_SIZE_TO_CONTENT;
TaskConfig.pszWindowTitle = wtitle;
if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) {
TaskConfig.pszMainIcon = TD_ERROR_ICON;
} else if (messageboxdata->flags & SDL_MESSAGEBOX_WARNING) {
TaskConfig.pszMainIcon = TD_WARNING_ICON;
} else if (messageboxdata->flags & SDL_MESSAGEBOX_INFORMATION) {
TaskConfig.pszMainIcon = TD_INFORMATION_ICON;
} else {
TaskConfig.pszMainIcon = NULL;
}
TaskConfig.pszContent = wmessage;
TaskConfig.cButtons = messageboxdata->numbuttons;
pButtons = SDL_malloc(sizeof (TASKDIALOG_BUTTON) * messageboxdata->numbuttons);
TaskConfig.nDefaultButton = 0;
nCancelButton = 0;
for (i = 0; i < messageboxdata->numbuttons; i++)
{
const char *buttontext;
pButton = &pButtons[messageboxdata->numbuttons-1-i];
if (messageboxdata->buttons[i].flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) {
nCancelButton = messageboxdata->buttons[i].buttonid;
pButton->nButtonID = 2;
} else {
pButton->nButtonID = messageboxdata->buttons[i].buttonid + 1;
if (pButton->nButtonID >= 2) {
pButton->nButtonID++;
}
}
buttontext = EscapeAmpersands(&ampescape, &ampescapesize, messageboxdata->buttons[i].text);
if (buttontext == NULL) {
int j;
FreeLibrary(hComctl32);
SDL_free(ampescape);
SDL_free(wmessage);
SDL_free(wtitle);
for (j = 0; j < i; j++) {
SDL_free((wchar_t *) pButtons[j].pszButtonText);
}
SDL_free(pButtons);
return -1;
}
pButton->pszButtonText = WIN_UTF8ToString(buttontext);
if (messageboxdata->buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
TaskConfig.nDefaultButton = pButton->nButtonID;
}
}
TaskConfig.pButtons = pButtons;
/* Show the Task Dialog */
hr = pfnTaskDialogIndirect(&TaskConfig, &nButton, NULL, NULL);
/* Free everything */
FreeLibrary(hComctl32);
SDL_free(ampescape);
SDL_free(wmessage);
SDL_free(wtitle);
for (i = 0; i < messageboxdata->numbuttons; i++) {
SDL_free((wchar_t *) pButtons[i].pszButtonText);
}
SDL_free(pButtons);
/* Check the Task Dialog was successful and give the result */
if (SUCCEEDED(hr)) {
if (nButton == 2) {
*buttonid = nCancelButton;
} else if (nButton > 2) {
*buttonid = nButton-1-1;
} else {
*buttonid = nButton-1;
}
return 0;
}
/* We failed showing the Task Dialog, use the old message box! */
return WIN_ShowOldMessageBox(messageboxdata, buttonid);
return 0;
}
#endif /* SDL_VIDEO_DRIVER_WINDOWS */

View file

@ -304,6 +304,8 @@ WIN_InitMouse(_THIS)
mouse->GetGlobalMouseState = WIN_GetGlobalMouseState;
SDL_SetDefaultCursor(WIN_CreateDefaultCursor());
SDL_SetDoubleClickTime(GetDoubleClickTime());
}
void

View file

@ -33,31 +33,31 @@ struct SDL_GLDriverData
SDL_bool HAS_WGL_ARB_create_context_robustness;
SDL_bool HAS_WGL_ARB_create_context_no_error;
/* Max version of OpenGL ES context that can be created if the
implementation supports WGL_EXT_create_context_es2_profile.
major = minor = 0 when unsupported.
*/
struct {
int major;
int minor;
} es_profile_max_supported_version;
/* Max version of OpenGL ES context that can be created if the
implementation supports WGL_EXT_create_context_es2_profile.
major = minor = 0 when unsupported.
*/
struct {
int major;
int minor;
} es_profile_max_supported_version;
void *(WINAPI * wglGetProcAddress) (const char *proc);
HGLRC(WINAPI * wglCreateContext) (HDC hdc);
BOOL(WINAPI * wglDeleteContext) (HGLRC hglrc);
BOOL(WINAPI * wglMakeCurrent) (HDC hdc, HGLRC hglrc);
BOOL(WINAPI * wglShareLists) (HGLRC hglrc1, HGLRC hglrc2);
BOOL(WINAPI * wglChoosePixelFormatARB) (HDC hdc,
const int *piAttribIList,
const FLOAT * pfAttribFList,
UINT nMaxFormats,
int *piFormats,
UINT * nNumFormats);
BOOL(WINAPI * wglGetPixelFormatAttribivARB) (HDC hdc, int iPixelFormat,
int iLayerPlane,
UINT nAttributes,
const int *piAttributes,
int *piValues);
void *(WINAPI * wglGetProcAddress) (const char *proc);
HGLRC(WINAPI * wglCreateContext) (HDC hdc);
BOOL(WINAPI * wglDeleteContext) (HGLRC hglrc);
BOOL(WINAPI * wglMakeCurrent) (HDC hdc, HGLRC hglrc);
BOOL(WINAPI * wglShareLists) (HGLRC hglrc1, HGLRC hglrc2);
BOOL(WINAPI * wglChoosePixelFormatARB) (HDC hdc,
const int *piAttribIList,
const FLOAT * pfAttribFList,
UINT nMaxFormats,
int *piFormats,
UINT * nNumFormats);
BOOL(WINAPI * wglGetPixelFormatAttribivARB) (HDC hdc, int iPixelFormat,
int iLayerPlane,
UINT nAttributes,
const int *piAttributes,
int *piValues);
BOOL (WINAPI * wglSwapIntervalEXT) (int interval);
int (WINAPI * wglGetSwapIntervalEXT) (void);
};

View file

@ -1,156 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include <pshpack1.h>
typedef HRESULT(CALLBACK *PFTASKDIALOGCALLBACK)(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, LONG_PTR lpRefData);
enum _TASKDIALOG_FLAGS
{
TDF_ENABLE_HYPERLINKS = 0x0001,
TDF_USE_HICON_MAIN = 0x0002,
TDF_USE_HICON_FOOTER = 0x0004,
TDF_ALLOW_DIALOG_CANCELLATION = 0x0008,
TDF_USE_COMMAND_LINKS = 0x0010,
TDF_USE_COMMAND_LINKS_NO_ICON = 0x0020,
TDF_EXPAND_FOOTER_AREA = 0x0040,
TDF_EXPANDED_BY_DEFAULT = 0x0080,
TDF_VERIFICATION_FLAG_CHECKED = 0x0100,
TDF_SHOW_PROGRESS_BAR = 0x0200,
TDF_SHOW_MARQUEE_PROGRESS_BAR = 0x0400,
TDF_CALLBACK_TIMER = 0x0800,
TDF_POSITION_RELATIVE_TO_WINDOW = 0x1000,
TDF_RTL_LAYOUT = 0x2000,
TDF_NO_DEFAULT_RADIO_BUTTON = 0x4000,
TDF_CAN_BE_MINIMIZED = 0x8000,
//#if (NTDDI_VERSION >= NTDDI_WIN8)
TDF_NO_SET_FOREGROUND = 0x00010000, // Don't call SetForegroundWindow() when activating the dialog
//#endif // (NTDDI_VERSION >= NTDDI_WIN8)
TDF_SIZE_TO_CONTENT = 0x01000000 // used by ShellMessageBox to emulate MessageBox sizing behavior
};
typedef int TASKDIALOG_FLAGS; // Note: _TASKDIALOG_FLAGS is an int
typedef enum _TASKDIALOG_MESSAGES
{
TDM_NAVIGATE_PAGE = WM_USER + 101,
TDM_CLICK_BUTTON = WM_USER + 102, // wParam = Button ID
TDM_SET_MARQUEE_PROGRESS_BAR = WM_USER + 103, // wParam = 0 (nonMarque) wParam != 0 (Marquee)
TDM_SET_PROGRESS_BAR_STATE = WM_USER + 104, // wParam = new progress state
TDM_SET_PROGRESS_BAR_RANGE = WM_USER + 105, // lParam = MAKELPARAM(nMinRange, nMaxRange)
TDM_SET_PROGRESS_BAR_POS = WM_USER + 106, // wParam = new position
TDM_SET_PROGRESS_BAR_MARQUEE = WM_USER + 107, // wParam = 0 (stop marquee), wParam != 0 (start marquee), lparam = speed (milliseconds between repaints)
TDM_SET_ELEMENT_TEXT = WM_USER + 108, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)
TDM_CLICK_RADIO_BUTTON = WM_USER + 110, // wParam = Radio Button ID
TDM_ENABLE_BUTTON = WM_USER + 111, // lParam = 0 (disable), lParam != 0 (enable), wParam = Button ID
TDM_ENABLE_RADIO_BUTTON = WM_USER + 112, // lParam = 0 (disable), lParam != 0 (enable), wParam = Radio Button ID
TDM_CLICK_VERIFICATION = WM_USER + 113, // wParam = 0 (unchecked), 1 (checked), lParam = 1 (set key focus)
TDM_UPDATE_ELEMENT_TEXT = WM_USER + 114, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)
TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE = WM_USER + 115, // wParam = Button ID, lParam = 0 (elevation not required), lParam != 0 (elevation required)
TDM_UPDATE_ICON = WM_USER + 116 // wParam = icon element (TASKDIALOG_ICON_ELEMENTS), lParam = new icon (hIcon if TDF_USE_HICON_* was set, PCWSTR otherwise)
} TASKDIALOG_MESSAGES;
typedef enum _TASKDIALOG_NOTIFICATIONS
{
TDN_CREATED = 0,
TDN_NAVIGATED = 1,
TDN_BUTTON_CLICKED = 2, // wParam = Button ID
TDN_HYPERLINK_CLICKED = 3, // lParam = (LPCWSTR)pszHREF
TDN_TIMER = 4, // wParam = Milliseconds since dialog created or timer reset
TDN_DESTROYED = 5,
TDN_RADIO_BUTTON_CLICKED = 6, // wParam = Radio Button ID
TDN_DIALOG_CONSTRUCTED = 7,
TDN_VERIFICATION_CLICKED = 8, // wParam = 1 if checkbox checked, 0 if not, lParam is unused and always 0
TDN_HELP = 9,
TDN_EXPANDO_BUTTON_CLICKED = 10 // wParam = 0 (dialog is now collapsed), wParam != 0 (dialog is now expanded)
} TASKDIALOG_NOTIFICATIONS;
typedef struct _TASKDIALOG_BUTTON
{
int nButtonID;
PCWSTR pszButtonText;
} TASKDIALOG_BUTTON;
typedef enum _TASKDIALOG_ELEMENTS
{
TDE_CONTENT,
TDE_EXPANDED_INFORMATION,
TDE_FOOTER,
TDE_MAIN_INSTRUCTION
} TASKDIALOG_ELEMENTS;
typedef enum _TASKDIALOG_ICON_ELEMENTS
{
TDIE_ICON_MAIN,
TDIE_ICON_FOOTER
} TASKDIALOG_ICON_ELEMENTS;
#define TD_WARNING_ICON MAKEINTRESOURCEW(-1)
#define TD_ERROR_ICON MAKEINTRESOURCEW(-2)
#define TD_INFORMATION_ICON MAKEINTRESOURCEW(-3)
#define TD_SHIELD_ICON MAKEINTRESOURCEW(-4)
enum _TASKDIALOG_COMMON_BUTTON_FLAGS
{
TDCBF_OK_BUTTON = 0x0001, // selected control return value IDOK
TDCBF_YES_BUTTON = 0x0002, // selected control return value IDYES
TDCBF_NO_BUTTON = 0x0004, // selected control return value IDNO
TDCBF_CANCEL_BUTTON = 0x0008, // selected control return value IDCANCEL
TDCBF_RETRY_BUTTON = 0x0010, // selected control return value IDRETRY
TDCBF_CLOSE_BUTTON = 0x0020 // selected control return value IDCLOSE
};
typedef int TASKDIALOG_COMMON_BUTTON_FLAGS; // Note: _TASKDIALOG_COMMON_BUTTON_FLAGS is an int
typedef struct _TASKDIALOGCONFIG
{
UINT cbSize;
HWND hwndParent; // incorrectly named, this is the owner window, not a parent.
HINSTANCE hInstance; // used for MAKEINTRESOURCE() strings
TASKDIALOG_FLAGS dwFlags; // TASKDIALOG_FLAGS (TDF_XXX) flags
TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons; // TASKDIALOG_COMMON_BUTTON (TDCBF_XXX) flags
PCWSTR pszWindowTitle; // string or MAKEINTRESOURCE()
union
{
HICON hMainIcon;
PCWSTR pszMainIcon;
} /*DUMMYUNIONNAME*/;
PCWSTR pszMainInstruction;
PCWSTR pszContent;
UINT cButtons;
const TASKDIALOG_BUTTON *pButtons;
int nDefaultButton;
UINT cRadioButtons;
const TASKDIALOG_BUTTON *pRadioButtons;
int nDefaultRadioButton;
PCWSTR pszVerificationText;
PCWSTR pszExpandedInformation;
PCWSTR pszExpandedControlText;
PCWSTR pszCollapsedControlText;
union
{
HICON hFooterIcon;
PCWSTR pszFooterIcon;
} /*DUMMYUNIONNAME2*/;
PCWSTR pszFooter;
PFTASKDIALOGCALLBACK pfCallback;
LONG_PTR lpCallbackData;
UINT cxWidth; // width of the Task Dialog's client area in DLU's. If 0, Task Dialog will calculate the ideal width.
} TASKDIALOGCONFIG;
#include <poppack.h>

View file

@ -63,15 +63,6 @@ UpdateWindowFrameUsableWhileCursorHidden(void *userdata, const char *name, const
}
}
static void WIN_SuspendScreenSaver(_THIS)
{
if (_this->suspend_screensaver) {
SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
} else {
SetThreadExecutionState(ES_CONTINUOUS);
}
}
/* Windows driver bootstrap functions */
@ -145,7 +136,6 @@ WIN_CreateDevice(int devindex)
device->GetDisplayModes = WIN_GetDisplayModes;
device->SetDisplayMode = WIN_SetDisplayMode;
device->PumpEvents = WIN_PumpEvents;
device->SuspendScreenSaver = WIN_SuspendScreenSaver;
device->CreateSDLWindow = WIN_CreateWindow;
device->CreateSDLWindowFrom = WIN_CreateWindowFrom;
@ -174,7 +164,6 @@ WIN_CreateDevice(int devindex)
device->DestroyWindowFramebuffer = WIN_DestroyWindowFramebuffer;
device->OnWindowEnter = WIN_OnWindowEnter;
device->SetWindowHitTest = WIN_SetWindowHitTest;
device->AcceptDragAndDrop = WIN_AcceptDragAndDrop;
device->shape_driver.CreateShaper = Win32_CreateShaper;
device->shape_driver.SetWindowShape = Win32_SetWindowShape;

View file

@ -40,7 +40,7 @@ int WIN_Vulkan_LoadLibrary(_THIS, const char *path)
{
VkExtensionProperties *extensions = NULL;
Uint32 extensionCount = 0;
Uint32 i;
Uint32 i;
SDL_bool hasSurfaceExtension = SDL_FALSE;
SDL_bool hasWin32SurfaceExtension = SDL_FALSE;
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL;

View file

@ -97,11 +97,6 @@ GetWindowStyle(SDL_Window * window)
if (window->flags & SDL_WINDOW_RESIZABLE) {
style |= STYLE_RESIZABLE;
}
/* Need to set initialize minimize style, or when we call ShowWindow with WS_MINIMIZE it will activate a random window */
if (window->flags & SDL_WINDOW_MINIMIZED) {
style |= WS_MINIMIZE;
}
}
return style;
}
@ -220,6 +215,8 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, HWND parent, SDL_bool cre
if ((window->windowed.w && window->windowed.w != w) || (window->windowed.h && window->windowed.h != h)) {
/* We tried to create a window larger than the desktop and Windows didn't allow it. Override! */
int x, y;
int w, h;
/* Figure out what the window area will be */
WIN_AdjustWindowRect(window, &x, &y, &w, &h, SDL_FALSE);
SetWindowPos(hwnd, HWND_NOTOPMOST, x, y, w, h, SWP_NOCOPYBITS | SWP_NOZORDER | SWP_NOACTIVATE);
@ -290,6 +287,9 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, HWND parent, SDL_bool cre
videodata->RegisterTouchWindow(hwnd, (TWF_FINETOUCH|TWF_WANTPALM));
}
/* Enable dropping files */
DragAcceptFiles(hwnd, TRUE);
data->initializing = SDL_FALSE;
/* All done! */
@ -335,10 +335,6 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
/* Inform Windows of the frame change so we can respond to WM_NCCALCSIZE */
SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
if (window->flags & SDL_WINDOW_MINIMIZED) {
ShowWindow(hwnd, SW_SHOWMINNOACTIVE);
}
if (!(window->flags & SDL_WINDOW_OPENGL)) {
return 0;
}
@ -411,11 +407,13 @@ WIN_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
SDL_sscanf(hint, "%p", (void**)&otherWindow);
/* Do some error checking on the pointer */
if (otherWindow != NULL && otherWindow->magic == &_this->window_magic) {
if (otherWindow != NULL && otherWindow->magic == &_this->window_magic)
{
/* If the otherWindow has SDL_WINDOW_OPENGL set, set it for the new window as well */
if (otherWindow->flags & SDL_WINDOW_OPENGL) {
if (otherWindow->flags & SDL_WINDOW_OPENGL)
{
window->flags |= SDL_WINDOW_OPENGL;
if (!WIN_GL_SetPixelFormatFrom(_this, otherWindow, window)) {
if(!WIN_GL_SetPixelFormatFrom(_this, otherWindow, window)) {
return -1;
}
}
@ -548,17 +546,8 @@ WIN_GetWindowBordersSize(_THIS, SDL_Window * window, int *top, int *left, int *b
void
WIN_ShowWindow(_THIS, SDL_Window * window)
{
DWORD style;
HWND hwnd;
int nCmdShow;
hwnd = ((SDL_WindowData *)window->driverdata)->hwnd;
nCmdShow = SW_SHOW;
style = GetWindowLong(hwnd, GWL_EXSTYLE);
if (style & WS_EX_NOACTIVATE) {
nCmdShow = SW_SHOWNOACTIVATE;
}
ShowWindow(hwnd, nCmdShow);
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
ShowWindow(hwnd, SW_SHOW);
}
void
@ -902,13 +891,8 @@ WIN_UpdateClipCursor(SDL_Window *window)
{
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
SDL_Mouse *mouse = SDL_GetMouse();
RECT rect;
if (data->in_title_click || data->focus_click_pending) {
return;
}
if (data->skip_update_clipcursor) {
data->skip_update_clipcursor = SDL_FALSE;
if (data->focus_click_pending) {
return;
}
@ -916,6 +900,7 @@ WIN_UpdateClipCursor(SDL_Window *window)
(window->flags & SDL_WINDOW_INPUT_FOCUS)) {
if (mouse->relative_mode && !mouse->relative_mode_warp) {
LONG cx, cy;
RECT rect;
GetWindowRect(data->hwnd, &rect);
cx = (rect.left + rect.right) / 2;
@ -927,21 +912,17 @@ WIN_UpdateClipCursor(SDL_Window *window)
rect.top = cy - 1;
rect.bottom = cy + 1;
if (ClipCursor(&rect)) {
data->cursor_clipped_rect = rect;
}
ClipCursor(&rect);
} else {
RECT rect;
if (GetClientRect(data->hwnd, &rect) && !IsRectEmpty(&rect)) {
ClientToScreen(data->hwnd, (LPPOINT) & rect);
ClientToScreen(data->hwnd, (LPPOINT) & rect + 1);
if (ClipCursor(&rect)) {
data->cursor_clipped_rect = rect;
}
ClipCursor(&rect);
}
}
} else if (GetClipCursor(&rect) && SDL_memcmp(&rect, &data->cursor_clipped_rect, sizeof(rect)) == 0) {
} else {
ClipCursor(NULL);
SDL_zero(data->cursor_clipped_rect);
}
}
@ -984,13 +965,6 @@ WIN_SetWindowOpacity(_THIS, SDL_Window * window, float opacity)
return 0;
}
void
WIN_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept)
{
const SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
DragAcceptFiles(data->hwnd, accept ? TRUE : FALSE);
}
#endif /* SDL_VIDEO_DRIVER_WINDOWS */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -44,10 +44,8 @@ typedef struct
SDL_bool in_border_change;
SDL_bool in_title_click;
Uint8 focus_click_pending;
SDL_bool skip_update_clipcursor;
SDL_bool windowed_mode_was_maximized;
SDL_bool in_window_deactivation;
RECT cursor_clipped_rect;
struct SDL_VideoData *videodata;
#if SDL_VIDEO_OPENGL_EGL
EGLSurface egl_surface;
@ -80,7 +78,6 @@ extern SDL_bool WIN_GetWindowWMInfo(_THIS, SDL_Window * window,
extern void WIN_OnWindowEnter(_THIS, SDL_Window * window);
extern void WIN_UpdateClipCursor(SDL_Window *window);
extern int WIN_SetWindowHitTest(SDL_Window *window, SDL_bool enabled);
extern void WIN_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept);
#endif /* SDL_windowswindow_h_ */

View file

@ -18,10 +18,6 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_x11framebuffer_h_
#define SDL_x11framebuffer_h_
#include "../../SDL_internal.h"
@ -32,6 +28,4 @@ extern int X11_UpdateWindowFramebuffer(_THIS, SDL_Window * window,
const SDL_Rect * rects, int numrects);
extern void X11_DestroyWindowFramebuffer(_THIS, SDL_Window * window);
#endif /* SDL_x11framebuffer_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -266,7 +266,7 @@ X11_InitKeyboard(_THIS)
int best_distance;
int best_index;
int distance;
Bool xkb_repeat = 0;
BOOL xkb_repeat = 0;
X11_XAutoRepeatOn(data->display);
@ -292,7 +292,9 @@ X11_InitKeyboard(_THIS)
char *prev_locale = setlocale(LC_ALL, NULL);
char *prev_xmods = X11_XSetLocaleModifiers(NULL);
const char *new_xmods = "";
#if defined(HAVE_IBUS_IBUS_H) || defined(HAVE_FCITX_FRONTEND_H)
const char *env_xmods = SDL_getenv("XMODIFIERS");
#endif
SDL_bool has_dbus_ime_support = SDL_FALSE;
if (prev_locale) {
@ -307,12 +309,16 @@ X11_InitKeyboard(_THIS)
when it is used via XIM which causes issues. Prevent this by forcing
@im=none if XMODIFIERS contains @im=ibus. IBus can still be used via
the DBus implementation, which also has support for pre-editing. */
#ifdef HAVE_IBUS_IBUS_H
if (env_xmods && SDL_strstr(env_xmods, "@im=ibus") != NULL) {
has_dbus_ime_support = SDL_TRUE;
}
#endif
#ifdef HAVE_FCITX_FRONTEND_H
if (env_xmods && SDL_strstr(env_xmods, "@im=fcitx") != NULL) {
has_dbus_ime_support = SDL_TRUE;
}
#endif
if (has_dbus_ime_support || !xkb_repeat) {
new_xmods = "@im=none";
}

View file

@ -44,6 +44,7 @@
#endif
#define MAX_BUTTONS 8 /* Maximum number of buttons supported */
#define MAX_TEXT_LINES 32 /* Maximum number of text lines supported */
#define MIN_BUTTON_WIDTH 64 /* Minimum button width */
#define MIN_DIALOG_WIDTH 200 /* Minimum dialog width */
#define MIN_DIALOG_HEIGHT 100 /* Minimum dialog height */
@ -100,7 +101,7 @@ typedef struct SDL_MessageBoxDataX11
int xtext, ytext; /* Text position to start drawing at. */
int numlines; /* Count of Text lines. */
int text_height; /* Height for text lines. */
TextLineData *linedata;
TextLineData linedata[ MAX_TEXT_LINES ];
int *pbuttonid; /* Pointer to user return buttonid value. */
@ -222,18 +223,6 @@ X11_MessageBoxInit( SDL_MessageBoxDataX11 *data, const SDL_MessageBoxData * mess
return 0;
}
static int
CountLinesOfText(const char *text)
{
int retval = 0;
while (text && *text) {
const char *lf = SDL_strchr(text, '\n');
retval++; /* even without an endline, this counts as a line. */
text = lf ? lf + 1 : NULL;
}
return retval;
}
/* Calculate and initialize text and button locations. */
static int
X11_MessageBoxInitPositions( SDL_MessageBoxDataX11 *data )
@ -248,35 +237,29 @@ X11_MessageBoxInitPositions( SDL_MessageBoxDataX11 *data )
/* Go over text and break linefeeds into separate lines. */
if ( messageboxdata->message && messageboxdata->message[ 0 ] ) {
const char *text = messageboxdata->message;
const int linecount = CountLinesOfText(text);
TextLineData *plinedata = (TextLineData *) SDL_malloc(sizeof (TextLineData) * linecount);
TextLineData *plinedata = data->linedata;
if (!plinedata) {
return SDL_OutOfMemory();
}
data->linedata = plinedata;
data->numlines = linecount;
for ( i = 0; i < linecount; i++, plinedata++ ) {
const char *lf = SDL_strchr( text, '\n' );
const int length = lf ? ( lf - text ) : SDL_strlen( text );
for ( i = 0; i < MAX_TEXT_LINES; i++, plinedata++ ) {
int height;
char *lf = SDL_strchr( ( char * )text, '\n' );
data->numlines++;
/* Only grab length up to lf if it exists and isn't the last line. */
plinedata->length = ( lf && ( i < MAX_TEXT_LINES - 1 ) ) ? ( lf - text ) : SDL_strlen( text );
plinedata->text = text;
GetTextWidthHeight( data, text, length, &plinedata->width, &height );
GetTextWidthHeight( data, text, plinedata->length, &plinedata->width, &height );
/* Text and widths are the largest we've ever seen. */
data->text_height = IntMax( data->text_height, height );
text_width_max = IntMax( text_width_max, plinedata->width );
plinedata->length = length;
if (lf && (lf > text) && (lf[-1] == '\r')) {
plinedata->length--;
}
text += length + 1;
text += plinedata->length + 1;
/* Break if there are no more linefeeds. */
if ( !lf )
@ -386,8 +369,6 @@ X11_MessageBoxShutdown( SDL_MessageBoxDataX11 *data )
X11_XCloseDisplay( data->display );
data->display = NULL;
}
SDL_free(data->linedata);
}
/* Create and set up our X11 dialog box indow. */

View file

@ -19,15 +19,10 @@
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_x11messagebox_h_
#define SDL_x11messagebox_h_
#if SDL_VIDEO_DRIVER_X11
extern int X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
#endif /* SDL_VIDEO_DRIVER_X11 */
#endif /* SDL_x11messagebox_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -38,14 +38,14 @@ struct SDL_GLDriverData
SDL_bool HAS_GLX_ARB_create_context_robustness;
SDL_bool HAS_GLX_ARB_create_context_no_error;
/* Max version of OpenGL ES context that can be created if the
implementation supports GLX_EXT_create_context_es2_profile.
major = minor = 0 when unsupported.
*/
struct {
int major;
int minor;
} es_profile_max_supported_version;
/* Max version of OpenGL ES context that can be created if the
implementation supports GLX_EXT_create_context_es2_profile.
major = minor = 0 when unsupported.
*/
struct {
int major;
int minor;
} es_profile_max_supported_version;
Bool (*glXQueryExtension) (Display*,int*,int*);
void *(*glXGetProcAddress) (const GLubyte*);

View file

@ -45,7 +45,7 @@ SDL_X11_SYM(Pixmap,XCreateBitmapFromData,(Display *dpy,Drawable d,_Xconst char *
SDL_X11_SYM(Colormap,XCreateColormap,(Display* a,Window b,Visual* c,int d),(a,b,c,d),return)
SDL_X11_SYM(Cursor,XCreatePixmapCursor,(Display* a,Pixmap b,Pixmap c,XColor* d,XColor* e,unsigned int f,unsigned int g),(a,b,c,d,e,f,g),return)
SDL_X11_SYM(Cursor,XCreateFontCursor,(Display* a,unsigned int b),(a,b),return)
SDL_X11_SYM(XFontSet,XCreateFontSet,(Display* a, _Xconst char* b, char*** c, int* d, char** e),(a,b,c,d,e),return)
SDL_X11_SYM(XFontSet,XCreateFontSet,(Display* a, _Xconst char* b, char*** c, int* d, char** e),(a,b,c,d,e),return)
SDL_X11_SYM(GC,XCreateGC,(Display* a,Drawable b,unsigned long c,XGCValues* d),(a,b,c,d),return)
SDL_X11_SYM(XImage*,XCreateImage,(Display* a,Visual* b,unsigned int c,int d,int e,char* f,unsigned int g,unsigned int h,int i,int j),(a,b,c,d,e,f,g,h,i,j),return)
SDL_X11_SYM(Window,XCreateWindow,(Display* a,Window b,int c,int d,unsigned int e,unsigned int f,unsigned int g,int h,unsigned int i,Visual* j,unsigned long k,XSetWindowAttributes* l),(a,b,c,d,e,f,g,h,i,j,k,l),return)
@ -180,7 +180,7 @@ SDL_X11_SYM(Status,XkbGetUpdatedMap,(Display* a,unsigned int b,XkbDescPtr c),(a,
SDL_X11_SYM(XkbDescPtr,XkbGetMap,(Display* a,unsigned int b,unsigned int c),(a,b,c),return)
SDL_X11_SYM(void,XkbFreeClientMap,(XkbDescPtr a,unsigned int b, Bool c),(a,b,c),)
SDL_X11_SYM(void,XkbFreeKeyboard,(XkbDescPtr a,unsigned int b, Bool c),(a,b,c),)
SDL_X11_SYM(Bool,XkbSetDetectableAutoRepeat,(Display* a, Bool b, Bool* c),(a,b,c),return)
SDL_X11_SYM(BOOL,XkbSetDetectableAutoRepeat,(Display* a, BOOL b, BOOL* c),(a,b,c),return)
#endif
#if NeedWidePrototypes
@ -201,7 +201,7 @@ SDL_X11_SYM(void,XUnsetICFocus,(XIC a),(a),)
SDL_X11_SYM(XIM,XOpenIM,(Display* a,struct _XrmHashBucketRec* b,char* c,char* d),(a,b,c,d),return)
SDL_X11_SYM(Status,XCloseIM,(XIM a),(a),return)
SDL_X11_SYM(void,Xutf8DrawString,(Display *a, Drawable b, XFontSet c, GC d, int e, int f, _Xconst char *g, int h),(a,b,c,d,e,f,g,h),)
SDL_X11_SYM(int,Xutf8TextExtents,(XFontSet a, _Xconst char* b, int c, XRectangle* d, XRectangle* e),(a,b,c,d,e),return)
SDL_X11_SYM(int,Xutf8TextExtents,(XFontSet a, _Xconst char* b, int c, XRectangle* d, XRectangle* e),(a,b,c,d,e),return)
SDL_X11_SYM(char*,XSetLocaleModifiers,(const char *a),(a),return)
SDL_X11_SYM(char*,Xutf8ResetIC,(XIC a),(a),return)
#endif

View file

@ -260,7 +260,6 @@ X11_CreateDevice(int devindex)
device->DestroyWindowFramebuffer = X11_DestroyWindowFramebuffer;
device->GetWindowWMInfo = X11_GetWindowWMInfo;
device->SetWindowHitTest = X11_SetWindowHitTest;
device->AcceptDragAndDrop = X11_AcceptDragAndDrop;
device->shape_driver.CreateShaper = X11_CreateShaper;
device->shape_driver.SetWindowShape = X11_SetWindowShape;

View file

@ -390,6 +390,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
const char *wintype_name = NULL;
long compositor = 1;
Atom _NET_WM_PID;
Atom XdndAware, xdnd_version = 5;
long fevent = 0;
#if SDL_VIDEO_OPENGL_GLX || SDL_VIDEO_OPENGL_EGL
@ -650,6 +651,11 @@ X11_CreateWindow(_THIS, SDL_Window * window)
PropertyChangeMask | StructureNotifyMask |
KeymapStateMask | fevent));
XdndAware = X11_XInternAtom(display, "XdndAware", False);
X11_XChangeProperty(display, w, XdndAware, XA_ATOM, 32,
PropModeReplace,
(unsigned char*)&xdnd_version, 1);
X11_XFlush(display);
return 0;
@ -1598,22 +1604,6 @@ X11_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
return 0; /* just succeed, the real work is done elsewhere. */
}
void
X11_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept)
{
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
Display *display = data->videodata->display;
Atom XdndAware = X11_XInternAtom(display, "XdndAware", False);
if (accept) {
Atom xdnd_version = 5;
X11_XChangeProperty(display, data->xwindow, XdndAware, XA_ATOM, 32,
PropModeReplace, (unsigned char*)&xdnd_version, 1);
} else {
X11_XDeleteProperty(display, data->xwindow, XdndAware);
}
}
#endif /* SDL_VIDEO_DRIVER_X11 */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -104,7 +104,6 @@ extern void X11_DestroyWindow(_THIS, SDL_Window * window);
extern SDL_bool X11_GetWindowWMInfo(_THIS, SDL_Window * window,
struct SDL_SysWMinfo *info);
extern int X11_SetWindowHitTest(SDL_Window *window, SDL_bool enabled);
extern void X11_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept);
#endif /* SDL_x11window_h_ */

View file

@ -77,20 +77,20 @@ void STD_FUNCTION_NAME(
{
const YUV2RGBParam *const param = &(YUV2RGB[yuv_type]);
#if YUV_FORMAT == YUV_FORMAT_420
#define y_pixel_stride 1
#define uv_pixel_stride 1
#define uv_x_sample_interval 2
#define uv_y_sample_interval 2
const int y_pixel_stride = 1;
const int uv_pixel_stride = 1;
const int uv_x_sample_interval = 2;
const int uv_y_sample_interval = 2;
#elif YUV_FORMAT == YUV_FORMAT_422
#define y_pixel_stride 2
#define uv_pixel_stride 4
#define uv_x_sample_interval 2
#define uv_y_sample_interval 1
const int y_pixel_stride = 2;
const int uv_pixel_stride = 4;
const int uv_x_sample_interval = 2;
const int uv_y_sample_interval = 1;
#elif YUV_FORMAT == YUV_FORMAT_NV12
#define y_pixel_stride 1
#define uv_pixel_stride 2
#define uv_x_sample_interval 2
#define uv_y_sample_interval 2
const int y_pixel_stride = 1;
const int uv_pixel_stride = 2;
const int uv_x_sample_interval = 2;
const int uv_y_sample_interval = 2;
#endif
uint32_t x, y;
@ -101,12 +101,9 @@ void STD_FUNCTION_NAME(
*u_ptr=U+(y/uv_y_sample_interval)*UV_stride,
*v_ptr=V+(y/uv_y_sample_interval)*UV_stride;
uint8_t *rgb_ptr1=RGB+y*RGB_stride;
#if uv_y_sample_interval > 1
uint8_t *rgb_ptr2=RGB+(y+1)*RGB_stride;
#endif
uint8_t *rgb_ptr1=RGB+y*RGB_stride,
*rgb_ptr2=RGB+(y+1)*RGB_stride;
for(x=0; x<(width-(uv_x_sample_interval-1)); x+=uv_x_sample_interval)
{
// Compute U and V contributions, common to the four pixels
@ -126,13 +123,13 @@ void STD_FUNCTION_NAME(
y_tmp = ((y_ptr1[y_pixel_stride]-param->y_shift)*param->y_factor);
PACK_PIXEL(rgb_ptr1);
#if uv_y_sample_interval > 1
y_tmp = ((y_ptr2[0]-param->y_shift)*param->y_factor);
PACK_PIXEL(rgb_ptr2);
if (uv_y_sample_interval > 1) {
y_tmp = ((y_ptr2[0]-param->y_shift)*param->y_factor);
PACK_PIXEL(rgb_ptr2);
y_tmp = ((y_ptr2[y_pixel_stride]-param->y_shift)*param->y_factor);
PACK_PIXEL(rgb_ptr2);
#endif
y_tmp = ((y_ptr2[y_pixel_stride]-param->y_shift)*param->y_factor);
PACK_PIXEL(rgb_ptr2);
}
y_ptr1+=2*y_pixel_stride;
y_ptr2+=2*y_pixel_stride;
@ -157,10 +154,10 @@ void STD_FUNCTION_NAME(
int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor);
PACK_PIXEL(rgb_ptr1);
#if uv_y_sample_interval > 1
y_tmp = ((y_ptr2[0]-param->y_shift)*param->y_factor);
PACK_PIXEL(rgb_ptr2);
#endif
if (uv_y_sample_interval > 1) {
y_tmp = ((y_ptr2[0]-param->y_shift)*param->y_factor);
PACK_PIXEL(rgb_ptr2);
}
}
}
@ -215,11 +212,6 @@ void STD_FUNCTION_NAME(
PACK_PIXEL(rgb_ptr1);
}
}
#undef y_pixel_stride
#undef uv_pixel_stride
#undef uv_x_sample_interval
#undef uv_y_sample_interval
}
#undef STD_FUNCTION_NAME