mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 23:24:41 +00:00
* Adjustment: Update libsdl to address a bug in compilation on MacOS devices.
This commit is contained in:
parent
516163fd5d
commit
eab544c8f3
270 changed files with 9531 additions and 3704 deletions
|
|
@ -92,10 +92,6 @@
|
|||
#include "SDL_blit.h"
|
||||
#include "SDL_RLEaccel_c.h"
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#define PIXEL_COPY(to, from, len, bpp) \
|
||||
SDL_memcpy(to, from, (size_t)(len) * (bpp))
|
||||
|
||||
|
|
@ -1161,13 +1157,13 @@ RLEAlphaSurface(SDL_Surface * surface)
|
|||
ADD_OPAQUE_COUNTS(max_opaque_run, 0);
|
||||
skip -= max_opaque_run;
|
||||
}
|
||||
len = MIN(run, max_opaque_run);
|
||||
len = SDL_min(run, max_opaque_run);
|
||||
ADD_OPAQUE_COUNTS(skip, len);
|
||||
dst += copy_opaque(dst, src + runstart, len, sf, df);
|
||||
runstart += len;
|
||||
run -= len;
|
||||
while (run) {
|
||||
len = MIN(run, max_opaque_run);
|
||||
len = SDL_min(run, max_opaque_run);
|
||||
ADD_OPAQUE_COUNTS(0, len);
|
||||
dst += copy_opaque(dst, src + runstart, len, sf, df);
|
||||
runstart += len;
|
||||
|
|
@ -1195,13 +1191,13 @@ RLEAlphaSurface(SDL_Surface * surface)
|
|||
ADD_TRANSL_COUNTS(max_transl_run, 0);
|
||||
skip -= max_transl_run;
|
||||
}
|
||||
len = MIN(run, max_transl_run);
|
||||
len = SDL_min(run, max_transl_run);
|
||||
ADD_TRANSL_COUNTS(skip, len);
|
||||
dst += copy_transl(dst, src + runstart, len, sf, df);
|
||||
runstart += len;
|
||||
run -= len;
|
||||
while (run) {
|
||||
len = MIN(run, max_transl_run);
|
||||
len = SDL_min(run, max_transl_run);
|
||||
ADD_TRANSL_COUNTS(0, len);
|
||||
dst += copy_transl(dst, src + runstart, len, sf, df);
|
||||
runstart += len;
|
||||
|
|
@ -1222,9 +1218,13 @@ RLEAlphaSurface(SDL_Surface * surface)
|
|||
|
||||
/* Now that we have it encoded, release the original pixels */
|
||||
if (!(surface->flags & SDL_PREALLOC)) {
|
||||
SDL_SIMDFree(surface->pixels);
|
||||
if (surface->flags & SDL_SIMD_ALIGNED) {
|
||||
SDL_SIMDFree(surface->pixels);
|
||||
surface->flags &= ~SDL_SIMD_ALIGNED;
|
||||
} else {
|
||||
SDL_free(surface->pixels);
|
||||
}
|
||||
surface->pixels = NULL;
|
||||
surface->flags &= ~SDL_SIMD_ALIGNED;
|
||||
}
|
||||
|
||||
/* reallocate the buffer to release unused memory */
|
||||
|
|
@ -1359,14 +1359,14 @@ RLEColorkeySurface(SDL_Surface * surface)
|
|||
ADD_COUNTS(maxn, 0);
|
||||
skip -= maxn;
|
||||
}
|
||||
len = MIN(run, maxn);
|
||||
len = SDL_min(run, maxn);
|
||||
ADD_COUNTS(skip, len);
|
||||
SDL_memcpy(dst, srcbuf + runstart * bpp, len * bpp);
|
||||
dst += len * bpp;
|
||||
run -= len;
|
||||
runstart += len;
|
||||
while (run) {
|
||||
len = MIN(run, maxn);
|
||||
len = SDL_min(run, maxn);
|
||||
ADD_COUNTS(0, len);
|
||||
SDL_memcpy(dst, srcbuf + runstart * bpp, len * bpp);
|
||||
dst += len * bpp;
|
||||
|
|
@ -1386,9 +1386,13 @@ RLEColorkeySurface(SDL_Surface * surface)
|
|||
|
||||
/* Now that we have it encoded, release the original pixels */
|
||||
if (!(surface->flags & SDL_PREALLOC)) {
|
||||
SDL_SIMDFree(surface->pixels);
|
||||
if (surface->flags & SDL_SIMD_ALIGNED) {
|
||||
SDL_SIMDFree(surface->pixels);
|
||||
surface->flags &= ~SDL_SIMD_ALIGNED;
|
||||
} else {
|
||||
SDL_free(surface->pixels);
|
||||
}
|
||||
surface->pixels = NULL;
|
||||
surface->flags &= ~SDL_SIMD_ALIGNED;
|
||||
}
|
||||
|
||||
/* reallocate the buffer to release unused memory */
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ Blit1to1(SDL_BlitInfo * info)
|
|||
|
||||
while (height--) {
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
*dst = map[*src];
|
||||
|
|
@ -58,7 +58,7 @@ Blit1to1(SDL_BlitInfo * info)
|
|||
dst++;
|
||||
src++;
|
||||
, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
#else
|
||||
for (c = width; c; --c) {
|
||||
*dst = map[*src];
|
||||
|
|
@ -103,14 +103,14 @@ Blit1to2(SDL_BlitInfo * info)
|
|||
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
*(Uint16 *)dst = map[*src++];
|
||||
dst += 2;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -210,7 +210,7 @@ Blit1to3(SDL_BlitInfo * info)
|
|||
|
||||
while (height--) {
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
o = *src * 4;
|
||||
|
|
@ -221,7 +221,7 @@ Blit1to3(SDL_BlitInfo * info)
|
|||
src++;
|
||||
dst += 3;
|
||||
, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
#else
|
||||
for (c = width; c; --c) {
|
||||
o = *src * 4;
|
||||
|
|
@ -259,11 +259,11 @@ Blit1to4(SDL_BlitInfo * info)
|
|||
|
||||
while (height--) {
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
*dst++ = map[*src++];
|
||||
, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
#else
|
||||
for (c = width / 4; c; --c) {
|
||||
*dst++ = map[*src++];
|
||||
|
|
@ -299,7 +299,7 @@ Blit1to1Key(SDL_BlitInfo * info)
|
|||
|
||||
if (palmap) {
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
if ( *src != ckey ) {
|
||||
|
|
@ -309,13 +309,13 @@ Blit1to1Key(SDL_BlitInfo * info)
|
|||
src++;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
} else {
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
if ( *src != ckey ) {
|
||||
|
|
@ -325,7 +325,7 @@ Blit1to1Key(SDL_BlitInfo * info)
|
|||
src++;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -348,7 +348,7 @@ Blit1to2Key(SDL_BlitInfo * info)
|
|||
dstskip /= 2;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
if ( *src != ckey ) {
|
||||
|
|
@ -358,7 +358,7 @@ Blit1to2Key(SDL_BlitInfo * info)
|
|||
dstp++;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
|
|
@ -378,7 +378,7 @@ Blit1to3Key(SDL_BlitInfo * info)
|
|||
int o;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
if ( *src != ckey ) {
|
||||
|
|
@ -391,7 +391,7 @@ Blit1to3Key(SDL_BlitInfo * info)
|
|||
dst += 3;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -413,7 +413,7 @@ Blit1to4Key(SDL_BlitInfo * info)
|
|||
dstskip /= 4;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
if ( *src != ckey ) {
|
||||
|
|
@ -423,7 +423,7 @@ Blit1to4Key(SDL_BlitInfo * info)
|
|||
dstp++;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
|
|
@ -450,7 +450,7 @@ Blit1toNAlpha(SDL_BlitInfo * info)
|
|||
dstbpp = dstfmt->BytesPerPixel;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP4(
|
||||
{
|
||||
sR = srcpal[*src].r;
|
||||
|
|
@ -463,7 +463,7 @@ Blit1toNAlpha(SDL_BlitInfo * info)
|
|||
dst += dstbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -491,7 +491,7 @@ Blit1toNAlphaKey(SDL_BlitInfo * info)
|
|||
dstbpp = dstfmt->BytesPerPixel;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
if ( *src != ckey ) {
|
||||
|
|
@ -506,7 +506,7 @@ Blit1toNAlphaKey(SDL_BlitInfo * info)
|
|||
dst += dstbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ BlitNto1SurfaceAlpha(SDL_BlitInfo * info)
|
|||
const unsigned A = info->a;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP4(
|
||||
{
|
||||
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
|
||||
|
|
@ -68,7 +68,7 @@ BlitNto1SurfaceAlpha(SDL_BlitInfo * info)
|
|||
src += srcbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -93,7 +93,7 @@ BlitNto1PixelAlpha(SDL_BlitInfo * info)
|
|||
unsigned dR, dG, dB;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP4(
|
||||
{
|
||||
DISEMBLE_RGBA(src,srcbpp,srcfmt,Pixel,sR,sG,sB,sA);
|
||||
|
|
@ -114,7 +114,7 @@ BlitNto1PixelAlpha(SDL_BlitInfo * info)
|
|||
src += srcbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -141,7 +141,7 @@ BlitNto1SurfaceAlphaKey(SDL_BlitInfo * info)
|
|||
const unsigned A = info->a;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
|
||||
|
|
@ -164,7 +164,7 @@ BlitNto1SurfaceAlphaKey(SDL_BlitInfo * info)
|
|||
src += srcbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -348,7 +348,7 @@ BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info)
|
|||
multmask2 = 0x00FF00FF00FF00FFULL;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP4({
|
||||
Uint32 alpha = *srcp & amask;
|
||||
if (alpha == 0) {
|
||||
|
|
@ -382,7 +382,7 @@ BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info)
|
|||
++srcp;
|
||||
++dstp;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
|
|
@ -467,14 +467,14 @@ BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo * info)
|
|||
int dstskip = info->dst_skip >> 2;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP4({
|
||||
Uint32 s = *srcp++;
|
||||
Uint32 d = *dstp;
|
||||
*dstp++ = ((((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1)
|
||||
+ (s & d & 0x00010101)) | 0xff000000;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
|
|
@ -500,7 +500,7 @@ BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo * info)
|
|||
Uint32 d1;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP4({
|
||||
s = *srcp;
|
||||
d = *dstp;
|
||||
|
|
@ -515,7 +515,7 @@ BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo * info)
|
|||
++srcp;
|
||||
++dstp;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
|
|
@ -534,7 +534,7 @@ BlitRGBtoRGBPixelAlpha(SDL_BlitInfo * info)
|
|||
int dstskip = info->dst_skip >> 2;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP4({
|
||||
Uint32 dalpha;
|
||||
Uint32 d;
|
||||
|
|
@ -569,7 +569,7 @@ BlitRGBtoRGBPixelAlpha(SDL_BlitInfo * info)
|
|||
++srcp;
|
||||
++dstp;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
|
|
@ -587,7 +587,7 @@ BlitRGBtoBGRPixelAlpha(SDL_BlitInfo * info)
|
|||
int dstskip = info->dst_skip >> 2;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP4({
|
||||
Uint32 dalpha;
|
||||
Uint32 d;
|
||||
|
|
@ -624,7 +624,7 @@ BlitRGBtoBGRPixelAlpha(SDL_BlitInfo * info)
|
|||
++srcp;
|
||||
++dstp;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
|
|
@ -654,7 +654,7 @@ BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info)
|
|||
multmask2 = 0x00FF00FF00FF00FFULL;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP4({
|
||||
Uint32 alpha;
|
||||
|
||||
|
|
@ -694,7 +694,7 @@ BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info)
|
|||
++srcp;
|
||||
++dstp;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
|
|
@ -848,7 +848,7 @@ Blit565to565SurfaceAlphaMMX(SDL_BlitInfo * info)
|
|||
bmask = _mm_set_pi32(0x001F001F, 0x001F001F); /* MASKBLUE -> bmask */
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP_124(
|
||||
{
|
||||
s = *srcp++;
|
||||
|
|
@ -944,7 +944,7 @@ Blit565to565SurfaceAlphaMMX(SDL_BlitInfo * info)
|
|||
srcp += 4;
|
||||
dstp += 4;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
|
|
@ -986,7 +986,7 @@ Blit555to555SurfaceAlphaMMX(SDL_BlitInfo * info)
|
|||
bmask = _mm_set_pi32(0x001F001F, 0x001F001F); /* MASKBLUE -> bmask */
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP_124(
|
||||
{
|
||||
s = *srcp++;
|
||||
|
|
@ -1082,7 +1082,7 @@ Blit555to555SurfaceAlphaMMX(SDL_BlitInfo * info)
|
|||
srcp += 4;
|
||||
dstp += 4;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
|
|
@ -1109,7 +1109,7 @@ Blit565to565SurfaceAlpha(SDL_BlitInfo * info)
|
|||
alpha >>= 3; /* downscale alpha to 5 bits */
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP4({
|
||||
Uint32 s = *srcp++;
|
||||
Uint32 d = *dstp;
|
||||
|
|
@ -1124,7 +1124,7 @@ Blit565to565SurfaceAlpha(SDL_BlitInfo * info)
|
|||
d &= 0x07e0f81f;
|
||||
*dstp++ = (Uint16)(d | d >> 16);
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
|
|
@ -1148,7 +1148,7 @@ Blit555to555SurfaceAlpha(SDL_BlitInfo * info)
|
|||
alpha >>= 3; /* downscale alpha to 5 bits */
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP4({
|
||||
Uint32 s = *srcp++;
|
||||
Uint32 d = *dstp;
|
||||
|
|
@ -1163,7 +1163,7 @@ Blit555to555SurfaceAlpha(SDL_BlitInfo * info)
|
|||
d &= 0x03e07c1f;
|
||||
*dstp++ = (Uint16)(d | d >> 16);
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
|
|
@ -1182,7 +1182,7 @@ BlitARGBto565PixelAlpha(SDL_BlitInfo * info)
|
|||
int dstskip = info->dst_skip >> 1;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP4({
|
||||
Uint32 s = *srcp;
|
||||
unsigned alpha = s >> 27; /* downscale alpha to 5 bits */
|
||||
|
|
@ -1210,7 +1210,7 @@ BlitARGBto565PixelAlpha(SDL_BlitInfo * info)
|
|||
srcp++;
|
||||
dstp++;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
|
|
@ -1228,7 +1228,7 @@ BlitARGBto555PixelAlpha(SDL_BlitInfo * info)
|
|||
int dstskip = info->dst_skip >> 1;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP4({
|
||||
unsigned alpha;
|
||||
Uint32 s = *srcp;
|
||||
|
|
@ -1257,7 +1257,7 @@ BlitARGBto555PixelAlpha(SDL_BlitInfo * info)
|
|||
srcp++;
|
||||
dstp++;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
|
|
@ -1284,7 +1284,7 @@ BlitNtoNSurfaceAlpha(SDL_BlitInfo * info)
|
|||
|
||||
if (sA) {
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP4(
|
||||
{
|
||||
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
|
||||
|
|
@ -1295,7 +1295,7 @@ BlitNtoNSurfaceAlpha(SDL_BlitInfo * info)
|
|||
dst += dstbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -1323,7 +1323,7 @@ BlitNtoNSurfaceAlphaKey(SDL_BlitInfo * info)
|
|||
const unsigned sA = info->a;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP4(
|
||||
{
|
||||
RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel);
|
||||
|
|
@ -1337,7 +1337,7 @@ BlitNtoNSurfaceAlphaKey(SDL_BlitInfo * info)
|
|||
dst += dstbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -1366,7 +1366,7 @@ BlitNtoNPixelAlpha(SDL_BlitInfo * info)
|
|||
dstbpp = dstfmt->BytesPerPixel;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP4(
|
||||
{
|
||||
DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
|
||||
|
|
@ -1379,7 +1379,7 @@ BlitNtoNPixelAlpha(SDL_BlitInfo * info)
|
|||
dst += dstbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1008,11 +1008,11 @@ Blit_RGB888_index8(SDL_BlitInfo * info)
|
|||
if (map == NULL) {
|
||||
while (height--) {
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
RGB888_RGB332(*dst++, *src);
|
||||
, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
#else
|
||||
for (c = width / 4; c; --c) {
|
||||
/* Pack RGB into 8bit pixel */
|
||||
|
|
@ -1044,13 +1044,13 @@ Blit_RGB888_index8(SDL_BlitInfo * info)
|
|||
|
||||
while (height--) {
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
RGB888_RGB332(Pixel, *src);
|
||||
*dst++ = map[Pixel];
|
||||
++src;
|
||||
, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
#else
|
||||
for (c = width / 4; c; --c) {
|
||||
/* Pack RGB into 8bit pixel */
|
||||
|
|
@ -1118,11 +1118,11 @@ Blit_RGB101010_index8(SDL_BlitInfo * info)
|
|||
if (map == NULL) {
|
||||
while (height--) {
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
RGB101010_RGB332(*dst++, *src);
|
||||
, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
#else
|
||||
for (c = width / 4; c; --c) {
|
||||
/* Pack RGB into 8bit pixel */
|
||||
|
|
@ -1154,13 +1154,13 @@ Blit_RGB101010_index8(SDL_BlitInfo * info)
|
|||
|
||||
while (height--) {
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
RGB101010_RGB332(Pixel, *src);
|
||||
*dst++ = map[Pixel];
|
||||
++src;
|
||||
, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
#else
|
||||
for (c = width / 4; c; --c) {
|
||||
/* Pack RGB into 8bit pixel */
|
||||
|
|
@ -1235,13 +1235,13 @@ Blit_RGB888_RGB555(SDL_BlitInfo * info)
|
|||
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
RGB888_RGB555(dst, src);
|
||||
++src;
|
||||
++dst;
|
||||
, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -1361,13 +1361,13 @@ Blit_RGB888_RGB565(SDL_BlitInfo * info)
|
|||
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
RGB888_RGB565(dst, src);
|
||||
++src;
|
||||
++dst;
|
||||
, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -1476,14 +1476,14 @@ Blit_RGB565_32(SDL_BlitInfo * info, const Uint32 * map)
|
|||
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
*dst++ = RGB565_32(dst, src, map);
|
||||
src += 2;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -2088,7 +2088,7 @@ Blit_RGB555_ARGB1555(SDL_BlitInfo * info)
|
|||
Uint16 mask = ((Uint32)info->a >> dstfmt->Aloss) << dstfmt->Ashift;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
*dst = *src | mask;
|
||||
|
|
@ -2096,7 +2096,7 @@ Blit_RGB555_ARGB1555(SDL_BlitInfo * info)
|
|||
++src;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src = (Uint16 *) ((Uint8 *) src + srcskip);
|
||||
dst = (Uint16 *) ((Uint8 *) dst + dstskip);
|
||||
}
|
||||
|
|
@ -2132,7 +2132,7 @@ BlitNto1(SDL_BlitInfo * info)
|
|||
if (map == NULL) {
|
||||
while (height--) {
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
|
||||
sR, sG, sB);
|
||||
|
|
@ -2145,7 +2145,7 @@ BlitNto1(SDL_BlitInfo * info)
|
|||
dst++;
|
||||
src += srcbpp;
|
||||
, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
#else
|
||||
for (c = width; c; --c) {
|
||||
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
|
||||
|
|
@ -2164,7 +2164,7 @@ BlitNto1(SDL_BlitInfo * info)
|
|||
} else {
|
||||
while (height--) {
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
|
||||
sR, sG, sB);
|
||||
|
|
@ -2177,7 +2177,7 @@ BlitNto1(SDL_BlitInfo * info)
|
|||
dst++;
|
||||
src += srcbpp;
|
||||
, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
#else
|
||||
for (c = width; c; --c) {
|
||||
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
|
||||
|
|
@ -2214,7 +2214,7 @@ Blit4to4MaskAlpha(SDL_BlitInfo * info)
|
|||
Uint32 mask = ((Uint32)info->a >> dstfmt->Aloss) << dstfmt->Ashift;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
*dst = *src | mask;
|
||||
|
|
@ -2222,7 +2222,7 @@ Blit4to4MaskAlpha(SDL_BlitInfo * info)
|
|||
++src;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src = (Uint32 *) ((Uint8 *) src + srcskip);
|
||||
dst = (Uint32 *) ((Uint8 *) dst + dstskip);
|
||||
}
|
||||
|
|
@ -2231,7 +2231,7 @@ Blit4to4MaskAlpha(SDL_BlitInfo * info)
|
|||
Uint32 mask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
*dst = *src & mask;
|
||||
|
|
@ -2239,7 +2239,7 @@ Blit4to4MaskAlpha(SDL_BlitInfo * info)
|
|||
++src;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src = (Uint32 *) ((Uint8 *) src + srcskip);
|
||||
dst = (Uint32 *) ((Uint8 *) dst + dstskip);
|
||||
}
|
||||
|
|
@ -2259,7 +2259,7 @@ Blit4to4CopyAlpha(SDL_BlitInfo * info)
|
|||
|
||||
/* RGBA->RGBA, COPY_ALPHA */
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
*dst = *src;
|
||||
|
|
@ -2267,7 +2267,7 @@ Blit4to4CopyAlpha(SDL_BlitInfo * info)
|
|||
++src;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src = (Uint32 *) ((Uint8 *) src + srcskip);
|
||||
dst = (Uint32 *) ((Uint8 *) dst + dstskip);
|
||||
}
|
||||
|
|
@ -2380,7 +2380,7 @@ BlitNtoN(SDL_BlitInfo * info)
|
|||
get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, &alpha_channel);
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
dst[0] = src[p0];
|
||||
|
|
@ -2391,7 +2391,7 @@ BlitNtoN(SDL_BlitInfo * info)
|
|||
src += 4;
|
||||
dst += 4;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -2408,7 +2408,7 @@ BlitNtoN(SDL_BlitInfo * info)
|
|||
get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, NULL);
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
dst[0] = src[p0];
|
||||
|
|
@ -2417,7 +2417,7 @@ BlitNtoN(SDL_BlitInfo * info)
|
|||
src += 4;
|
||||
dst += 3;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -2434,7 +2434,7 @@ BlitNtoN(SDL_BlitInfo * info)
|
|||
get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, &alpha_channel);
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
dst[0] = src[p0];
|
||||
|
|
@ -2445,7 +2445,7 @@ BlitNtoN(SDL_BlitInfo * info)
|
|||
src += 3;
|
||||
dst += 4;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -2454,7 +2454,7 @@ BlitNtoN(SDL_BlitInfo * info)
|
|||
#endif
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint32 Pixel;
|
||||
|
|
@ -2467,7 +2467,7 @@ BlitNtoN(SDL_BlitInfo * info)
|
|||
src += srcbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -2499,7 +2499,7 @@ BlitNtoNCopyAlpha(SDL_BlitInfo * info)
|
|||
get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, NULL);
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
dst[0] = src[p0];
|
||||
|
|
@ -2509,7 +2509,7 @@ BlitNtoNCopyAlpha(SDL_BlitInfo * info)
|
|||
src += 4;
|
||||
dst += 4;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -2554,7 +2554,7 @@ BlitNto1Key(SDL_BlitInfo * info)
|
|||
|
||||
if (palmap == NULL) {
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
|
||||
|
|
@ -2569,13 +2569,13 @@ BlitNto1Key(SDL_BlitInfo * info)
|
|||
src += srcbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
} else {
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
|
||||
|
|
@ -2590,7 +2590,7 @@ BlitNto1Key(SDL_BlitInfo * info)
|
|||
src += srcbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -2615,7 +2615,7 @@ Blit2to2Key(SDL_BlitInfo * info)
|
|||
ckey &= rgbmask;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
if ( (*srcp & rgbmask) != ckey ) {
|
||||
|
|
@ -2625,7 +2625,7 @@ Blit2to2Key(SDL_BlitInfo * info)
|
|||
srcp++;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
|
|
@ -2662,7 +2662,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
|||
/* RGB->RGBA, SET_ALPHA */
|
||||
Uint32 mask = ((Uint32)info->a) << dstfmt->Ashift;
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
if ((*src32 & rgbmask) != ckey) {
|
||||
|
|
@ -2671,7 +2671,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
|||
++dst32;
|
||||
++src32;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src32 = (Uint32 *) ((Uint8 *) src32 + srcskip);
|
||||
dst32 = (Uint32 *) ((Uint8 *) dst32 + dstskip);
|
||||
}
|
||||
|
|
@ -2680,7 +2680,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
|||
/* RGBA->RGB, NO_ALPHA */
|
||||
Uint32 mask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask;
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
if ((*src32 & rgbmask) != ckey) {
|
||||
|
|
@ -2689,7 +2689,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
|||
++dst32;
|
||||
++src32;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src32 = (Uint32 *) ((Uint8 *) src32 + srcskip);
|
||||
dst32 = (Uint32 *) ((Uint8 *) dst32 + dstskip);
|
||||
}
|
||||
|
|
@ -2708,7 +2708,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
|||
get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, &alpha_channel);
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint32 *src32 = (Uint32*)src;
|
||||
|
|
@ -2723,7 +2723,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
|||
src += 4;
|
||||
dst += 4;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -2746,7 +2746,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
|||
#endif
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint8 s0 = src[0];
|
||||
|
|
@ -2762,7 +2762,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
|||
dst += 3;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -2784,7 +2784,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
|||
#endif
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint8 s0 = src[0];
|
||||
|
|
@ -2800,7 +2800,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
|||
dst += 3;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -2816,7 +2816,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
|||
get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, NULL);
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint32 *src32 = (Uint32*)src;
|
||||
|
|
@ -2828,7 +2828,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
|||
src += 4;
|
||||
dst += 3;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -2855,7 +2855,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
|||
get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, &alpha_channel);
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint8 s0 = src[0];
|
||||
|
|
@ -2872,7 +2872,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
|||
src += 3;
|
||||
dst += 4;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -2881,7 +2881,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
|||
#endif
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint32 Pixel;
|
||||
|
|
@ -2897,7 +2897,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
|||
src += srcbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -2938,7 +2938,7 @@ BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info)
|
|||
Uint32 *src32 = (Uint32*)src;
|
||||
Uint32 *dst32 = (Uint32*)dst;
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
if ((*src32 & rgbmask) != ckey) {
|
||||
|
|
@ -2948,7 +2948,7 @@ BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info)
|
|||
++dst32;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src32 = (Uint32 *)((Uint8 *)src32 + srcskip);
|
||||
dst32 = (Uint32 *)((Uint8 *)dst32 + dstskip);
|
||||
}
|
||||
|
|
@ -2967,7 +2967,7 @@ BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info)
|
|||
get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, NULL);
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint32 *src32 = (Uint32*)src;
|
||||
|
|
@ -2980,7 +2980,7 @@ BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info)
|
|||
src += 4;
|
||||
dst += 4;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -2989,7 +2989,7 @@ BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info)
|
|||
#endif
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
|
||||
|
|
@ -3000,7 +3000,7 @@ BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info)
|
|||
src += srcbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -3022,7 +3022,7 @@ Blit2101010toN(SDL_BlitInfo * info)
|
|||
unsigned sR, sG, sB, sA;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Pixel = *(Uint32 *)src;
|
||||
|
|
@ -3032,7 +3032,7 @@ Blit2101010toN(SDL_BlitInfo * info)
|
|||
src += 4;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -3054,7 +3054,7 @@ BlitNto2101010(SDL_BlitInfo * info)
|
|||
unsigned sR, sG, sB, sA;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
|
||||
|
|
@ -3064,7 +3064,7 @@ BlitNto2101010(SDL_BlitInfo * info)
|
|||
src += srcbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -3096,7 +3096,7 @@ Blit_3or4_to_3or4__same_rgb(SDL_BlitInfo * info)
|
|||
int i2 = srcbpp - 1 - 2;
|
||||
#endif
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint32 *dst32 = (Uint32*)dst;
|
||||
|
|
@ -3107,7 +3107,7 @@ Blit_3or4_to_3or4__same_rgb(SDL_BlitInfo * info)
|
|||
dst += 4;
|
||||
src += srcbpp;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -3125,7 +3125,7 @@ Blit_3or4_to_3or4__same_rgb(SDL_BlitInfo * info)
|
|||
int j2 = dstbpp - 1 - 2;
|
||||
#endif
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint8 s0 = src[i0];
|
||||
|
|
@ -3137,7 +3137,7 @@ Blit_3or4_to_3or4__same_rgb(SDL_BlitInfo * info)
|
|||
dst += dstbpp;
|
||||
src += srcbpp;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -3169,7 +3169,7 @@ Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo * info)
|
|||
#else
|
||||
int i0 = 3, i1 = 2, i2 = 1, i3 = 0;
|
||||
#endif
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint32 *dst32 = (Uint32*)dst;
|
||||
|
|
@ -3182,7 +3182,7 @@ Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo * info)
|
|||
dst += 4;
|
||||
src += 4;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -3197,7 +3197,7 @@ Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo * info)
|
|||
int i2 = srcbpp - 1 - 2;
|
||||
#endif
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint32 *dst32 = (Uint32*)dst;
|
||||
|
|
@ -3209,7 +3209,7 @@ Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo * info)
|
|||
dst += 4;
|
||||
src += srcbpp;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
@ -3228,7 +3228,7 @@ Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo * info)
|
|||
int j2 = dstbpp - 1 - 0;
|
||||
#endif
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint8 s0 = src[i0];
|
||||
|
|
@ -3241,7 +3241,7 @@ Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo * info)
|
|||
dst += dstbpp;
|
||||
src += srcbpp;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#if SDL_HAVE_BLIT_AUTO
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_blit.h"
|
||||
|
|
@ -7014,7 +7014,7 @@ SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
|
|||
{ 0, 0, 0, 0, NULL }
|
||||
};
|
||||
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
|
||||
#endif /* SDL_HAVE_BLIT_AUTO */
|
||||
|
||||
|
|
|
|||
|
|
@ -1250,10 +1250,12 @@ EGLSurface
|
|||
SDL_EGL_CreateOffscreenSurface(_THIS, int width, int height)
|
||||
{
|
||||
EGLint attributes[] = {
|
||||
EGL_WIDTH, width,
|
||||
EGL_HEIGHT, height,
|
||||
EGL_WIDTH, 0,
|
||||
EGL_HEIGHT, 0,
|
||||
EGL_NONE
|
||||
};
|
||||
attributes[1] = width;
|
||||
attributes[3] = height;
|
||||
|
||||
if (SDL_EGL_ChooseConfig(_this) != 0) {
|
||||
return EGL_NO_SURFACE;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
|
||||
#ifdef __SSE__
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#define SSE_BEGIN \
|
||||
|
|
@ -128,7 +128,7 @@ SDL_FillRect1SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h)
|
|||
DEFINE_SSE_FILLRECT(2, Uint16)
|
||||
DEFINE_SSE_FILLRECT(4, Uint32)
|
||||
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
#endif /* __SSE__ */
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -237,6 +237,7 @@ struct SDL_VideoDevice
|
|||
int (*SetWindowGammaRamp) (_THIS, SDL_Window * window, const Uint16 * ramp);
|
||||
int (*GetWindowGammaRamp) (_THIS, SDL_Window * window, Uint16 * ramp);
|
||||
void* (*GetWindowICCProfile) (_THIS, SDL_Window * window, size_t* size);
|
||||
int (*GetWindowDisplayIndex)(_THIS, SDL_Window * window);
|
||||
void (*SetWindowMouseRect)(_THIS, SDL_Window * window);
|
||||
void (*SetWindowMouseGrab) (_THIS, SDL_Window * window, SDL_bool grabbed);
|
||||
void (*SetWindowKeyboardGrab) (_THIS, SDL_Window * window, SDL_bool grabbed);
|
||||
|
|
@ -332,6 +333,7 @@ struct SDL_VideoDevice
|
|||
|
||||
/* * * */
|
||||
/* Data common to all drivers */
|
||||
SDL_threadID thread;
|
||||
SDL_bool checked_texture_framebuffer;
|
||||
SDL_bool is_dummy;
|
||||
SDL_bool suspend_screensaver;
|
||||
|
|
@ -456,9 +458,12 @@ extern VideoBootStrap VIVANTE_bootstrap;
|
|||
extern VideoBootStrap Emscripten_bootstrap;
|
||||
extern VideoBootStrap QNX_bootstrap;
|
||||
extern VideoBootStrap OFFSCREEN_bootstrap;
|
||||
extern VideoBootStrap NGAGE_bootstrap;
|
||||
extern VideoBootStrap OS2DIVE_bootstrap;
|
||||
extern VideoBootStrap OS2VMAN_bootstrap;
|
||||
|
||||
/* Use SDL_OnVideoThread() sparingly, to avoid regressions in use cases that currently happen to work */
|
||||
extern SDL_bool SDL_OnVideoThread(void);
|
||||
extern SDL_VideoDevice *SDL_GetVideoDevice(void);
|
||||
extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
|
||||
extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display, SDL_bool send_event);
|
||||
|
|
@ -472,6 +477,7 @@ extern SDL_VideoDisplay *SDL_GetDisplay(int displayIndex);
|
|||
extern SDL_VideoDisplay *SDL_GetDisplayForWindow(SDL_Window *window);
|
||||
extern void *SDL_GetDisplayDriverData( int displayIndex );
|
||||
extern SDL_bool SDL_IsVideoContextExternal(void);
|
||||
extern int SDL_GetMessageBoxCount(void);
|
||||
|
||||
extern void SDL_GL_DeduceMaxSupportedESProfile(int* major, int* minor);
|
||||
|
||||
|
|
|
|||
|
|
@ -118,6 +118,9 @@ static VideoBootStrap *bootstrap[] = {
|
|||
#if SDL_VIDEO_DRIVER_OFFSCREEN
|
||||
&OFFSCREEN_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_NGAGE
|
||||
&NGAGE_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_OS2
|
||||
&OS2DIVE_bootstrap,
|
||||
&OS2VMAN_bootstrap,
|
||||
|
|
@ -288,6 +291,7 @@ SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window * window, Uint32 * fo
|
|||
}
|
||||
|
||||
static SDL_VideoDevice *_this = NULL;
|
||||
static SDL_atomic_t SDL_messagebox_count;
|
||||
|
||||
static int
|
||||
SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window * window, const SDL_Rect * rects, int numrects)
|
||||
|
|
@ -338,7 +342,7 @@ SDL_DestroyWindowTexture(SDL_VideoDevice *unused, SDL_Window * window)
|
|||
SDL_free(data);
|
||||
}
|
||||
|
||||
static int
|
||||
static int SDLCALL
|
||||
cmpmodes(const void *A, const void *B)
|
||||
{
|
||||
const SDL_DisplayMode *a = (const SDL_DisplayMode *) A;
|
||||
|
|
@ -466,6 +470,7 @@ SDL_VideoInit(const char *driver_name)
|
|||
_this = video;
|
||||
_this->name = bootstrap[i]->name;
|
||||
_this->next_object_id = 1;
|
||||
_this->thread = SDL_ThreadID();
|
||||
|
||||
|
||||
/* Set some very sane GL defaults */
|
||||
|
|
@ -545,6 +550,12 @@ SDL_GetVideoDevice(void)
|
|||
return _this;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_OnVideoThread()
|
||||
{
|
||||
return (_this && SDL_ThreadID() == _this->thread) ? SDL_TRUE : SDL_FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode)
|
||||
{
|
||||
|
|
@ -1060,61 +1071,64 @@ SDL_GetDisplay(int displayIndex)
|
|||
int
|
||||
SDL_GetWindowDisplayIndex(SDL_Window * window)
|
||||
{
|
||||
int displayIndex;
|
||||
int i, dist;
|
||||
int closest = -1;
|
||||
int closest_dist = 0x7FFFFFFF;
|
||||
SDL_Point center;
|
||||
SDL_Point delta;
|
||||
SDL_Rect rect;
|
||||
|
||||
CHECK_WINDOW_MAGIC(window, -1);
|
||||
if (_this->GetWindowDisplayIndex) {
|
||||
return _this->GetWindowDisplayIndex(_this, window);
|
||||
} else {
|
||||
int displayIndex;
|
||||
int i, dist;
|
||||
int closest = -1;
|
||||
int closest_dist = 0x7FFFFFFF;
|
||||
SDL_Point center;
|
||||
SDL_Point delta;
|
||||
SDL_Rect rect;
|
||||
|
||||
if (SDL_WINDOWPOS_ISUNDEFINED(window->x) ||
|
||||
SDL_WINDOWPOS_ISCENTERED(window->x)) {
|
||||
displayIndex = (window->x & 0xFFFF);
|
||||
if (displayIndex >= _this->num_displays) {
|
||||
displayIndex = 0;
|
||||
if (SDL_WINDOWPOS_ISUNDEFINED(window->x) ||
|
||||
SDL_WINDOWPOS_ISCENTERED(window->x)) {
|
||||
displayIndex = (window->x & 0xFFFF);
|
||||
if (displayIndex >= _this->num_displays) {
|
||||
displayIndex = 0;
|
||||
}
|
||||
return displayIndex;
|
||||
}
|
||||
return displayIndex;
|
||||
}
|
||||
if (SDL_WINDOWPOS_ISUNDEFINED(window->y) ||
|
||||
SDL_WINDOWPOS_ISCENTERED(window->y)) {
|
||||
displayIndex = (window->y & 0xFFFF);
|
||||
if (displayIndex >= _this->num_displays) {
|
||||
displayIndex = 0;
|
||||
}
|
||||
return displayIndex;
|
||||
}
|
||||
|
||||
/* Find the display containing the window */
|
||||
for (i = 0; i < _this->num_displays; ++i) {
|
||||
SDL_VideoDisplay *display = &_this->displays[i];
|
||||
|
||||
if (display->fullscreen_window == window) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
center.x = window->x + window->w / 2;
|
||||
center.y = window->y + window->h / 2;
|
||||
for (i = 0; i < _this->num_displays; ++i) {
|
||||
SDL_GetDisplayBounds(i, &rect);
|
||||
if (SDL_EnclosePoints(¢er, 1, &rect, NULL)) {
|
||||
return i;
|
||||
if (SDL_WINDOWPOS_ISUNDEFINED(window->y) ||
|
||||
SDL_WINDOWPOS_ISCENTERED(window->y)) {
|
||||
displayIndex = (window->y & 0xFFFF);
|
||||
if (displayIndex >= _this->num_displays) {
|
||||
displayIndex = 0;
|
||||
}
|
||||
return displayIndex;
|
||||
}
|
||||
|
||||
delta.x = center.x - (rect.x + rect.w / 2);
|
||||
delta.y = center.y - (rect.y + rect.h / 2);
|
||||
dist = (delta.x*delta.x + delta.y*delta.y);
|
||||
if (dist < closest_dist) {
|
||||
closest = i;
|
||||
closest_dist = dist;
|
||||
/* Find the display containing the window */
|
||||
for (i = 0; i < _this->num_displays; ++i) {
|
||||
SDL_VideoDisplay *display = &_this->displays[i];
|
||||
|
||||
if (display->fullscreen_window == window) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
center.x = window->x + window->w / 2;
|
||||
center.y = window->y + window->h / 2;
|
||||
for (i = 0; i < _this->num_displays; ++i) {
|
||||
SDL_GetDisplayBounds(i, &rect);
|
||||
if (SDL_EnclosePoints(¢er, 1, &rect, NULL)) {
|
||||
return i;
|
||||
}
|
||||
|
||||
delta.x = center.x - (rect.x + rect.w / 2);
|
||||
delta.y = center.y - (rect.y + rect.h / 2);
|
||||
dist = (delta.x*delta.x + delta.y*delta.y);
|
||||
if (dist < closest_dist) {
|
||||
closest = i;
|
||||
closest_dist = dist;
|
||||
}
|
||||
}
|
||||
if (closest < 0) {
|
||||
SDL_SetError("Couldn't find any displays");
|
||||
}
|
||||
return closest;
|
||||
}
|
||||
if (closest < 0) {
|
||||
SDL_SetError("Couldn't find any displays");
|
||||
}
|
||||
return closest;
|
||||
}
|
||||
|
||||
SDL_VideoDisplay *
|
||||
|
|
@ -2503,6 +2517,14 @@ SDL_CreateWindowFramebuffer(SDL_Window * window)
|
|||
if (!_this->checked_texture_framebuffer) {
|
||||
SDL_bool attempt_texture_framebuffer = SDL_TRUE;
|
||||
|
||||
/* See if the user or application wants to specifically disable the framebuffer */
|
||||
const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION);
|
||||
if (hint) {
|
||||
if (*hint == '0' || SDL_strcasecmp(hint, "false") == 0) {
|
||||
attempt_texture_framebuffer = SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (_this->is_dummy) { /* dummy driver never has GPU support, of course. */
|
||||
attempt_texture_framebuffer = SDL_FALSE;
|
||||
}
|
||||
|
|
@ -3024,7 +3046,7 @@ SDL_OnWindowFocusGained(SDL_Window * window)
|
|||
if (mouse && mouse->relative_mode) {
|
||||
SDL_SetMouseFocus(window);
|
||||
if (mouse->relative_mode_warp) {
|
||||
SDL_WarpMouseInWindow(window, window->w/2, window->h/2);
|
||||
SDL_PerformWarpMouseInWindow(window, window->w/2, window->h/2, SDL_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4257,6 +4279,12 @@ SDL_IsScreenKeyboardShown(SDL_Window *window)
|
|||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_GetMessageBoxCount(void)
|
||||
{
|
||||
return SDL_AtomicGet(&SDL_messagebox_count);
|
||||
}
|
||||
|
||||
#if SDL_VIDEO_DRIVER_ANDROID
|
||||
#include "android/SDL_androidmessagebox.h"
|
||||
#endif
|
||||
|
|
@ -4317,7 +4345,6 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
|||
int retval = -1;
|
||||
SDL_bool relative_mode;
|
||||
int show_cursor_prev;
|
||||
SDL_bool mouse_captured;
|
||||
SDL_Window *current_window;
|
||||
SDL_MessageBoxData mbdata;
|
||||
|
||||
|
|
@ -4327,10 +4354,11 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
|||
return SDL_SetError("Invalid number of buttons");
|
||||
}
|
||||
|
||||
(void)SDL_AtomicIncRef(&SDL_messagebox_count);
|
||||
|
||||
current_window = SDL_GetKeyboardFocus();
|
||||
mouse_captured = current_window && ((SDL_GetWindowFlags(current_window) & SDL_WINDOW_MOUSE_CAPTURE) != 0);
|
||||
relative_mode = SDL_GetRelativeMouseMode();
|
||||
SDL_CaptureMouse(SDL_FALSE);
|
||||
SDL_UpdateMouseCapture(SDL_FALSE);
|
||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
show_cursor_prev = SDL_ShowCursor(1);
|
||||
SDL_ResetKeyboard();
|
||||
|
|
@ -4434,15 +4462,15 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
|||
}
|
||||
}
|
||||
|
||||
(void)SDL_AtomicDecRef(&SDL_messagebox_count);
|
||||
|
||||
if (current_window) {
|
||||
SDL_RaiseWindow(current_window);
|
||||
if (mouse_captured) {
|
||||
SDL_CaptureMouse(SDL_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_ShowCursor(show_cursor_prev);
|
||||
SDL_SetRelativeMouseMode(relative_mode);
|
||||
SDL_UpdateMouseCapture(SDL_FALSE);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,12 +41,12 @@ void Android_InitKeyboard(void)
|
|||
|
||||
static SDL_Scancode Android_Keycodes[] = {
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_UNKNOWN */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_LEFT */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_RIGHT */
|
||||
SDL_SCANCODE_SOFTLEFT, /* AKEYCODE_SOFT_LEFT */
|
||||
SDL_SCANCODE_SOFTRIGHT, /* AKEYCODE_SOFT_RIGHT */
|
||||
SDL_SCANCODE_AC_HOME, /* AKEYCODE_HOME */
|
||||
SDL_SCANCODE_AC_BACK, /* AKEYCODE_BACK */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CALL */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ENDCALL */
|
||||
SDL_SCANCODE_CALL, /* AKEYCODE_CALL */
|
||||
SDL_SCANCODE_ENDCALL, /* AKEYCODE_ENDCALL */
|
||||
SDL_SCANCODE_0, /* AKEYCODE_0 */
|
||||
SDL_SCANCODE_1, /* AKEYCODE_1 */
|
||||
SDL_SCANCODE_2, /* AKEYCODE_2 */
|
||||
|
|
|
|||
|
|
@ -24,12 +24,12 @@
|
|||
#define SDL_cocoaclipboard_h_
|
||||
|
||||
/* Forward declaration */
|
||||
struct SDL_VideoData;
|
||||
@class SDL_VideoData;
|
||||
|
||||
extern int Cocoa_SetClipboardText(_THIS, const char *text);
|
||||
extern char *Cocoa_GetClipboardText(_THIS);
|
||||
extern SDL_bool Cocoa_HasClipboardText(_THIS);
|
||||
extern void Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data);
|
||||
extern void Cocoa_CheckClipboardUpdate(SDL_VideoData * data);
|
||||
|
||||
#endif /* SDL_cocoaclipboard_h_ */
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ int
|
|||
Cocoa_SetClipboardText(_THIS, const char *text)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata;
|
||||
NSPasteboard *pasteboard;
|
||||
NSString *format = NSPasteboardTypeString;
|
||||
NSString *nsstr = [NSString stringWithUTF8String:text];
|
||||
|
|
@ -38,7 +38,7 @@ Cocoa_SetClipboardText(_THIS, const char *text)
|
|||
}
|
||||
|
||||
pasteboard = [NSPasteboard generalPasteboard];
|
||||
data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
|
||||
data.clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
|
||||
[pasteboard setString:nsstr forType:format];
|
||||
|
||||
return 0;
|
||||
|
|
@ -86,7 +86,7 @@ Cocoa_HasClipboardText(_THIS)
|
|||
}
|
||||
|
||||
void
|
||||
Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
|
||||
Cocoa_CheckClipboardUpdate(SDL_VideoData * data)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSPasteboard *pasteboard;
|
||||
|
|
@ -94,11 +94,11 @@ Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
|
|||
|
||||
pasteboard = [NSPasteboard generalPasteboard];
|
||||
count = [pasteboard changeCount];
|
||||
if (count != data->clipboard_count) {
|
||||
if (data->clipboard_count) {
|
||||
if (count != data.clipboard_count) {
|
||||
if (data.clipboard_count) {
|
||||
SDL_SendClipboardUpdate();
|
||||
}
|
||||
data->clipboard_count = count;
|
||||
data.clipboard_count = count;
|
||||
}
|
||||
}}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ static SDL_Window *FindSDLWindowForNSWindow(NSWindow *win)
|
|||
SDL_VideoDevice *device = SDL_GetVideoDevice();
|
||||
if (device && device->windows) {
|
||||
for (sdlwindow = device->windows; sdlwindow; sdlwindow = sdlwindow->next) {
|
||||
NSWindow *nswindow = ((SDL_WindowData *) sdlwindow->driverdata)->nswindow;
|
||||
NSWindow *nswindow = ((__bridge SDL_WindowData *) sdlwindow->driverdata).nswindow;
|
||||
if (win == nswindow)
|
||||
return sdlwindow;
|
||||
}
|
||||
|
|
@ -121,7 +121,6 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
|
|||
[NSNumber numberWithBool:YES], @"ApplePersistenceIgnoreState",
|
||||
nil];
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
|
||||
[appDefaults release];
|
||||
}
|
||||
|
||||
@end // SDLApplication
|
||||
|
|
@ -182,8 +181,6 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
|
|||
removeEventHandlerForEventClass:kInternetEventClass
|
||||
andEventID:kAEGetURL];
|
||||
}
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)windowWillClose:(NSNotification *)notification;
|
||||
|
|
@ -374,9 +371,6 @@ CreateApplicationMenus(void)
|
|||
/* Create the main menu bar */
|
||||
[NSApp setMainMenu:mainMenu];
|
||||
|
||||
[mainMenu release]; /* we're done with it, let NSApp own it. */
|
||||
mainMenu = nil;
|
||||
|
||||
/* Create the application menu */
|
||||
appName = GetApplicationName();
|
||||
appleMenu = [[NSMenu alloc] initWithTitle:@""];
|
||||
|
|
@ -396,7 +390,6 @@ CreateApplicationMenus(void)
|
|||
[menuItem setSubmenu:serviceMenu];
|
||||
|
||||
[NSApp setServicesMenu:serviceMenu];
|
||||
[serviceMenu release];
|
||||
|
||||
[appleMenu addItem:[NSMenuItem separatorItem]];
|
||||
|
||||
|
|
@ -417,12 +410,9 @@ CreateApplicationMenus(void)
|
|||
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
|
||||
[menuItem setSubmenu:appleMenu];
|
||||
[[NSApp mainMenu] addItem:menuItem];
|
||||
[menuItem release];
|
||||
|
||||
/* Tell the application object that this is now the application menu */
|
||||
[NSApp setAppleMenu:appleMenu];
|
||||
[appleMenu release];
|
||||
|
||||
|
||||
/* Create the window menu */
|
||||
windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
|
||||
|
|
@ -434,26 +424,21 @@ CreateApplicationMenus(void)
|
|||
|
||||
[windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""];
|
||||
|
||||
/* Add the fullscreen toggle menu option, if supported */
|
||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
|
||||
/* Cocoa should update the title to Enter or Exit Full Screen automatically.
|
||||
* But if not, then just fallback to Toggle Full Screen.
|
||||
*/
|
||||
menuItem = [[NSMenuItem alloc] initWithTitle:@"Toggle Full Screen" action:@selector(toggleFullScreen:) keyEquivalent:@"f"];
|
||||
[menuItem setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand];
|
||||
[windowMenu addItem:menuItem];
|
||||
[menuItem release];
|
||||
}
|
||||
/* Add the fullscreen toggle menu option. */
|
||||
/* Cocoa should update the title to Enter or Exit Full Screen automatically.
|
||||
* But if not, then just fallback to Toggle Full Screen.
|
||||
*/
|
||||
menuItem = [[NSMenuItem alloc] initWithTitle:@"Toggle Full Screen" action:@selector(toggleFullScreen:) keyEquivalent:@"f"];
|
||||
[menuItem setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand];
|
||||
[windowMenu addItem:menuItem];
|
||||
|
||||
/* Put menu into the menubar */
|
||||
menuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
|
||||
[menuItem setSubmenu:windowMenu];
|
||||
[[NSApp mainMenu] addItem:menuItem];
|
||||
[menuItem release];
|
||||
|
||||
/* Tell the application object that this is now the window menu */
|
||||
[NSApp setWindowsMenu:windowMenu];
|
||||
[windowMenu release];
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -518,19 +503,6 @@ Cocoa_RegisterApp(void)
|
|||
int
|
||||
Cocoa_PumpEventsUntilDate(_THIS, NSDate *expiration, bool accumulate)
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
|
||||
/* Update activity every 30 seconds to prevent screensaver */
|
||||
SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
|
||||
if (_this->suspend_screensaver && !data->screensaver_use_iopm) {
|
||||
Uint32 now = SDL_GetTicks();
|
||||
if (!data->screensaver_activity ||
|
||||
SDL_TICKS_PASSED(now, data->screensaver_activity + 30000)) {
|
||||
UpdateSystemActivity(UsrActivity);
|
||||
data->screensaver_activity = now;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for ( ; ; ) {
|
||||
NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:expiration inMode:NSDefaultRunLoopMode dequeue:YES ];
|
||||
if ( event == nil ) {
|
||||
|
|
@ -576,7 +548,7 @@ Cocoa_PumpEvents(_THIS)
|
|||
void Cocoa_SendWakeupEvent(_THIS, SDL_Window *window)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||
NSWindow *nswindow = ((__bridge SDL_WindowData *) window->driverdata).nswindow;
|
||||
|
||||
NSEvent* event = [NSEvent otherEventWithType: NSEventTypeApplicationDefined
|
||||
location: NSMakePoint(0,0)
|
||||
|
|
@ -595,15 +567,11 @@ void
|
|||
Cocoa_SuspendScreenSaver(_THIS)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
|
||||
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata;
|
||||
|
||||
if (!data->screensaver_use_iopm) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (data->screensaver_assertion) {
|
||||
IOPMAssertionRelease(data->screensaver_assertion);
|
||||
data->screensaver_assertion = 0;
|
||||
if (data.screensaver_assertion) {
|
||||
IOPMAssertionRelease(data.screensaver_assertion);
|
||||
data.screensaver_assertion = kIOPMNullAssertionID;
|
||||
}
|
||||
|
||||
if (_this->suspend_screensaver) {
|
||||
|
|
@ -612,11 +580,13 @@ Cocoa_SuspendScreenSaver(_THIS)
|
|||
* seen by OS X power users. there's an additional optional human-readable
|
||||
* (localized) reason parameter which we don't set.
|
||||
*/
|
||||
IOPMAssertionID assertion = kIOPMNullAssertionID;
|
||||
NSString *name = [GetApplicationName() stringByAppendingString:@" using SDL_DisableScreenSaver"];
|
||||
IOPMAssertionCreateWithDescription(kIOPMAssertPreventUserIdleDisplaySleep,
|
||||
(CFStringRef) name,
|
||||
(__bridge CFStringRef) name,
|
||||
NULL, NULL, NULL, 0, NULL,
|
||||
&data->screensaver_assertion);
|
||||
&assertion);
|
||||
data.screensaver_assertion = assertion;
|
||||
}
|
||||
}}
|
||||
|
||||
|
|
|
|||
|
|
@ -104,8 +104,7 @@
|
|||
}
|
||||
|
||||
if (_markedText != aString) {
|
||||
[_markedText release];
|
||||
_markedText = [aString retain];
|
||||
_markedText = aString;
|
||||
}
|
||||
|
||||
_selectedRange = selectedRange;
|
||||
|
|
@ -120,7 +119,6 @@
|
|||
|
||||
- (void)unmarkText
|
||||
{
|
||||
[_markedText release];
|
||||
_markedText = nil;
|
||||
|
||||
SDL_SendEditingText("", 0, 0);
|
||||
|
|
@ -142,14 +140,7 @@
|
|||
aRange.location, aRange.length, windowHeight,
|
||||
NSStringFromRect(rect));
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
|
||||
if (![window respondsToSelector:@selector(convertRectToScreen:)]) {
|
||||
rect.origin = [window convertBaseToScreen:rect.origin];
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
rect = [window convertRectToScreen:rect];
|
||||
}
|
||||
rect = [window convertRectToScreen:rect];
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
|
@ -381,14 +372,14 @@ DoSidedModifiers(unsigned short scancode,
|
|||
static void
|
||||
HandleModifiers(_THIS, unsigned short scancode, unsigned int modifierFlags)
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata;
|
||||
|
||||
if (modifierFlags == data->modifierFlags) {
|
||||
if (modifierFlags == data.modifierFlags) {
|
||||
return;
|
||||
}
|
||||
|
||||
DoSidedModifiers(scancode, data->modifierFlags, modifierFlags);
|
||||
data->modifierFlags = modifierFlags;
|
||||
DoSidedModifiers(scancode, data.modifierFlags, modifierFlags);
|
||||
data.modifierFlags = modifierFlags;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -402,10 +393,10 @@ UpdateKeymap(SDL_VideoData *data, SDL_bool send_event)
|
|||
|
||||
/* See if the keymap needs to be updated */
|
||||
key_layout = TISCopyCurrentKeyboardLayoutInputSource();
|
||||
if (key_layout == data->key_layout) {
|
||||
if (key_layout == data.key_layout) {
|
||||
return;
|
||||
}
|
||||
data->key_layout = key_layout;
|
||||
data.key_layout = key_layout;
|
||||
|
||||
SDL_GetDefaultKeymap(keymap);
|
||||
|
||||
|
|
@ -461,7 +452,7 @@ cleanup:
|
|||
void
|
||||
Cocoa_InitKeyboard(_THIS)
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata;
|
||||
|
||||
UpdateKeymap(data, SDL_FALSE);
|
||||
|
||||
|
|
@ -473,19 +464,19 @@ Cocoa_InitKeyboard(_THIS)
|
|||
SDL_SetScancodeName(SDL_SCANCODE_RALT, "Right Option");
|
||||
SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Command");
|
||||
|
||||
data->modifierFlags = (unsigned int)[NSEvent modifierFlags];
|
||||
SDL_ToggleModState(KMOD_CAPS, (data->modifierFlags & NSEventModifierFlagCapsLock) != 0);
|
||||
data.modifierFlags = (unsigned int)[NSEvent modifierFlags];
|
||||
SDL_ToggleModState(KMOD_CAPS, (data.modifierFlags & NSEventModifierFlagCapsLock) != 0);
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_StartTextInput(_THIS)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata;
|
||||
SDL_Window *window = SDL_GetKeyboardFocus();
|
||||
NSWindow *nswindow = nil;
|
||||
if (window) {
|
||||
nswindow = ((SDL_WindowData*)window->driverdata)->nswindow;
|
||||
nswindow = ((__bridge SDL_WindowData*)window->driverdata).nswindow;
|
||||
}
|
||||
|
||||
NSView *parentView = [nswindow contentView];
|
||||
|
|
@ -495,16 +486,16 @@ Cocoa_StartTextInput(_THIS)
|
|||
* than one copy. When we switched to another window and requesting for
|
||||
* text input, simply remove the field editor from its superview then add
|
||||
* it to the front most window's content view */
|
||||
if (!data->fieldEdit) {
|
||||
data->fieldEdit =
|
||||
if (!data.fieldEdit) {
|
||||
data.fieldEdit =
|
||||
[[SDLTranslatorResponder alloc] initWithFrame: NSMakeRect(0.0, 0.0, 0.0, 0.0)];
|
||||
}
|
||||
|
||||
if (![[data->fieldEdit superview] isEqual:parentView]) {
|
||||
if (![[data.fieldEdit superview] isEqual:parentView]) {
|
||||
/* DEBUG_IME(@"add fieldEdit to window contentView"); */
|
||||
[data->fieldEdit removeFromSuperview];
|
||||
[parentView addSubview: data->fieldEdit];
|
||||
[nswindow makeFirstResponder: data->fieldEdit];
|
||||
[data.fieldEdit removeFromSuperview];
|
||||
[parentView addSubview: data.fieldEdit];
|
||||
[nswindow makeFirstResponder: data.fieldEdit];
|
||||
}
|
||||
}}
|
||||
|
||||
|
|
@ -512,32 +503,31 @@ void
|
|||
Cocoa_StopTextInput(_THIS)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata;
|
||||
|
||||
if (data && data->fieldEdit) {
|
||||
[data->fieldEdit removeFromSuperview];
|
||||
[data->fieldEdit release];
|
||||
data->fieldEdit = nil;
|
||||
if (data && data.fieldEdit) {
|
||||
[data.fieldEdit removeFromSuperview];
|
||||
data.fieldEdit = nil;
|
||||
}
|
||||
}}
|
||||
|
||||
void
|
||||
Cocoa_SetTextInputRect(_THIS, SDL_Rect *rect)
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata;
|
||||
|
||||
if (!rect) {
|
||||
SDL_InvalidParamError("rect");
|
||||
return;
|
||||
}
|
||||
|
||||
[data->fieldEdit setInputRect:rect];
|
||||
[data.fieldEdit setInputRect:rect];
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
|
||||
{
|
||||
SDL_VideoData *data = _this ? ((SDL_VideoData *) _this->driverdata) : NULL;
|
||||
SDL_VideoData *data = _this ? ((__bridge SDL_VideoData *) _this->driverdata) : nil;
|
||||
if (!data) {
|
||||
return; /* can happen when returning from fullscreen Space on shutdown */
|
||||
}
|
||||
|
|
@ -575,7 +565,7 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
|
|||
#endif
|
||||
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
|
||||
/* FIXME CW 2007-08-16: only send those events to the field editor for which we actually want text events, not e.g. esc or function keys. Arrow keys in particular seem to produce crashes sometimes. */
|
||||
[data->fieldEdit interpretKeyEvents:[NSArray arrayWithObject:event]];
|
||||
[data.fieldEdit interpretKeyEvents:[NSArray arrayWithObject:event]];
|
||||
#if 0
|
||||
text = [[event characters] UTF8String];
|
||||
if(text && *text) {
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@
|
|||
|
||||
/* Retain the NSWindow because we'll show the alert later on the main thread */
|
||||
if (window) {
|
||||
nswindow = [((SDL_WindowData *) window->driverdata)->nswindow retain];
|
||||
nswindow = ((__bridge SDL_WindowData *) window->driverdata).nswindow;
|
||||
} else {
|
||||
nswindow = NULL;
|
||||
nswindow = nil;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +60,7 @@
|
|||
#ifdef MAC_OS_X_VERSION_10_9
|
||||
if ([alert respondsToSelector:@selector(beginSheetModalForWindow:completionHandler:)]) {
|
||||
[alert beginSheetModalForWindow:nswindow completionHandler:^(NSModalResponse returnCode) {
|
||||
clicked = returnCode;
|
||||
self->clicked = returnCode;
|
||||
}];
|
||||
} else
|
||||
#endif
|
||||
|
|
@ -75,7 +75,7 @@
|
|||
SDL_Delay(100);
|
||||
}
|
||||
|
||||
[nswindow release];
|
||||
nswindow = nil;
|
||||
} else {
|
||||
clicked = [alert runModal];
|
||||
}
|
||||
|
|
@ -94,7 +94,7 @@ Cocoa_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid
|
|||
{
|
||||
Cocoa_RegisterApp();
|
||||
|
||||
NSAlert* alert = [[[NSAlert alloc] init] autorelease];
|
||||
NSAlert* alert = [[NSAlert alloc] init];
|
||||
|
||||
if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) {
|
||||
[alert setAlertStyle:NSAlertStyleCritical];
|
||||
|
|
@ -129,7 +129,7 @@ Cocoa_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid
|
|||
}
|
||||
}
|
||||
|
||||
SDLMessageBoxPresenter* presenter = [[[SDLMessageBoxPresenter alloc] initWithParentWindow:messageboxdata->window] autorelease];
|
||||
SDLMessageBoxPresenter* presenter = [[SDLMessageBoxPresenter alloc] initWithParentWindow:messageboxdata->window];
|
||||
|
||||
[presenter showAlert:alert];
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ SDL_MetalViewEventWatch(void *userdata, SDL_Event *event)
|
|||
/* Allow resize. */
|
||||
self.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
||||
|
||||
SDL_AddEventWatch(SDL_MetalViewEventWatch, self);
|
||||
SDL_AddEventWatch(SDL_MetalViewEventWatch, (__bridge void *)(self));
|
||||
|
||||
[self updateDrawableSize];
|
||||
}
|
||||
|
|
@ -99,8 +99,7 @@ SDL_MetalViewEventWatch(void *userdata, SDL_Event *event)
|
|||
|
||||
- (void)dealloc
|
||||
{
|
||||
SDL_DelEventWatch(SDL_MetalViewEventWatch, self);
|
||||
[super dealloc];
|
||||
SDL_DelEventWatch(SDL_MetalViewEventWatch, (__bridge void *)(self));
|
||||
}
|
||||
|
||||
- (NSInteger)tag
|
||||
|
|
@ -135,7 +134,7 @@ SDL_MetalView
|
|||
Cocoa_Metal_CreateView(_THIS, SDL_Window * window)
|
||||
{ @autoreleasepool {
|
||||
SDL_WindowData* data = (__bridge SDL_WindowData *)window->driverdata;
|
||||
NSView *view = data->nswindow.contentView;
|
||||
NSView *view = data.nswindow.contentView;
|
||||
BOOL highDPI = (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) != 0;
|
||||
Uint32 windowID = SDL_GetWindowID(window);
|
||||
SDL_cocoametalview *newview;
|
||||
|
|
@ -151,7 +150,6 @@ Cocoa_Metal_CreateView(_THIS, SDL_Window * window)
|
|||
[view addSubview:newview];
|
||||
|
||||
metalview = (SDL_MetalView)CFBridgingRetain(newview);
|
||||
[newview release];
|
||||
|
||||
return metalview;
|
||||
}}
|
||||
|
|
@ -174,7 +172,7 @@ void
|
|||
Cocoa_Metal_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
|
||||
{ @autoreleasepool {
|
||||
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
|
||||
NSView *contentView = data->sdlContentView;
|
||||
NSView *contentView = data.sdlContentView;
|
||||
SDL_cocoametalview* metalview = [contentView viewWithTag:SDL_METALVIEW_TAG];
|
||||
if (metalview) {
|
||||
CAMetalLayer *layer = (CAMetalLayer*)metalview.layer;
|
||||
|
|
@ -189,11 +187,8 @@ Cocoa_Metal_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
|
|||
/* Fall back to the viewport size. */
|
||||
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. */
|
||||
viewport = [contentView convertRectToBacking:viewport];
|
||||
}
|
||||
if (w) {
|
||||
*w = viewport.size.width;
|
||||
|
|
|
|||
|
|
@ -31,9 +31,6 @@
|
|||
#include <CoreVideo/CVBase.h>
|
||||
#include <CoreVideo/CVDisplayLink.h>
|
||||
|
||||
/* we need this for ShowMenuBar() and HideMenuBar(). */
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
/* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */
|
||||
#include <AvailabilityMacros.h>
|
||||
|
||||
|
|
@ -45,23 +42,6 @@
|
|||
#endif
|
||||
|
||||
|
||||
static void
|
||||
Cocoa_ToggleMenuBar(const BOOL show)
|
||||
{
|
||||
/* !!! FIXME: keep an eye on this.
|
||||
* ShowMenuBar/HideMenuBar is officially unavailable for 64-bit binaries.
|
||||
* It happens to work, as of 10.7, but we're going to see if
|
||||
* we can just simply do without it on newer OSes...
|
||||
*/
|
||||
#if (MAC_OS_X_VERSION_MIN_REQUIRED < 1070) && !defined(__LP64__)
|
||||
if (show) {
|
||||
ShowMenuBar();
|
||||
} else {
|
||||
HideMenuBar();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
CG_SetError(const char *prefix, CGDisplayErr result)
|
||||
{
|
||||
|
|
@ -306,7 +286,7 @@ Cocoa_GetDisplayName(CGDirectDisplayID displayID)
|
|||
/* This API is deprecated in 10.9 with no good replacement (as of 10.15). */
|
||||
io_service_t servicePort = CGDisplayIOServicePort(displayID);
|
||||
CFDictionaryRef deviceInfo = IODisplayCreateInfoDictionary(servicePort, kIODisplayOnlyPreferredName);
|
||||
NSDictionary *localizedNames = [(NSDictionary *)deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]];
|
||||
NSDictionary *localizedNames = [(__bridge NSDictionary *)deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]];
|
||||
const char* displayName = NULL;
|
||||
|
||||
if ([localizedNames count] > 0) {
|
||||
|
|
@ -497,7 +477,7 @@ Cocoa_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdp
|
|||
CFRelease(dmOptions);
|
||||
} else
|
||||
#endif
|
||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
|
||||
{
|
||||
// fallback for 10.7
|
||||
scaleFactor = [screen backingScaleFactor];
|
||||
displayNativeSize.width = displayNativeSize.width * scaleFactor;
|
||||
|
|
@ -646,10 +626,6 @@ Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
|||
} else {
|
||||
CGDisplayRelease(displaydata->display);
|
||||
}
|
||||
|
||||
if (CGDisplayIsMain(displaydata->display)) {
|
||||
Cocoa_ToggleMenuBar(YES);
|
||||
}
|
||||
} else {
|
||||
/* Put up the blanking window (a window above all other windows) */
|
||||
if (CGDisplayIsMain(displaydata->display)) {
|
||||
|
|
@ -669,11 +645,6 @@ Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
|||
CG_SetError("CGDisplaySwitchToMode()", result);
|
||||
goto ERR_NO_SWITCH;
|
||||
}
|
||||
|
||||
/* Hide the menu bar so it doesn't intercept events */
|
||||
if (CGDisplayIsMain(displaydata->display)) {
|
||||
Cocoa_ToggleMenuBar(NO);
|
||||
}
|
||||
}
|
||||
|
||||
/* Fade in again (asynchronously) */
|
||||
|
|
@ -720,7 +691,6 @@ Cocoa_QuitModes(_THIS)
|
|||
CFRelease(mode->modes);
|
||||
}
|
||||
}
|
||||
Cocoa_ToggleMenuBar(YES);
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_COCOA */
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
NSData *cursorData = [NSData dataWithBytesNoCopy:&cursorBytes[0]
|
||||
length:sizeof(cursorBytes)
|
||||
freeWhenDone:NO];
|
||||
NSImage *cursorImage = [[[NSImage alloc] initWithData:cursorData] autorelease];
|
||||
NSImage *cursorImage = [[NSImage alloc] initWithData:cursorData];
|
||||
invisibleCursor = [[NSCursor alloc] initWithImage:cursorImage
|
||||
hotSpot:NSZeroPoint];
|
||||
}
|
||||
|
|
@ -75,8 +75,7 @@ Cocoa_CreateDefaultCursor()
|
|||
if (nscursor) {
|
||||
cursor = SDL_calloc(1, sizeof(*cursor));
|
||||
if (cursor) {
|
||||
cursor->driverdata = nscursor;
|
||||
[nscursor retain];
|
||||
cursor->driverdata = (void *)CFBridgingRetain(nscursor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -99,15 +98,52 @@ Cocoa_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
|||
if (nscursor) {
|
||||
cursor = SDL_calloc(1, sizeof(*cursor));
|
||||
if (cursor) {
|
||||
cursor->driverdata = nscursor;
|
||||
} else {
|
||||
[nscursor release];
|
||||
cursor->driverdata = (void *)CFBridgingRetain(nscursor);
|
||||
}
|
||||
}
|
||||
|
||||
return cursor;
|
||||
}}
|
||||
|
||||
/* there are .pdf files of some of the cursors we need, installed by default on macOS, but not available through NSCursor.
|
||||
If we can load them ourselves, use them, otherwise fallback to something standard but not super-great.
|
||||
Since these are under /System, they should be available even to sandboxed apps. */
|
||||
static NSCursor *
|
||||
LoadHiddenSystemCursor(NSString *cursorName, SEL fallback)
|
||||
{
|
||||
NSString *cursorPath = [@"/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/Resources/cursors" stringByAppendingPathComponent:cursorName];
|
||||
NSImage *image = [[NSImage alloc] initWithContentsOfFile:[cursorPath stringByAppendingPathComponent:@"cursor.pdf"]];
|
||||
if ((image == nil) || (image.valid == NO)) {
|
||||
return [NSCursor performSelector:fallback];
|
||||
}
|
||||
|
||||
NSDictionary *info = [NSDictionary dictionaryWithContentsOfFile:[cursorPath stringByAppendingPathComponent:@"info.plist"]];
|
||||
|
||||
/* we can't do animation atm. :/ */
|
||||
const int frames = [[info valueForKey:@"frames"] integerValue];
|
||||
if (frames > 1) {
|
||||
const NSSize cropped_size = NSMakeSize(image.size.width, (int) (image.size.height / frames));
|
||||
NSImage *cropped = [[NSImage alloc] initWithSize:cropped_size];
|
||||
if (cropped == nil) {
|
||||
return [NSCursor performSelector:fallback];
|
||||
}
|
||||
|
||||
#ifdef MAC_OS_VERSION_12_0 /* same value as deprecated symbol. */
|
||||
const NSCompositingOperation operation = NSCompositingOperationCopy;
|
||||
#else
|
||||
const NSCompositingOperation operation = NSCompositeCopy;
|
||||
#endif
|
||||
[cropped lockFocus];
|
||||
const NSRect cropped_rect = NSMakeRect(0, 0, cropped_size.width, cropped_size.height);
|
||||
[image drawInRect:cropped_rect fromRect:cropped_rect operation:operation fraction:1];
|
||||
[cropped unlockFocus];
|
||||
image = cropped;
|
||||
}
|
||||
|
||||
NSCursor *cursor = [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint([[info valueForKey:@"hotx"] doubleValue], [[info valueForKey:@"hoty"] doubleValue])];
|
||||
return cursor;
|
||||
}
|
||||
|
||||
static SDL_Cursor *
|
||||
Cocoa_CreateSystemCursor(SDL_SystemCursor id)
|
||||
{ @autoreleasepool
|
||||
|
|
@ -122,27 +158,29 @@ Cocoa_CreateSystemCursor(SDL_SystemCursor id)
|
|||
case SDL_SYSTEM_CURSOR_IBEAM:
|
||||
nscursor = [NSCursor IBeamCursor];
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WAIT:
|
||||
nscursor = [NSCursor arrowCursor];
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_CROSSHAIR:
|
||||
nscursor = [NSCursor crosshairCursor];
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WAITARROW:
|
||||
nscursor = [NSCursor arrowCursor];
|
||||
case SDL_SYSTEM_CURSOR_WAIT: /* !!! FIXME: this is more like WAITARROW */
|
||||
nscursor = LoadHiddenSystemCursor(@"busybutclickable", @selector(arrowCursor));
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WAITARROW: /* !!! FIXME: this is meant to be animated */
|
||||
nscursor = LoadHiddenSystemCursor(@"busybutclickable", @selector(arrowCursor));
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENWSE:
|
||||
nscursor = LoadHiddenSystemCursor(@"resizenorthwestsoutheast", @selector(closedHandCursor));
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENESW:
|
||||
nscursor = [NSCursor closedHandCursor];
|
||||
nscursor = LoadHiddenSystemCursor(@"resizenortheastsouthwest", @selector(closedHandCursor));
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_SIZEWE:
|
||||
nscursor = [NSCursor resizeLeftRightCursor];
|
||||
nscursor = LoadHiddenSystemCursor(@"resizeeastwest", @selector(resizeLeftRightCursor));
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENS:
|
||||
nscursor = [NSCursor resizeUpDownCursor];
|
||||
nscursor = LoadHiddenSystemCursor(@"resizenorthsouth", @selector(resizeUpDownCursor));
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_SIZEALL:
|
||||
nscursor = [NSCursor closedHandCursor];
|
||||
nscursor = LoadHiddenSystemCursor(@"move", @selector(closedHandCursor));
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_NO:
|
||||
nscursor = [NSCursor operationNotAllowedCursor];
|
||||
|
|
@ -159,8 +197,7 @@ Cocoa_CreateSystemCursor(SDL_SystemCursor id)
|
|||
cursor = SDL_calloc(1, sizeof(*cursor));
|
||||
if (cursor) {
|
||||
/* We'll free it later, so retain it here */
|
||||
[nscursor retain];
|
||||
cursor->driverdata = nscursor;
|
||||
cursor->driverdata = (void *)CFBridgingRetain(nscursor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -171,9 +208,7 @@ static void
|
|||
Cocoa_FreeCursor(SDL_Cursor * cursor)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSCursor *nscursor = (NSCursor *)cursor->driverdata;
|
||||
|
||||
[nscursor release];
|
||||
CFBridgingRelease(cursor->driverdata);
|
||||
SDL_free(cursor);
|
||||
}}
|
||||
|
||||
|
|
@ -184,11 +219,11 @@ Cocoa_ShowCursor(SDL_Cursor * cursor)
|
|||
SDL_VideoDevice *device = SDL_GetVideoDevice();
|
||||
SDL_Window *window = (device ? device->windows : NULL);
|
||||
for (; window != NULL; window = window->next) {
|
||||
SDL_WindowData *driverdata = (SDL_WindowData *)window->driverdata;
|
||||
SDL_WindowData *driverdata = (__bridge SDL_WindowData *)window->driverdata;
|
||||
if (driverdata) {
|
||||
[driverdata->nswindow performSelectorOnMainThread:@selector(invalidateCursorRectsForView:)
|
||||
withObject:[driverdata->nswindow contentView]
|
||||
waitUntilDone:NO];
|
||||
[driverdata.nswindow performSelectorOnMainThread:@selector(invalidateCursorRectsForView:)
|
||||
withObject:[driverdata.nswindow contentView]
|
||||
waitUntilDone:NO];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -214,10 +249,10 @@ Cocoa_WarpMouseGlobal(int x, int y)
|
|||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
if (mouse->focus) {
|
||||
SDL_WindowData *data = (SDL_WindowData *) mouse->focus->driverdata;
|
||||
if ([data->listener isMovingOrFocusClickPending]) {
|
||||
SDL_WindowData *data = (__bridge SDL_WindowData *) mouse->focus->driverdata;
|
||||
if ([data.listener isMovingOrFocusClickPending]) {
|
||||
DLog("Postponing warp, window being moved or focused.");
|
||||
[data->listener setPendingMoveX:x Y:y];
|
||||
[data.listener setPendingMoveX:x Y:y];
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -259,22 +294,6 @@ Cocoa_WarpMouse(SDL_Window * window, int x, int y)
|
|||
static int
|
||||
Cocoa_SetRelativeMouseMode(SDL_bool enabled)
|
||||
{
|
||||
/* We will re-apply the relative mode when the window gets focus, if it
|
||||
* doesn't have focus right now.
|
||||
*/
|
||||
SDL_Window *window = SDL_GetKeyboardFocus();
|
||||
if (!window) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* We will re-apply the relative mode when the window finishes being moved,
|
||||
* if it is being moved right now.
|
||||
*/
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
if ([data->listener isMovingOrFocusClickPending]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
CGError result;
|
||||
if (enabled) {
|
||||
DLog("Turning on.");
|
||||
|
|
@ -287,6 +306,22 @@ Cocoa_SetRelativeMouseMode(SDL_bool enabled)
|
|||
return SDL_SetError("CGAssociateMouseAndMouseCursorPosition() failed");
|
||||
}
|
||||
|
||||
/* We will re-apply the non-relative mode when the window gets focus, if it
|
||||
* doesn't have focus right now.
|
||||
*/
|
||||
SDL_Window *window = SDL_GetKeyboardFocus();
|
||||
if (!window) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* We will re-apply the non-relative mode when the window finishes being moved,
|
||||
* if it is being moved right now.
|
||||
*/
|
||||
SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;
|
||||
if ([data.listener isMovingOrFocusClickPending]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The hide/unhide calls are redundant most of the time, but they fix
|
||||
* https://bugzilla.libsdl.org/show_bug.cgi?id=2550
|
||||
*/
|
||||
|
|
@ -360,18 +395,18 @@ Cocoa_HandleTitleButtonEvent(_THIS, NSEvent *event)
|
|||
NSWindow *nswindow = [event window];
|
||||
|
||||
for (window = _this->windows; window; window = window->next) {
|
||||
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||
if (data && data->nswindow == nswindow) {
|
||||
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
|
||||
if (data && data.nswindow == nswindow) {
|
||||
switch ([event type]) {
|
||||
case NSEventTypeLeftMouseDown:
|
||||
case NSEventTypeRightMouseDown:
|
||||
case NSEventTypeOtherMouseDown:
|
||||
[data->listener setFocusClickPending:[event buttonNumber]];
|
||||
[data.listener setFocusClickPending:[event buttonNumber]];
|
||||
break;
|
||||
case NSEventTypeLeftMouseUp:
|
||||
case NSEventTypeRightMouseUp:
|
||||
case NSEventTypeOtherMouseUp:
|
||||
[data->listener clearFocusClickPending:[event buttonNumber]];
|
||||
[data.listener clearFocusClickPending:[event buttonNumber]];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -467,15 +502,13 @@ Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
|
|||
CGFloat y = [event deltaY];
|
||||
SDL_MouseWheelDirection direction = SDL_MOUSEWHEEL_NORMAL;
|
||||
|
||||
if ([event respondsToSelector:@selector(isDirectionInvertedFromDevice)]) {
|
||||
if ([event isDirectionInvertedFromDevice] == YES) {
|
||||
direction = SDL_MOUSEWHEEL_FLIPPED;
|
||||
}
|
||||
if ([event isDirectionInvertedFromDevice] == YES) {
|
||||
direction = SDL_MOUSEWHEEL_FLIPPED;
|
||||
}
|
||||
|
||||
/* For discrete scroll events from conventional mice, always send a full tick.
|
||||
For continuous scroll events from trackpads, send fractional deltas for smoother scrolling. */
|
||||
if (![event respondsToSelector:@selector(hasPreciseScrollingDeltas)] || ![event hasPreciseScrollingDeltas]) {
|
||||
if (![event hasPreciseScrollingDeltas]) {
|
||||
if (x > 0) {
|
||||
x = SDL_ceil(x);
|
||||
} else if (x < 0) {
|
||||
|
|
|
|||
|
|
@ -82,10 +82,10 @@
|
|||
- (void)setWindow:(SDL_Window *)newWindow
|
||||
{
|
||||
if (self->window) {
|
||||
SDL_WindowData *oldwindowdata = (SDL_WindowData *)self->window->driverdata;
|
||||
SDL_WindowData *oldwindowdata = (__bridge SDL_WindowData *)self->window->driverdata;
|
||||
|
||||
/* Make sure to remove us from the old window's context list, or we'll get scheduled updates from it too. */
|
||||
NSMutableArray *contexts = oldwindowdata->nscontexts;
|
||||
NSMutableArray *contexts = oldwindowdata.nscontexts;
|
||||
@synchronized (contexts) {
|
||||
[contexts removeObject:self];
|
||||
}
|
||||
|
|
@ -94,11 +94,11 @@
|
|||
self->window = newWindow;
|
||||
|
||||
if (newWindow) {
|
||||
SDL_WindowData *windowdata = (SDL_WindowData *)newWindow->driverdata;
|
||||
NSView *contentview = windowdata->sdlContentView;
|
||||
SDL_WindowData *windowdata = (__bridge SDL_WindowData *)newWindow->driverdata;
|
||||
NSView *contentview = windowdata.sdlContentView;
|
||||
|
||||
/* Now sign up for scheduled updates for the new window. */
|
||||
NSMutableArray *contexts = windowdata->nscontexts;
|
||||
NSMutableArray *contexts = windowdata.nscontexts;
|
||||
@synchronized (contexts) {
|
||||
[contexts addObject:self];
|
||||
}
|
||||
|
|
@ -180,10 +180,10 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
|||
{
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
|
||||
SDL_bool lion_or_later = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;
|
||||
NSOpenGLPixelFormatAttribute attr[32];
|
||||
NSOpenGLPixelFormat *fmt;
|
||||
SDLOpenGLContext *context;
|
||||
SDL_GLContext sdlcontext;
|
||||
NSOpenGLContext *share_context = nil;
|
||||
int i = 0;
|
||||
const char *glversion;
|
||||
|
|
@ -213,22 +213,15 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
|||
return NULL;
|
||||
#endif
|
||||
}
|
||||
if ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) && !lion_or_later) {
|
||||
SDL_SetError ("OpenGL Core Profile is not supported on this platform version");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
attr[i++] = NSOpenGLPFAAllowOfflineRenderers;
|
||||
|
||||
/* specify a profile if we're on Lion (10.7) or later. */
|
||||
if (lion_or_later) {
|
||||
NSOpenGLPixelFormatAttribute profile = NSOpenGLProfileVersionLegacy;
|
||||
if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) {
|
||||
profile = NSOpenGLProfileVersion3_2Core;
|
||||
}
|
||||
attr[i++] = NSOpenGLPFAOpenGLProfile;
|
||||
attr[i++] = profile;
|
||||
NSOpenGLPixelFormatAttribute profile = NSOpenGLProfileVersionLegacy;
|
||||
if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) {
|
||||
profile = NSOpenGLProfileVersion3_2Core;
|
||||
}
|
||||
attr[i++] = NSOpenGLPFAOpenGLProfile;
|
||||
attr[i++] = profile;
|
||||
|
||||
attr[i++] = NSOpenGLPFAColorSize;
|
||||
attr[i++] = SDL_BYTESPERPIXEL(display->current_mode.format)*8;
|
||||
|
|
@ -288,20 +281,20 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
|||
}
|
||||
|
||||
if (_this->gl_config.share_with_current_context) {
|
||||
share_context = (NSOpenGLContext*)SDL_GL_GetCurrentContext();
|
||||
share_context = (__bridge NSOpenGLContext*)SDL_GL_GetCurrentContext();
|
||||
}
|
||||
|
||||
context = [[SDLOpenGLContext alloc] initWithFormat:fmt shareContext:share_context];
|
||||
|
||||
[fmt release];
|
||||
|
||||
if (context == nil) {
|
||||
SDL_SetError("Failed creating OpenGL context");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( Cocoa_GL_MakeCurrent(_this, window, context) < 0 ) {
|
||||
Cocoa_GL_DeleteContext(_this, context);
|
||||
sdlcontext = (SDL_GLContext)CFBridgingRetain(context);
|
||||
|
||||
if ( Cocoa_GL_MakeCurrent(_this, window, (__bridge SDL_GLContext)context) < 0 ) {
|
||||
Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context);
|
||||
SDL_SetError("Failed making OpenGL context current");
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -315,27 +308,27 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
|||
|
||||
glGetStringFunc = (const GLubyte *(APIENTRY *)(GLenum)) SDL_GL_GetProcAddress("glGetString");
|
||||
if (!glGetStringFunc) {
|
||||
Cocoa_GL_DeleteContext(_this, context);
|
||||
Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context);
|
||||
SDL_SetError ("Failed getting OpenGL glGetString entry point");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
glversion = (const char *)glGetStringFunc(GL_VERSION);
|
||||
if (glversion == NULL) {
|
||||
Cocoa_GL_DeleteContext(_this, context);
|
||||
Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context);
|
||||
SDL_SetError ("Failed getting OpenGL context version");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (SDL_sscanf(glversion, "%d.%d", &glversion_major, &glversion_minor) != 2) {
|
||||
Cocoa_GL_DeleteContext(_this, context);
|
||||
Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context);
|
||||
SDL_SetError ("Failed parsing OpenGL context version");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((glversion_major < _this->gl_config.major_version) ||
|
||||
((glversion_major == _this->gl_config.major_version) && (glversion_minor < _this->gl_config.minor_version))) {
|
||||
Cocoa_GL_DeleteContext(_this, context);
|
||||
Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context);
|
||||
SDL_SetError ("Failed creating OpenGL context at version requested");
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -346,7 +339,7 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
|||
/*_this->gl_config.major_version = glversion_major;*/
|
||||
/*_this->gl_config.minor_version = glversion_minor;*/
|
||||
}
|
||||
return context;
|
||||
return sdlcontext;
|
||||
}}
|
||||
|
||||
int
|
||||
|
|
@ -354,7 +347,7 @@ Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
|||
{ @autoreleasepool
|
||||
{
|
||||
if (context) {
|
||||
SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
|
||||
SDLOpenGLContext *nscontext = (__bridge SDLOpenGLContext *)context;
|
||||
if ([nscontext window] != window) {
|
||||
[nscontext setWindow:window];
|
||||
[nscontext updateIfNeeded];
|
||||
|
|
@ -369,17 +362,15 @@ Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
|||
|
||||
void
|
||||
Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
|
||||
NSView *contentView = windata->sdlContentView;
|
||||
SDL_WindowData *windata = (__bridge SDL_WindowData *) window->driverdata;
|
||||
NSView *contentView = windata.sdlContentView;
|
||||
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. */
|
||||
viewport = [contentView convertRectToBacking:viewport];
|
||||
}
|
||||
|
||||
if (w) {
|
||||
|
|
@ -389,7 +380,7 @@ Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
|
|||
if (h) {
|
||||
*h = viewport.size.height;
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
||||
int
|
||||
Cocoa_GL_SetSwapInterval(_THIS, int interval)
|
||||
|
|
@ -403,7 +394,7 @@ Cocoa_GL_SetSwapInterval(_THIS, int interval)
|
|||
return SDL_SetError("Late swap tearing currently unsupported");
|
||||
}
|
||||
|
||||
nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext();
|
||||
nscontext = (__bridge NSOpenGLContext*)SDL_GL_GetCurrentContext();
|
||||
if (nscontext != nil) {
|
||||
value = interval;
|
||||
[nscontext setValues:&value forParameter:NSOpenGLCPSwapInterval];
|
||||
|
|
@ -423,7 +414,7 @@ Cocoa_GL_GetSwapInterval(_THIS)
|
|||
GLint value;
|
||||
int status = 0;
|
||||
|
||||
nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext();
|
||||
nscontext = (__bridge NSOpenGLContext*)SDL_GL_GetCurrentContext();
|
||||
if (nscontext != nil) {
|
||||
[nscontext getValues:&value forParameter:NSOpenGLCPSwapInterval];
|
||||
status = (int)value;
|
||||
|
|
@ -436,15 +427,15 @@ int
|
|||
Cocoa_GL_SwapWindow(_THIS, SDL_Window * window)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDLOpenGLContext* nscontext = (SDLOpenGLContext*)SDL_GL_GetCurrentContext();
|
||||
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
||||
SDLOpenGLContext* nscontext = (__bridge SDLOpenGLContext*)SDL_GL_GetCurrentContext();
|
||||
SDL_VideoData *videodata = (__bridge 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);
|
||||
SDL_LockMutex(videodata.swaplock);
|
||||
[nscontext flushBuffer];
|
||||
[nscontext updateIfNeeded];
|
||||
SDL_UnlockMutex(videodata->swaplock);
|
||||
SDL_UnlockMutex(videodata.swaplock);
|
||||
return 0;
|
||||
}}
|
||||
|
||||
|
|
@ -452,10 +443,8 @@ void
|
|||
Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
|
||||
|
||||
SDLOpenGLContext *nscontext = (SDLOpenGLContext *)CFBridgingRelease(context);
|
||||
[nscontext setWindow:NULL];
|
||||
[nscontext release];
|
||||
}}
|
||||
|
||||
/* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@
|
|||
/* EGL implementation of SDL OpenGL support */
|
||||
|
||||
int
|
||||
Cocoa_GLES_LoadLibrary(_THIS, const char *path) {
|
||||
|
||||
Cocoa_GLES_LoadLibrary(_THIS, const char *path)
|
||||
{
|
||||
/* If the profile requested is not GL ES, switch over to WIN_GL functions */
|
||||
if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) {
|
||||
#if SDL_VIDEO_OPENGL_CGL
|
||||
|
|
@ -59,9 +59,10 @@ Cocoa_GLES_LoadLibrary(_THIS, const char *path) {
|
|||
|
||||
SDL_GLContext
|
||||
Cocoa_GLES_CreateContext(_THIS, SDL_Window * window)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_GLContext context;
|
||||
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
|
||||
|
||||
#if SDL_VIDEO_OPENGL_CGL
|
||||
if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) {
|
||||
|
|
@ -85,25 +86,37 @@ Cocoa_GLES_CreateContext(_THIS, SDL_Window * window)
|
|||
}
|
||||
#endif
|
||||
|
||||
context = SDL_EGL_CreateContext(_this, data->egl_surface);
|
||||
context = SDL_EGL_CreateContext(_this, data.egl_surface);
|
||||
return context;
|
||||
}
|
||||
}}
|
||||
|
||||
void
|
||||
Cocoa_GLES_DeleteContext(_THIS, SDL_GLContext context)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_EGL_DeleteContext(_this, context);
|
||||
Cocoa_GLES_UnloadLibrary(_this);
|
||||
}
|
||||
}}
|
||||
|
||||
SDL_EGL_SwapWindow_impl(Cocoa)
|
||||
SDL_EGL_MakeCurrent_impl(Cocoa)
|
||||
int
|
||||
Cocoa_GLES_SwapWindow(_THIS, SDL_Window * window)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
return SDL_EGL_SwapBuffers(_this, ((__bridge SDL_WindowData *) window->driverdata).egl_surface);
|
||||
}}
|
||||
|
||||
int
|
||||
Cocoa_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
return SDL_EGL_MakeCurrent(_this, window ? ((__bridge SDL_WindowData *) window->driverdata).egl_surface : EGL_NO_SURFACE, context);
|
||||
}}
|
||||
|
||||
int
|
||||
Cocoa_GLES_SetupWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
/* The current context is lost in here; save it and reset it. */
|
||||
SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
|
||||
SDL_WindowData *windowdata = (__bridge SDL_WindowData *) window->driverdata;
|
||||
SDL_Window *current_win = SDL_GL_GetCurrentWindow();
|
||||
SDL_GLContext current_ctx = SDL_GL_GetCurrentContext();
|
||||
|
||||
|
|
@ -121,10 +134,10 @@ Cocoa_GLES_SetupWindow(_THIS, SDL_Window * window)
|
|||
}
|
||||
|
||||
/* Create the GLES window surface */
|
||||
NSView* v = windowdata->nswindow.contentView;
|
||||
windowdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType)[v layer]);
|
||||
NSView* v = windowdata.nswindow.contentView;
|
||||
windowdata.egl_surface = SDL_EGL_CreateSurface(_this, (__bridge NativeWindowType)[v layer]);
|
||||
|
||||
if (windowdata->egl_surface == EGL_NO_SURFACE) {
|
||||
if (windowdata.egl_surface == EGL_NO_SURFACE) {
|
||||
return SDL_SetError("Could not create GLES window surface");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,11 +29,12 @@
|
|||
|
||||
SDL_WindowShaper*
|
||||
Cocoa_CreateShaper(SDL_Window* window)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_WindowData* windata = (SDL_WindowData*)window->driverdata;
|
||||
[windata->nswindow setOpaque:NO];
|
||||
SDL_WindowData* windata = (__bridge SDL_WindowData*)window->driverdata;
|
||||
[windata.nswindow setOpaque:NO];
|
||||
|
||||
[windata->nswindow setStyleMask:NSWindowStyleMaskBorderless];
|
||||
[windata.nswindow setStyleMask:NSWindowStyleMaskBorderless];
|
||||
|
||||
SDL_WindowShaper* result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper));
|
||||
result->window = window;
|
||||
|
|
@ -44,14 +45,14 @@ Cocoa_CreateShaper(SDL_Window* window)
|
|||
|
||||
SDL_ShapeData* data = (SDL_ShapeData *)SDL_malloc(sizeof(SDL_ShapeData));
|
||||
result->driverdata = data;
|
||||
data->context = [windata->nswindow graphicsContext];
|
||||
data->context = [windata.nswindow graphicsContext];
|
||||
data->saved = SDL_FALSE;
|
||||
data->shape = NULL;
|
||||
|
||||
int resized_properly = Cocoa_ResizeWindowShape(window);
|
||||
SDL_assert(resized_properly == 0);
|
||||
return result;
|
||||
}
|
||||
}}
|
||||
|
||||
typedef struct {
|
||||
NSView* view;
|
||||
|
|
@ -74,7 +75,7 @@ Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowSha
|
|||
{ @autoreleasepool
|
||||
{
|
||||
SDL_ShapeData* data = (SDL_ShapeData*)shaper->driverdata;
|
||||
SDL_WindowData* windata = (SDL_WindowData*)shaper->window->driverdata;
|
||||
SDL_WindowData* windata = (__bridge SDL_WindowData*)shaper->window->driverdata;
|
||||
SDL_CocoaClosure closure;
|
||||
if(data->saved == SDL_TRUE) {
|
||||
[data->context restoreGraphicsState];
|
||||
|
|
@ -86,10 +87,10 @@ Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowSha
|
|||
[NSGraphicsContext setCurrentContext:data->context];
|
||||
|
||||
[[NSColor clearColor] set];
|
||||
NSRectFill([windata->sdlContentView frame]);
|
||||
NSRectFill([windata.sdlContentView frame]);
|
||||
data->shape = SDL_CalculateShapeTree(*shape_mode,shape);
|
||||
|
||||
closure.view = windata->sdlContentView;
|
||||
closure.view = windata.sdlContentView;
|
||||
closure.path = [NSBezierPath bezierPath];
|
||||
closure.window = shaper->window;
|
||||
SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure);
|
||||
|
|
|
|||
|
|
@ -97,18 +97,15 @@ DECLARE_ALERT_STYLE(Critical);
|
|||
|
||||
@class SDLTranslatorResponder;
|
||||
|
||||
typedef struct SDL_VideoData
|
||||
{
|
||||
int allow_spaces;
|
||||
unsigned int modifierFlags;
|
||||
void *key_layout;
|
||||
SDLTranslatorResponder *fieldEdit;
|
||||
NSInteger clipboard_count;
|
||||
Uint32 screensaver_activity;
|
||||
BOOL screensaver_use_iopm;
|
||||
IOPMAssertionID screensaver_assertion;
|
||||
SDL_mutex *swaplock;
|
||||
} SDL_VideoData;
|
||||
@interface SDL_VideoData : NSObject
|
||||
@property (nonatomic) int allow_spaces;
|
||||
@property (nonatomic) unsigned int modifierFlags;
|
||||
@property (nonatomic) void *key_layout;
|
||||
@property (nonatomic) SDLTranslatorResponder *fieldEdit;
|
||||
@property (nonatomic) NSInteger clipboard_count;
|
||||
@property (nonatomic) IOPMAssertionID screensaver_assertion;
|
||||
@property (nonatomic) SDL_mutex *swaplock;
|
||||
@end
|
||||
|
||||
/* Utility functions */
|
||||
extern NSImage * Cocoa_CreateImage(SDL_Surface * surface);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,10 @@
|
|||
|
||||
#if SDL_VIDEO_DRIVER_COCOA
|
||||
|
||||
#if !__has_feature(objc_arc)
|
||||
#error SDL must be built with Objective-C ARC (automatic reference counting) enabled
|
||||
#endif
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_endian.h"
|
||||
#include "SDL_cocoavideo.h"
|
||||
|
|
@ -29,6 +33,10 @@
|
|||
#include "SDL_cocoavulkan.h"
|
||||
#include "SDL_cocoametalview.h"
|
||||
|
||||
@implementation SDL_VideoData
|
||||
|
||||
@end
|
||||
|
||||
/* Initialization/Query functions */
|
||||
static int Cocoa_VideoInit(_THIS);
|
||||
static void Cocoa_VideoQuit(_THIS);
|
||||
|
|
@ -37,16 +45,18 @@ static void Cocoa_VideoQuit(_THIS);
|
|||
|
||||
static void
|
||||
Cocoa_DeleteDevice(SDL_VideoDevice * device)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
if (device->wakeup_lock) {
|
||||
SDL_DestroyMutex(device->wakeup_lock);
|
||||
}
|
||||
SDL_free(device->driverdata);
|
||||
CFBridgingRelease(device->driverdata);
|
||||
SDL_free(device);
|
||||
}
|
||||
}}
|
||||
|
||||
static SDL_VideoDevice *
|
||||
Cocoa_CreateDevice(int devindex)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_VideoDevice *device;
|
||||
SDL_VideoData *data;
|
||||
|
|
@ -56,16 +66,16 @@ Cocoa_CreateDevice(int devindex)
|
|||
/* Initialize all variables that we clean on shutdown */
|
||||
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
|
||||
if (device) {
|
||||
data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
|
||||
data = [[SDL_VideoData alloc] init];
|
||||
} else {
|
||||
data = NULL;
|
||||
data = nil;
|
||||
}
|
||||
if (!data) {
|
||||
SDL_OutOfMemory();
|
||||
SDL_free(device);
|
||||
return NULL;
|
||||
}
|
||||
device->driverdata = data;
|
||||
device->driverdata = (void *)CFBridgingRetain(data);
|
||||
device->wakeup_lock = SDL_CreateMutex();
|
||||
|
||||
/* Set the function pointers */
|
||||
|
|
@ -103,6 +113,7 @@ Cocoa_CreateDevice(int devindex)
|
|||
device->SetWindowGammaRamp = Cocoa_SetWindowGammaRamp;
|
||||
device->GetWindowGammaRamp = Cocoa_GetWindowGammaRamp;
|
||||
device->GetWindowICCProfile = Cocoa_GetWindowICCProfile;
|
||||
device->GetWindowDisplayIndex = Cocoa_GetWindowDisplayIndex;
|
||||
device->SetWindowMouseRect = Cocoa_SetWindowMouseRect;
|
||||
device->SetWindowMouseGrab = Cocoa_SetWindowMouseGrab;
|
||||
device->SetWindowKeyboardGrab = Cocoa_SetWindowKeyboardGrab;
|
||||
|
|
@ -165,7 +176,7 @@ Cocoa_CreateDevice(int devindex)
|
|||
device->free = Cocoa_DeleteDevice;
|
||||
|
||||
return device;
|
||||
}
|
||||
}}
|
||||
|
||||
VideoBootStrap COCOA_bootstrap = {
|
||||
"cocoa", "SDL Cocoa video driver",
|
||||
|
|
@ -175,8 +186,9 @@ VideoBootStrap COCOA_bootstrap = {
|
|||
|
||||
int
|
||||
Cocoa_VideoInit(_THIS)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata;
|
||||
|
||||
Cocoa_InitModes(_this);
|
||||
Cocoa_InitKeyboard(_this);
|
||||
|
|
@ -184,29 +196,27 @@ Cocoa_VideoInit(_THIS)
|
|||
return -1;
|
||||
}
|
||||
|
||||
data->allow_spaces = ((floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) && SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_TRUE));
|
||||
data.allow_spaces = SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_TRUE);
|
||||
|
||||
/* 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) {
|
||||
data.swaplock = SDL_CreateMutex();
|
||||
if (!data.swaplock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}}
|
||||
|
||||
void
|
||||
Cocoa_VideoQuit(_THIS)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata;
|
||||
Cocoa_QuitModes(_this);
|
||||
Cocoa_QuitKeyboard(_this);
|
||||
Cocoa_QuitMouse(_this);
|
||||
SDL_DestroyMutex(data->swaplock);
|
||||
data->swaplock = NULL;
|
||||
}
|
||||
SDL_DestroyMutex(data.swaplock);
|
||||
data.swaplock = NULL;
|
||||
}}
|
||||
|
||||
/* This function assumes that it's called from within an autorelease pool */
|
||||
NSImage *
|
||||
|
|
@ -223,7 +233,7 @@ Cocoa_CreateImage(SDL_Surface * surface)
|
|||
return nil;
|
||||
}
|
||||
|
||||
imgrep = [[[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL
|
||||
imgrep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL
|
||||
pixelsWide: converted->w
|
||||
pixelsHigh: converted->h
|
||||
bitsPerSample: 8
|
||||
|
|
@ -232,7 +242,7 @@ Cocoa_CreateImage(SDL_Surface * surface)
|
|||
isPlanar: NO
|
||||
colorSpaceName: NSDeviceRGBColorSpace
|
||||
bytesPerRow: converted->pitch
|
||||
bitsPerPixel: converted->format->BitsPerPixel] autorelease];
|
||||
bitsPerPixel: converted->format->BitsPerPixel];
|
||||
if (imgrep == nil) {
|
||||
SDL_FreeSurface(converted);
|
||||
return nil;
|
||||
|
|
@ -252,7 +262,7 @@ Cocoa_CreateImage(SDL_Surface * surface)
|
|||
pixels += 4;
|
||||
}
|
||||
|
||||
img = [[[NSImage alloc] initWithSize: NSMakeSize(surface->w, surface->h)] autorelease];
|
||||
img = [[NSImage alloc] initWithSize: NSMakeSize(surface->w, surface->h)];
|
||||
if (img != nil) {
|
||||
[img addRepresentation: imgrep];
|
||||
}
|
||||
|
|
@ -269,11 +279,16 @@ Cocoa_CreateImage(SDL_Surface * surface)
|
|||
* versions remain identical!
|
||||
*/
|
||||
|
||||
void SDL_NSLog(const char *text)
|
||||
void SDL_NSLog(const char *prefix, const char *text)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSString *str = [NSString stringWithUTF8String:text];
|
||||
NSLog(@"%@", str);
|
||||
NSString *nsText = [NSString stringWithUTF8String:text];
|
||||
if (prefix) {
|
||||
NSString *nsPrefix = [NSString stringWithUTF8String:prefix];
|
||||
NSLog(@"%@: %@", nsPrefix, nsText);
|
||||
} else {
|
||||
NSLog(@"%@", nsText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
#include "../SDL_egl_c.h"
|
||||
#endif
|
||||
|
||||
typedef struct SDL_WindowData SDL_WindowData;
|
||||
@class SDL_WindowData;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
|
@ -40,7 +40,10 @@ typedef enum
|
|||
} PendingWindowOperation;
|
||||
|
||||
@interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> {
|
||||
SDL_WindowData *_data;
|
||||
/* SDL_WindowData owns this Listener and has a strong reference to it.
|
||||
* To avoid reference cycles, we could have either a weak or an
|
||||
* unretained ref to the WindowData. */
|
||||
__weak SDL_WindowData *_data;
|
||||
BOOL observingVisible;
|
||||
BOOL wasCtrlLeft;
|
||||
BOOL wasVisible;
|
||||
|
|
@ -114,22 +117,22 @@ typedef enum
|
|||
/* *INDENT-ON* */
|
||||
|
||||
@class SDLOpenGLContext;
|
||||
@class SDL_VideoData;
|
||||
|
||||
struct SDL_WindowData
|
||||
{
|
||||
SDL_Window *window;
|
||||
NSWindow *nswindow;
|
||||
NSView *sdlContentView;
|
||||
NSMutableArray *nscontexts;
|
||||
SDL_bool created;
|
||||
SDL_bool inWindowFullscreenTransition;
|
||||
NSInteger flash_request;
|
||||
Cocoa_WindowListener *listener;
|
||||
struct SDL_VideoData *videodata;
|
||||
@interface SDL_WindowData : NSObject
|
||||
@property (nonatomic) SDL_Window *window;
|
||||
@property (nonatomic) NSWindow *nswindow;
|
||||
@property (nonatomic) NSView *sdlContentView;
|
||||
@property (nonatomic) NSMutableArray *nscontexts;
|
||||
@property (nonatomic) SDL_bool created;
|
||||
@property (nonatomic) SDL_bool inWindowFullscreenTransition;
|
||||
@property (nonatomic) NSInteger flash_request;
|
||||
@property (nonatomic) Cocoa_WindowListener *listener;
|
||||
@property (nonatomic) SDL_VideoData *videodata;
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
EGLSurface egl_surface;
|
||||
@property (nonatomic) EGLSurface egl_surface;
|
||||
#endif
|
||||
};
|
||||
@end
|
||||
|
||||
extern int Cocoa_CreateWindow(_THIS, SDL_Window * window);
|
||||
extern int Cocoa_CreateWindowFrom(_THIS, SDL_Window * window,
|
||||
|
|
@ -153,6 +156,7 @@ extern void Cocoa_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_t
|
|||
extern void Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
|
||||
extern int Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
|
||||
extern void* Cocoa_GetWindowICCProfile(_THIS, SDL_Window * window, size_t * size);
|
||||
extern int Cocoa_GetWindowDisplayIndex(_THIS, SDL_Window * window);
|
||||
extern int Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
|
||||
extern void Cocoa_SetWindowMouseRect(_THIS, SDL_Window * window);
|
||||
extern void Cocoa_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -19,7 +19,7 @@
|
|||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
|
||||
#ifndef SDL_KMSDRM_MODULE
|
||||
#define SDL_KMSDRM_MODULE(modname)
|
||||
|
|
@ -125,6 +125,6 @@ SDL_KMSDRM_SYM(void,gbm_surface_release_buffer,(struct gbm_surface *surf, struct
|
|||
#undef SDL_KMSDRM_SYM
|
||||
#undef SDL_KMSDRM_SYM_CONST
|
||||
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
|||
200
Engine/lib/sdl/src/video/ngage/SDL_ngageevents.cpp
Normal file
200
Engine/lib/sdl/src/video/ngage/SDL_ngageevents.cpp
Normal file
|
|
@ -0,0 +1,200 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 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 "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_NGAGE
|
||||
|
||||
/* Being a ngage driver, there's no event stream. We just define stubs for
|
||||
most of the API. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../../events/SDL_events_c.h"
|
||||
#include "../../events/SDL_keyboard_c.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "SDL_ngagevideo.h"
|
||||
#include "SDL_ngageevents_c.h"
|
||||
|
||||
int HandleWsEvent(_THIS, const TWsEvent& aWsEvent);
|
||||
|
||||
void
|
||||
NGAGE_PumpEvents(_THIS)
|
||||
{
|
||||
SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata;
|
||||
|
||||
while (phdata->NGAGE_WsEventStatus != KRequestPending)
|
||||
{
|
||||
phdata->NGAGE_WsSession.GetEvent(phdata->NGAGE_WsEvent);
|
||||
|
||||
HandleWsEvent(_this, phdata->NGAGE_WsEvent);
|
||||
|
||||
phdata->NGAGE_WsEventStatus = KRequestPending;
|
||||
phdata->NGAGE_WsSession.EventReady(&phdata->NGAGE_WsEventStatus);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Internal */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <bautils.h>
|
||||
#include <hal.h>
|
||||
|
||||
extern void DisableKeyBlocking(_THIS);
|
||||
extern void RedrawWindowL(_THIS);
|
||||
|
||||
TBool isCursorVisible = EFalse;
|
||||
|
||||
static SDL_Scancode ConvertScancode(_THIS, int key)
|
||||
{
|
||||
SDL_Keycode keycode;
|
||||
|
||||
switch(key)
|
||||
{
|
||||
case EStdKeyBackspace: // Clear key
|
||||
keycode = SDLK_BACKSPACE;
|
||||
break;
|
||||
case 0x31: // 1
|
||||
keycode = SDLK_1;
|
||||
break;
|
||||
case 0x32: // 2
|
||||
keycode = SDLK_2;
|
||||
break;
|
||||
case 0x33: // 3
|
||||
keycode = SDLK_3;
|
||||
break;
|
||||
case 0x34: // 4
|
||||
keycode = SDLK_4;
|
||||
break;
|
||||
case 0x35: // 5
|
||||
keycode = SDLK_5;
|
||||
break;
|
||||
case 0x36: // 6
|
||||
keycode = SDLK_6;
|
||||
break;
|
||||
case 0x37: // 7
|
||||
keycode = SDLK_7;
|
||||
break;
|
||||
case 0x38: // 8
|
||||
keycode = SDLK_8;
|
||||
break;
|
||||
case 0x39: // 9
|
||||
keycode = SDLK_9;
|
||||
break;
|
||||
case 0x30: // 0
|
||||
keycode = SDLK_0;
|
||||
break;
|
||||
case 0x2a: // Asterisk
|
||||
keycode = SDLK_ASTERISK;
|
||||
break;
|
||||
case EStdKeyHash: // Hash
|
||||
keycode = SDLK_HASH;
|
||||
break;
|
||||
case EStdKeyDevice0: // Left softkey
|
||||
keycode = SDLK_SOFTLEFT;
|
||||
break;
|
||||
case EStdKeyDevice1: // Right softkey
|
||||
keycode = SDLK_SOFTRIGHT;
|
||||
break;
|
||||
case EStdKeyApplication0: // Call softkey
|
||||
keycode = SDLK_CALL;
|
||||
break;
|
||||
case EStdKeyApplication1: // End call softkey
|
||||
keycode = SDLK_ENDCALL;
|
||||
break;
|
||||
case EStdKeyDevice3: // Middle softkey
|
||||
keycode = SDLK_SELECT;
|
||||
break;
|
||||
case EStdKeyUpArrow: // Up arrow
|
||||
keycode = SDLK_UP;
|
||||
break;
|
||||
case EStdKeyDownArrow: // Down arrow
|
||||
keycode = SDLK_DOWN;
|
||||
break;
|
||||
case EStdKeyLeftArrow: // Left arrow
|
||||
keycode = SDLK_LEFT;
|
||||
break;
|
||||
case EStdKeyRightArrow: // Right arrow
|
||||
keycode = SDLK_RIGHT;
|
||||
break;
|
||||
default:
|
||||
keycode = SDLK_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
return SDL_GetScancodeFromKey(keycode);
|
||||
}
|
||||
|
||||
int HandleWsEvent(_THIS, const TWsEvent& aWsEvent)
|
||||
{
|
||||
SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata;
|
||||
int posted = 0;
|
||||
|
||||
switch (aWsEvent.Type())
|
||||
{
|
||||
case EEventKeyDown: /* Key events */
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, ConvertScancode(_this, aWsEvent.Key()->iScanCode));
|
||||
break;
|
||||
case EEventKeyUp: /* Key events */
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, ConvertScancode(_this, aWsEvent.Key()->iScanCode));
|
||||
break;
|
||||
case EEventFocusGained: /* SDL window got focus */
|
||||
phdata->NGAGE_IsWindowFocused = ETrue;
|
||||
/* Draw window background and screen buffer */
|
||||
DisableKeyBlocking(_this);
|
||||
RedrawWindowL(_this);
|
||||
break;
|
||||
case EEventFocusLost: /* SDL window lost focus */
|
||||
{
|
||||
phdata->NGAGE_IsWindowFocused = EFalse;
|
||||
RWsSession s;
|
||||
s.Connect();
|
||||
RWindowGroup g(s);
|
||||
g.Construct(TUint32(&g), EFalse);
|
||||
g.EnableReceiptOfFocus(EFalse);
|
||||
RWindow w(s);
|
||||
w.Construct(g, TUint32(&w));
|
||||
w.SetExtent(TPoint(0, 0), phdata->NGAGE_WsWindow.Size());
|
||||
w.SetOrdinalPosition(0);
|
||||
w.Activate();
|
||||
w.Close();
|
||||
g.Close();
|
||||
s.Close();
|
||||
break;
|
||||
}
|
||||
case EEventModifiersChanged:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return posted;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_NGAGE */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
28
Engine/lib/sdl/src/video/ngage/SDL_ngageevents_c.h
Normal file
28
Engine/lib/sdl/src/video/ngage/SDL_ngageevents_c.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 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 "../../SDL_internal.h"
|
||||
|
||||
#include "SDL_ngagevideo.h"
|
||||
|
||||
extern void NGAGE_PumpEvents(_THIS);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
431
Engine/lib/sdl/src/video/ngage/SDL_ngageframebuffer.cpp
Normal file
431
Engine/lib/sdl/src/video/ngage/SDL_ngageframebuffer.cpp
Normal file
|
|
@ -0,0 +1,431 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 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 "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_NGAGE
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "SDL_ngagevideo.h"
|
||||
#include "SDL_ngageframebuffer_c.h"
|
||||
|
||||
#define NGAGE_SURFACE "NGAGE_FrameBuffer"
|
||||
|
||||
/* For 12 bit screen HW. Table for fast conversion from 8 bit to 12 bit
|
||||
*
|
||||
* TUint16 is enough, but using TUint32 so we can use better instruction
|
||||
* selection on ARMI.
|
||||
*/
|
||||
static TUint32 NGAGE_HWPalette_256_to_Screen[256];
|
||||
|
||||
int GetBpp(TDisplayMode displaymode);
|
||||
void DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
|
||||
void DrawBackground(_THIS);
|
||||
void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer);
|
||||
void RedrawWindowL(_THIS);
|
||||
|
||||
int SDL_NGAGE_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
|
||||
{
|
||||
SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata;
|
||||
SDL_Surface *surface;
|
||||
const Uint32 surface_format = SDL_PIXELFORMAT_RGB444;
|
||||
int w, h;
|
||||
|
||||
/* Free the old framebuffer surface */
|
||||
SDL_NGAGE_DestroyWindowFramebuffer(_this, window);
|
||||
|
||||
/* Create a new one */
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format);
|
||||
if (! surface) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Save the info and return! */
|
||||
SDL_SetWindowData(window, NGAGE_SURFACE, surface);
|
||||
*format = surface_format;
|
||||
*pixels = surface->pixels;
|
||||
*pitch = surface->pitch;
|
||||
|
||||
/* Initialise Epoc frame buffer */
|
||||
|
||||
TDisplayMode displayMode = phdata->NGAGE_WsScreen->DisplayMode();
|
||||
|
||||
TScreenInfoV01 screenInfo;
|
||||
TPckg<TScreenInfoV01> sInfo(screenInfo);
|
||||
UserSvr::ScreenInfo(sInfo);
|
||||
|
||||
phdata->NGAGE_ScreenSize = screenInfo.iScreenSize;
|
||||
phdata->NGAGE_DisplayMode = displayMode;
|
||||
phdata->NGAGE_HasFrameBuffer = screenInfo.iScreenAddressValid;
|
||||
phdata->NGAGE_FrameBuffer = phdata->NGAGE_HasFrameBuffer ? (TUint8*) screenInfo.iScreenAddress : NULL;
|
||||
phdata->NGAGE_BytesPerPixel = ((GetBpp(displayMode)-1) / 8) + 1;
|
||||
|
||||
phdata->NGAGE_BytesPerScanLine = screenInfo.iScreenSize.iWidth * phdata->NGAGE_BytesPerPixel;
|
||||
phdata->NGAGE_BytesPerScreen = phdata->NGAGE_BytesPerScanLine * phdata->NGAGE_ScreenSize.iHeight;
|
||||
|
||||
SDL_Log("Screen width %d", screenInfo.iScreenSize.iWidth);
|
||||
SDL_Log("Screen height %d", screenInfo.iScreenSize.iHeight);
|
||||
SDL_Log("Screen dmode %d", displayMode);
|
||||
SDL_Log("Screen valid %d", screenInfo.iScreenAddressValid);
|
||||
|
||||
SDL_Log("Bytes per pixel %d", phdata->NGAGE_BytesPerPixel);
|
||||
SDL_Log("Bytes per scan line %d", phdata->NGAGE_BytesPerScanLine);
|
||||
SDL_Log("Bytes per screen %d", phdata->NGAGE_BytesPerScreen);
|
||||
|
||||
/* It seems that in SA1100 machines for 8bpp displays there is a 512
|
||||
* palette table at the beginning of the frame buffer.
|
||||
*
|
||||
* In 12 bpp machines the table has 16 entries.
|
||||
*/
|
||||
if (phdata->NGAGE_HasFrameBuffer && GetBpp(displayMode) == 8)
|
||||
{
|
||||
phdata->NGAGE_FrameBuffer += 512;
|
||||
}
|
||||
else
|
||||
{
|
||||
phdata->NGAGE_FrameBuffer += 32;
|
||||
}
|
||||
#if 0
|
||||
if (phdata->NGAGE_HasFrameBuffer && GetBpp(displayMode) == 12)
|
||||
{
|
||||
phdata->NGAGE_FrameBuffer += 16 * 2;
|
||||
}
|
||||
if (phdata->NGAGE_HasFrameBuffer && GetBpp(displayMode) == 16)
|
||||
{
|
||||
phdata->NGAGE_FrameBuffer += 16 * 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Get draw device for updating the screen
|
||||
TScreenInfoV01 screenInfo2;
|
||||
|
||||
NGAGE_Runtime::GetScreenInfo(screenInfo2);
|
||||
|
||||
TRAPD(status, phdata->NGAGE_DrawDevice = CFbsDrawDevice::NewScreenDeviceL(screenInfo2, displayMode));
|
||||
User::LeaveIfError(status);
|
||||
|
||||
/* Activate events for me */
|
||||
phdata->NGAGE_WsEventStatus = KRequestPending;
|
||||
phdata->NGAGE_WsSession.EventReady(&phdata->NGAGE_WsEventStatus);
|
||||
|
||||
SDL_Log("SDL:WsEventStatus");
|
||||
User::WaitForRequest(phdata->NGAGE_WsEventStatus);
|
||||
|
||||
phdata->NGAGE_RedrawEventStatus = KRequestPending;
|
||||
phdata->NGAGE_WsSession.RedrawReady(&phdata->NGAGE_RedrawEventStatus);
|
||||
|
||||
SDL_Log("SDL:RedrawEventStatus");
|
||||
User::WaitForRequest(phdata->NGAGE_RedrawEventStatus);
|
||||
|
||||
phdata->NGAGE_WsWindow.PointerFilter(EPointerFilterDrag, 0);
|
||||
|
||||
phdata->NGAGE_ScreenOffset = TPoint(0, 0);
|
||||
|
||||
SDL_Log("SDL:DrawBackground");
|
||||
DrawBackground(_this); // Clear screen
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDL_NGAGE_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects)
|
||||
{
|
||||
static int frame_number;
|
||||
SDL_Surface *surface;
|
||||
|
||||
surface = (SDL_Surface *) SDL_GetWindowData(window, NGAGE_SURFACE);
|
||||
if (! surface)
|
||||
{
|
||||
return SDL_SetError("Couldn't find ngage surface for window");
|
||||
}
|
||||
|
||||
/* Send the data to the display */
|
||||
if (SDL_getenv("SDL_VIDEO_NGAGE_SAVE_FRAMES"))
|
||||
{
|
||||
char file[128];
|
||||
SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
|
||||
(int)SDL_GetWindowID(window), ++frame_number);
|
||||
SDL_SaveBMP(surface, file);
|
||||
}
|
||||
|
||||
DirectUpdate(_this, numrects, (SDL_Rect*)rects);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SDL_NGAGE_DestroyWindowFramebuffer(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_Surface *surface;
|
||||
|
||||
surface = (SDL_Surface *) SDL_SetWindowData(window, NGAGE_SURFACE, NULL);
|
||||
SDL_FreeSurface(surface);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Runtime */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <e32svr.h>
|
||||
#include <hal_data.h>
|
||||
#include <hal.h>
|
||||
|
||||
EXPORT_C void NGAGE_Runtime::GetScreenInfo(TScreenInfoV01& screenInfo2)
|
||||
{
|
||||
TPckg<TScreenInfoV01> sInfo2(screenInfo2);
|
||||
UserSvr::ScreenInfo(sInfo2);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Internal */
|
||||
/*****************************************************************************/
|
||||
|
||||
int GetBpp(TDisplayMode displaymode)
|
||||
{
|
||||
return TDisplayModeUtils::NumDisplayModeBitsPerPixel(displaymode);
|
||||
}
|
||||
|
||||
void DrawBackground(_THIS)
|
||||
{
|
||||
SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata;
|
||||
/* Draw background */
|
||||
TUint16* screenBuffer = (TUint16*)phdata->NGAGE_FrameBuffer;
|
||||
/* Draw black background */
|
||||
Mem::FillZ(screenBuffer, phdata->NGAGE_BytesPerScreen);
|
||||
}
|
||||
|
||||
void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer)
|
||||
{
|
||||
SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata;
|
||||
SDL_Surface *screen = (SDL_Surface*)SDL_GetWindowData(_this->windows, NGAGE_SURFACE);
|
||||
|
||||
TInt i;
|
||||
|
||||
//const TInt sourceNumBytesPerPixel = ((screen->format->BitsPerPixel-1) >> 3) + 1;
|
||||
TDisplayMode displayMode = phdata->NGAGE_DisplayMode;
|
||||
const TInt sourceNumBytesPerPixel = ((GetBpp(displayMode)-1) / 8) + 1;
|
||||
//
|
||||
const TPoint fixedOffset = phdata->NGAGE_ScreenOffset;
|
||||
const TInt screenW = screen->w;
|
||||
const TInt screenH = screen->h;
|
||||
const TInt sourceScanlineLength = screenW;
|
||||
const TInt targetScanlineLength = phdata->NGAGE_ScreenSize.iWidth;
|
||||
|
||||
/* Render the rectangles in the list */
|
||||
|
||||
for (i = 0; i < numrects; ++i)
|
||||
{
|
||||
const SDL_Rect& currentRect = rects[i];
|
||||
SDL_Rect rect2;
|
||||
rect2.x = currentRect.x;
|
||||
rect2.y = currentRect.y;
|
||||
rect2.w = currentRect.w;
|
||||
rect2.h = currentRect.h;
|
||||
|
||||
if (rect2.w <= 0 || rect2.h <= 0) /* Sanity check */
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* All variables are measured in pixels */
|
||||
|
||||
/* Check rects validity, i.e. upper and lower bounds */
|
||||
TInt maxX = Min(screenW - 1, rect2.x + rect2.w - 1);
|
||||
TInt maxY = Min(screenH - 1, rect2.y + rect2.h - 1);
|
||||
if (maxX < 0 || maxY < 0) /* sanity check */
|
||||
{
|
||||
continue;
|
||||
}
|
||||
/* Clip from bottom */
|
||||
|
||||
maxY = Min(maxY, phdata->NGAGE_ScreenSize.iHeight-1);
|
||||
/* TODO: Clip from the right side */
|
||||
|
||||
const TInt sourceRectWidth = maxX - rect2.x + 1;
|
||||
const TInt sourceRectWidthInBytes = sourceRectWidth * sourceNumBytesPerPixel;
|
||||
const TInt sourceRectHeight = maxY - rect2.y + 1;
|
||||
const TInt sourceStartOffset = rect2.x + rect2.y * sourceScanlineLength;
|
||||
const TUint skipValue = 1; /* 1 = No skip */
|
||||
|
||||
TInt targetStartOffset = fixedOffset.iX + rect2.x + (fixedOffset.iY +rect2.y) * targetScanlineLength;
|
||||
|
||||
switch (screen->format->BitsPerPixel)
|
||||
{
|
||||
case 12:
|
||||
{
|
||||
TUint16* bitmapLine = (TUint16*)screen->pixels + sourceStartOffset;
|
||||
TUint16* screenMemory = screenBuffer + targetStartOffset;
|
||||
|
||||
if (skipValue == 1)
|
||||
{
|
||||
for(TInt y = 0 ; y < sourceRectHeight ; y++)
|
||||
{
|
||||
Mem::Copy(screenMemory, bitmapLine, sourceRectWidthInBytes);
|
||||
bitmapLine += sourceScanlineLength;
|
||||
screenMemory += targetScanlineLength;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(TInt y = 0 ; y < sourceRectHeight ; y++)
|
||||
{
|
||||
TUint16* bitmapPos = bitmapLine; /* 2 bytes per pixel */
|
||||
TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */
|
||||
for(TInt x = 0 ; x < sourceRectWidth ; x++)
|
||||
{
|
||||
__ASSERT_DEBUG(screenMemory < (screenBuffer + phdata->NGAGE_ScreenSize.iWidth * phdata->NGAGE_ScreenSize.iHeight), User::Panic(_L("SDL"), KErrCorrupt));
|
||||
__ASSERT_DEBUG(screenMemory >= screenBuffer, User::Panic(_L("SDL"), KErrCorrupt));
|
||||
__ASSERT_DEBUG(bitmapLine < ((TUint16*)screen->pixels + (screen->w * screen->h)), User::Panic(_L("SDL"), KErrCorrupt));
|
||||
__ASSERT_DEBUG(bitmapLine >= (TUint16*)screen->pixels, User::Panic(_L("SDL"), KErrCorrupt));
|
||||
|
||||
*screenMemoryLinePos++ = *bitmapPos;
|
||||
bitmapPos += skipValue;
|
||||
}
|
||||
bitmapLine += sourceScanlineLength;
|
||||
screenMemory += targetScanlineLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
// 256 color paletted mode: 8 bpp --> 12 bpp
|
||||
default:
|
||||
{
|
||||
if(phdata->NGAGE_BytesPerPixel <= 2)
|
||||
{
|
||||
TUint8* bitmapLine = (TUint8*)screen->pixels + sourceStartOffset;
|
||||
TUint16* screenMemory = screenBuffer + targetStartOffset;
|
||||
|
||||
for(TInt y = 0 ; y < sourceRectHeight ; y++)
|
||||
{
|
||||
TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel */
|
||||
TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */
|
||||
/* Convert each pixel from 256 palette to 4k color values */
|
||||
for(TInt x = 0 ; x < sourceRectWidth ; x++)
|
||||
{
|
||||
__ASSERT_DEBUG(screenMemoryLinePos < (screenBuffer + (phdata->NGAGE_ScreenSize.iWidth * phdata->NGAGE_ScreenSize.iHeight)), User::Panic(_L("SDL"), KErrCorrupt));
|
||||
__ASSERT_DEBUG(screenMemoryLinePos >= screenBuffer, User::Panic(_L("SDL"), KErrCorrupt));
|
||||
__ASSERT_DEBUG(bitmapPos < ((TUint8*)screen->pixels + (screen->w * screen->h)), User::Panic(_L("SDL"), KErrCorrupt));
|
||||
__ASSERT_DEBUG(bitmapPos >= (TUint8*)screen->pixels, User::Panic(_L("SDL"), KErrCorrupt));
|
||||
*screenMemoryLinePos++ = NGAGE_HWPalette_256_to_Screen[*bitmapPos++];
|
||||
}
|
||||
bitmapLine += sourceScanlineLength;
|
||||
screenMemory += targetScanlineLength;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TUint8* bitmapLine = (TUint8*)screen->pixels + sourceStartOffset;
|
||||
TUint32* screenMemory = reinterpret_cast<TUint32*>(screenBuffer + targetStartOffset);
|
||||
for(TInt y = 0 ; y < sourceRectHeight ; y++)
|
||||
{
|
||||
TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel */
|
||||
TUint32* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */
|
||||
/* Convert each pixel from 256 palette to 4k color values */
|
||||
for(TInt x = 0 ; x < sourceRectWidth ; x++)
|
||||
{
|
||||
__ASSERT_DEBUG(screenMemoryLinePos < (reinterpret_cast<TUint32*>(screenBuffer) + (phdata->NGAGE_ScreenSize.iWidth * phdata->NGAGE_ScreenSize.iHeight)), User::Panic(_L("SDL"), KErrCorrupt));
|
||||
__ASSERT_DEBUG(screenMemoryLinePos >= reinterpret_cast<TUint32*>(screenBuffer), User::Panic(_L("SDL"), KErrCorrupt));
|
||||
__ASSERT_DEBUG(bitmapPos < ((TUint8*)screen->pixels + (screen->w * screen->h)), User::Panic(_L("SDL"), KErrCorrupt));
|
||||
__ASSERT_DEBUG(bitmapPos >= (TUint8*)screen->pixels, User::Panic(_L("SDL"), KErrCorrupt));
|
||||
*screenMemoryLinePos++ = NGAGE_HWPalette_256_to_Screen[*bitmapPos++];
|
||||
}
|
||||
bitmapLine += sourceScanlineLength;
|
||||
screenMemory += targetScanlineLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
|
||||
{
|
||||
SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata;
|
||||
|
||||
if (! phdata->NGAGE_IsWindowFocused)
|
||||
{
|
||||
SDL_PauseAudio(1);
|
||||
SDL_Delay(1000);
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_PauseAudio(0);
|
||||
|
||||
TUint16* screenBuffer = (TUint16*)phdata->NGAGE_FrameBuffer;
|
||||
|
||||
#if 0
|
||||
if (phdata->NGAGE_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270)
|
||||
{
|
||||
// ...
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
DirectDraw(_this, numrects, rects, screenBuffer);
|
||||
}
|
||||
|
||||
//TRect rect2 = TRect(phdata->NGAGE_WsWindow.Size());
|
||||
for (int i = 0; i < numrects; ++i)
|
||||
{
|
||||
TInt aAx = rects[i].x;
|
||||
TInt aAy = rects[i].y;
|
||||
TInt aBx = rects[i].w;
|
||||
TInt aBy = rects[i].h;
|
||||
TRect rect2 = TRect(aAx, aAy, aBx, aBy);
|
||||
|
||||
phdata->NGAGE_DrawDevice->UpdateRegion(rect2); /* Should we update rects parameter area only? */
|
||||
phdata->NGAGE_DrawDevice->Update();
|
||||
}
|
||||
}
|
||||
|
||||
void RedrawWindowL(_THIS)
|
||||
{
|
||||
SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata;
|
||||
SDL_Surface *screen = (SDL_Surface*)SDL_GetWindowData(_this->windows, NGAGE_SURFACE);
|
||||
|
||||
int w = screen->w;
|
||||
int h = screen->h;
|
||||
if (phdata->NGAGE_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270) {
|
||||
w = screen->h;
|
||||
h = screen->w;
|
||||
}
|
||||
if ((w < phdata->NGAGE_ScreenSize.iWidth)
|
||||
|| (h < phdata->NGAGE_ScreenSize.iHeight)) {
|
||||
DrawBackground(_this);
|
||||
}
|
||||
|
||||
/* Tell the system that something has been drawn */
|
||||
TRect rect = TRect(phdata->NGAGE_WsWindow.Size());
|
||||
phdata->NGAGE_WsWindow.Invalidate(rect);
|
||||
|
||||
/* Draw current buffer */
|
||||
SDL_Rect fullScreen;
|
||||
fullScreen.x = 0;
|
||||
fullScreen.y = 0;
|
||||
fullScreen.w = screen->w;
|
||||
fullScreen.h = screen->h;
|
||||
DirectUpdate(_this, 1, &fullScreen);
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_NGAGE */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
38
Engine/lib/sdl/src/video/ngage/SDL_ngageframebuffer_c.h
Normal file
38
Engine/lib/sdl/src/video/ngage/SDL_ngageframebuffer_c.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 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 "../../SDL_internal.h"
|
||||
|
||||
extern int SDL_NGAGE_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch);
|
||||
extern int SDL_NGAGE_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects);
|
||||
extern void SDL_NGAGE_DestroyWindowFramebuffer(_THIS, SDL_Window * window);
|
||||
|
||||
/****************************************************************************/
|
||||
/* Runtime */
|
||||
/****************************************************************************/
|
||||
|
||||
class NGAGE_Runtime
|
||||
{
|
||||
public:
|
||||
IMPORT_C static void GetScreenInfo(TScreenInfoV01& screenInfo2);
|
||||
};
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
192
Engine/lib/sdl/src/video/ngage/SDL_ngagevideo.cpp
Normal file
192
Engine/lib/sdl/src/video/ngage/SDL_ngagevideo.cpp
Normal file
|
|
@ -0,0 +1,192 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 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 <stdlib.h>
|
||||
#ifdef NULL
|
||||
#undef NULL
|
||||
#endif
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_NGAGE
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "SDL_video.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../SDL_pixels_c.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "SDL_ngagevideo.h"
|
||||
#include "SDL_ngagewindow.h"
|
||||
#include "SDL_ngageevents_c.h"
|
||||
#include "SDL_ngageframebuffer_c.h"
|
||||
|
||||
#define NGAGEVID_DRIVER_NAME "ngage"
|
||||
|
||||
/* Initialization/Query functions */
|
||||
static int NGAGE_VideoInit(_THIS);
|
||||
static int NGAGE_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
|
||||
static void NGAGE_VideoQuit(_THIS);
|
||||
|
||||
/* NGAGE driver bootstrap functions */
|
||||
|
||||
static void
|
||||
NGAGE_DeleteDevice(SDL_VideoDevice * device)
|
||||
{
|
||||
SDL_VideoData *phdata = (SDL_VideoData*)device->driverdata;
|
||||
|
||||
if (phdata)
|
||||
{
|
||||
/* Free Epoc resources */
|
||||
|
||||
/* Disable events for me */
|
||||
if (phdata->NGAGE_WsEventStatus != KRequestPending)
|
||||
{
|
||||
phdata->NGAGE_WsSession.EventReadyCancel();
|
||||
}
|
||||
if (phdata->NGAGE_RedrawEventStatus != KRequestPending)
|
||||
{
|
||||
phdata->NGAGE_WsSession.RedrawReadyCancel();
|
||||
}
|
||||
|
||||
free(phdata->NGAGE_DrawDevice);
|
||||
|
||||
if (phdata->NGAGE_WsWindow.WsHandle())
|
||||
{
|
||||
phdata->NGAGE_WsWindow.Close();
|
||||
}
|
||||
|
||||
if (phdata->NGAGE_WsWindowGroup.WsHandle())
|
||||
{
|
||||
phdata->NGAGE_WsWindowGroup.Close();
|
||||
}
|
||||
|
||||
delete phdata->NGAGE_WindowGc;
|
||||
phdata->NGAGE_WindowGc = NULL;
|
||||
|
||||
delete phdata->NGAGE_WsScreen;
|
||||
phdata->NGAGE_WsScreen = NULL;
|
||||
|
||||
if (phdata->NGAGE_WsSession.WsHandle())
|
||||
{
|
||||
phdata->NGAGE_WsSession.Close();
|
||||
}
|
||||
|
||||
SDL_free(phdata);
|
||||
phdata = NULL;
|
||||
}
|
||||
|
||||
if (device)
|
||||
{
|
||||
SDL_free(device);
|
||||
device = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_VideoDevice *
|
||||
NGAGE_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_VideoDevice *device;
|
||||
SDL_VideoData *phdata;
|
||||
|
||||
/* Initialize all variables that we clean on shutdown */
|
||||
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
|
||||
if (!device) {
|
||||
SDL_OutOfMemory();
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Initialize internal N-Gage specific data */
|
||||
phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
|
||||
if (! phdata)
|
||||
{
|
||||
SDL_OutOfMemory();
|
||||
SDL_free(device);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* General video */
|
||||
device->VideoInit = NGAGE_VideoInit;
|
||||
device->VideoQuit = NGAGE_VideoQuit;
|
||||
device->SetDisplayMode = NGAGE_SetDisplayMode;
|
||||
device->PumpEvents = NGAGE_PumpEvents;
|
||||
device->CreateWindowFramebuffer = SDL_NGAGE_CreateWindowFramebuffer;
|
||||
device->UpdateWindowFramebuffer = SDL_NGAGE_UpdateWindowFramebuffer;
|
||||
device->DestroyWindowFramebuffer = SDL_NGAGE_DestroyWindowFramebuffer;
|
||||
device->free = NGAGE_DeleteDevice;
|
||||
|
||||
/* "Window" */
|
||||
device->CreateSDLWindow = NGAGE_CreateWindow;
|
||||
device->DestroyWindow = NGAGE_DestroyWindow;
|
||||
|
||||
/* N-Gage specific data */
|
||||
device->driverdata = phdata;
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
VideoBootStrap NGAGE_bootstrap = {
|
||||
NGAGEVID_DRIVER_NAME, "SDL ngage video driver",
|
||||
NGAGE_CreateDevice
|
||||
};
|
||||
|
||||
int
|
||||
NGAGE_VideoInit(_THIS)
|
||||
{
|
||||
SDL_DisplayMode mode;
|
||||
|
||||
/* Use 12-bpp desktop mode */
|
||||
mode.format = SDL_PIXELFORMAT_RGB444;
|
||||
mode.w = 176;
|
||||
mode.h = 208;
|
||||
mode.refresh_rate = 0;
|
||||
mode.driverdata = NULL;
|
||||
if (SDL_AddBasicVideoDisplay(&mode) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_zero(mode);
|
||||
SDL_AddDisplayMode(&_this->displays[0], &mode);
|
||||
|
||||
/* We're done! */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
NGAGE_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
NGAGE_VideoQuit(_THIS)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_NGAGE */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
75
Engine/lib/sdl/src/video/ngage/SDL_ngagevideo.h
Normal file
75
Engine/lib/sdl/src/video/ngage/SDL_ngagevideo.h
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 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 "../../SDL_internal.h"
|
||||
|
||||
#ifndef _SDL_ngagevideo_h
|
||||
#define _SDL_ngagevideo_h
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
#include <e32std.h>
|
||||
#include <e32svr.h>
|
||||
#include <bitdev.h>
|
||||
#include <w32std.h>
|
||||
#include <bitdraw.h> // CFbsDrawDevice
|
||||
|
||||
#define _THIS SDL_VideoDevice *_this
|
||||
|
||||
typedef struct SDL_VideoData
|
||||
{
|
||||
/* Epoc window server info */
|
||||
RWsSession NGAGE_WsSession;
|
||||
RWindowGroup NGAGE_WsWindowGroup;
|
||||
TInt NGAGE_WsWindowGroupID;
|
||||
RWindow NGAGE_WsWindow;
|
||||
CWsScreenDevice* NGAGE_WsScreen;
|
||||
CWindowGc* NGAGE_WindowGc;
|
||||
TRequestStatus NGAGE_WsEventStatus;
|
||||
TRequestStatus NGAGE_RedrawEventStatus;
|
||||
TWsEvent NGAGE_WsEvent;
|
||||
//TWsRedrawEvent NGAGE_RedrawEvent;
|
||||
|
||||
CFbsDrawDevice* NGAGE_DrawDevice;
|
||||
|
||||
TBool NGAGE_IsWindowFocused; /* Not used yet */
|
||||
|
||||
/* Screen hardware frame buffer info */
|
||||
TBool NGAGE_HasFrameBuffer;
|
||||
TInt NGAGE_BytesPerPixel;
|
||||
TInt NGAGE_BytesPerScanLine;
|
||||
TInt NGAGE_BytesPerScreen;
|
||||
TDisplayMode NGAGE_DisplayMode;
|
||||
TSize NGAGE_ScreenSize;
|
||||
TUint8* NGAGE_FrameBuffer;
|
||||
TPoint NGAGE_ScreenOffset;
|
||||
|
||||
CFbsBitGc::TGraphicsOrientation NGAGE_ScreenOrientation;
|
||||
|
||||
/* Simulate double screen height */
|
||||
//TInt NGAGE_ScreenXScaleValue;
|
||||
//TInt NGAGE_ScreenYScaleValue;
|
||||
|
||||
} SDL_VideoData;
|
||||
|
||||
#endif /* _SDL_ngagevideo_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
129
Engine/lib/sdl/src/video/ngage/SDL_ngagewindow.cpp
Normal file
129
Engine/lib/sdl/src/video/ngage/SDL_ngagewindow.cpp
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 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 "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_NGAGE
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
#include "SDL_ngagewindow.h"
|
||||
|
||||
const TUint32 WindowClientHandle = 9210;
|
||||
|
||||
void DisableKeyBlocking(_THIS);
|
||||
void ConstructWindowL(_THIS);
|
||||
|
||||
int
|
||||
NGAGE_CreateWindow(_THIS, SDL_Window* window)
|
||||
{
|
||||
NGAGE_Window* ngage_window = (NGAGE_Window*)SDL_calloc(1, sizeof(NGAGE_Window));
|
||||
|
||||
if (!ngage_window) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
window->driverdata = ngage_window;
|
||||
|
||||
if (window->x == SDL_WINDOWPOS_UNDEFINED) {
|
||||
window->x = 0;
|
||||
}
|
||||
|
||||
if (window->y == SDL_WINDOWPOS_UNDEFINED) {
|
||||
window->y = 0;
|
||||
}
|
||||
|
||||
ngage_window->sdl_window = window;
|
||||
|
||||
ConstructWindowL(_this);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
NGAGE_DestroyWindow(_THIS, SDL_Window* window)
|
||||
{
|
||||
NGAGE_Window* ngage_window = (NGAGE_Window*)window->driverdata;
|
||||
|
||||
if (ngage_window) {
|
||||
SDL_free(ngage_window);
|
||||
}
|
||||
|
||||
window->driverdata = NULL;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Internal */
|
||||
/*****************************************************************************/
|
||||
|
||||
void DisableKeyBlocking(_THIS)
|
||||
{
|
||||
SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata;
|
||||
TRawEvent event;
|
||||
|
||||
event.Set((TRawEvent::TType) /*EDisableKeyBlock*/ 51);
|
||||
phdata->NGAGE_WsSession.SimulateRawEvent(event);
|
||||
}
|
||||
|
||||
void ConstructWindowL(_THIS)
|
||||
{
|
||||
SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata;
|
||||
TInt error;
|
||||
|
||||
error = phdata->NGAGE_WsSession.Connect();
|
||||
User::LeaveIfError(error);
|
||||
phdata->NGAGE_WsScreen=new(ELeave) CWsScreenDevice(phdata->NGAGE_WsSession);
|
||||
User::LeaveIfError(phdata->NGAGE_WsScreen->Construct());
|
||||
User::LeaveIfError(phdata->NGAGE_WsScreen->CreateContext(phdata->NGAGE_WindowGc));
|
||||
|
||||
phdata->NGAGE_WsWindowGroup=RWindowGroup(phdata->NGAGE_WsSession);
|
||||
User::LeaveIfError(phdata->NGAGE_WsWindowGroup.Construct(WindowClientHandle));
|
||||
phdata->NGAGE_WsWindowGroup.SetOrdinalPosition(0);
|
||||
|
||||
RProcess thisProcess;
|
||||
TParse exeName;
|
||||
exeName.Set(thisProcess.FileName(), NULL, NULL);
|
||||
TBuf<32> winGroupName;
|
||||
winGroupName.Append(0);
|
||||
winGroupName.Append(0);
|
||||
winGroupName.Append(0); // UID
|
||||
winGroupName.Append(0);
|
||||
winGroupName.Append(exeName.Name()); // Caption
|
||||
winGroupName.Append(0);
|
||||
winGroupName.Append(0); // DOC name
|
||||
phdata->NGAGE_WsWindowGroup.SetName(winGroupName);
|
||||
|
||||
phdata->NGAGE_WsWindow=RWindow(phdata->NGAGE_WsSession);
|
||||
User::LeaveIfError(phdata->NGAGE_WsWindow.Construct(phdata->NGAGE_WsWindowGroup,WindowClientHandle - 1));
|
||||
phdata->NGAGE_WsWindow.SetBackgroundColor(KRgbWhite);
|
||||
phdata->NGAGE_WsWindow.Activate();
|
||||
phdata->NGAGE_WsWindow.SetSize(phdata->NGAGE_WsScreen->SizeInPixels());
|
||||
phdata->NGAGE_WsWindow.SetVisible(ETrue);
|
||||
|
||||
phdata->NGAGE_WsWindowGroupID = phdata->NGAGE_WsWindowGroup.Identifier();
|
||||
phdata->NGAGE_IsWindowFocused = EFalse;
|
||||
|
||||
DisableKeyBlocking(_this);
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_NGAGE */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
45
Engine/lib/sdl/src/video/ngage/SDL_ngagewindow.h
Normal file
45
Engine/lib/sdl/src/video/ngage/SDL_ngagewindow.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 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.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_ngagewindow_h
|
||||
#define _SDL_ngagewindow_h
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "SDL_syswm.h"
|
||||
|
||||
#include "SDL_ngagevideo.h"
|
||||
|
||||
typedef struct {
|
||||
SDL_Window* sdl_window;
|
||||
|
||||
} NGAGE_Window;
|
||||
|
||||
|
||||
extern int
|
||||
NGAGE_CreateWindow(_THIS, SDL_Window* window);
|
||||
|
||||
extern void
|
||||
NGAGE_DestroyWindow(_THIS, SDL_Window* window);
|
||||
|
||||
#endif /* _SDL_ngagewindow */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
Sources:
|
||||
- https://www.riscosopen.org/wiki/documentation/show/Keyboard Scan Codes
|
||||
*/
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
static SDL_Scancode const riscos_scancode_table[] = {
|
||||
/* 0 */ SDL_SCANCODE_UNKNOWN, /* Shift */
|
||||
/* 1 */ SDL_SCANCODE_UNKNOWN, /* Ctrl */
|
||||
|
|
@ -155,4 +155,4 @@ static SDL_Scancode const riscos_scancode_table[] = {
|
|||
/* 126 */ SDL_SCANCODE_RGUI,
|
||||
/* 127 */ SDL_SCANCODE_MENU
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ sub open_file {
|
|||
|
||||
#if SDL_HAVE_BLIT_AUTO
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
|
||||
__EOF__
|
||||
}
|
||||
|
|
@ -122,7 +122,7 @@ __EOF__
|
|||
sub close_file {
|
||||
my $name = shift;
|
||||
print FILE <<__EOF__;
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
|
||||
#endif /* SDL_HAVE_BLIT_AUTO */
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@
|
|||
glGetIntegerv(GL_MAX_SAMPLES, &maxsamples);
|
||||
|
||||
/* Clamp the samples to the max supported count. */
|
||||
samples = MIN(samples, maxsamples);
|
||||
samples = SDL_min(samples, maxsamples);
|
||||
}
|
||||
|
||||
if (sRGB) {
|
||||
|
|
|
|||
|
|
@ -278,11 +278,16 @@ UIKit_ForceUpdateHomeIndicator()
|
|||
*/
|
||||
|
||||
#if !defined(SDL_VIDEO_DRIVER_COCOA)
|
||||
void SDL_NSLog(const char *text)
|
||||
void SDL_NSLog(const char *prefix, const char *text)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSString *str = [NSString stringWithUTF8String:text];
|
||||
NSLog(@"%@", str);
|
||||
NSString *nsText = [NSString stringWithUTF8String:text];
|
||||
if (prefix) {
|
||||
NSString *nsPrefix = [NSString stringWithUTF8String:prefix];
|
||||
NSLog(@"%@: %@", nsPrefix, nsText);
|
||||
} else {
|
||||
NSLog(@"%@", nsText);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* SDL_VIDEO_DRIVER_COCOA */
|
||||
|
|
|
|||
|
|
@ -153,6 +153,7 @@ void SDL_WAYLAND_UnloadSymbols(void);
|
|||
#define libdecor_state_free (*WAYLAND_libdecor_state_free)
|
||||
#define libdecor_configuration_get_content_size (*WAYLAND_libdecor_configuration_get_content_size)
|
||||
#define libdecor_configuration_get_window_state (*WAYLAND_libdecor_configuration_get_window_state)
|
||||
#define libdecor_dispatch (*WAYLAND_libdecor_dispatch)
|
||||
#endif
|
||||
|
||||
#else /* SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC */
|
||||
|
|
|
|||
|
|
@ -294,6 +294,10 @@ Wayland_WaitEventTimeout(_THIS, int timeout)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
libdecor_dispatch(d->shell.libdecor, timeout);
|
||||
#endif
|
||||
|
||||
/* wl_display_prepare_read() will return -1 if the default queue is not empty.
|
||||
* If the default queue is empty, it will prepare us for our SDL_IOReady() call. */
|
||||
if (WAYLAND_wl_display_prepare_read(d->display) == 0) {
|
||||
|
|
@ -476,19 +480,16 @@ ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial)
|
|||
const uint32_t *directions_libdecor = directions;
|
||||
#endif
|
||||
|
||||
/* Hit tests shouldn't apply to xdg_popups, right? */
|
||||
SDL_assert(!WINDOW_IS_XDG_POPUP(window));
|
||||
|
||||
switch (rc) {
|
||||
case SDL_HITTEST_DRAGGABLE:
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
if (input->display->shell.libdecor) {
|
||||
if (window_data->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) {
|
||||
if (window_data->shell_surface.libdecor.frame) {
|
||||
libdecor_frame_move(window_data->shell_surface.libdecor.frame, input->seat, serial);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
if (input->display->shell.xdg) {
|
||||
if (window_data->shell_surface_type == WAYLAND_SURFACE_XDG_TOPLEVEL) {
|
||||
if (window_data->shell_surface.xdg.roleobj.toplevel) {
|
||||
xdg_toplevel_move(window_data->shell_surface.xdg.roleobj.toplevel,
|
||||
input->seat,
|
||||
|
|
@ -506,13 +507,13 @@ ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial)
|
|||
case SDL_HITTEST_RESIZE_BOTTOMLEFT:
|
||||
case SDL_HITTEST_RESIZE_LEFT:
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
if (input->display->shell.libdecor) {
|
||||
if (window_data->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) {
|
||||
if (window_data->shell_surface.libdecor.frame) {
|
||||
libdecor_frame_resize(window_data->shell_surface.libdecor.frame, input->seat, serial, directions_libdecor[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
if (input->display->shell.xdg) {
|
||||
if (window_data->shell_surface_type == WAYLAND_SURFACE_XDG_TOPLEVEL) {
|
||||
if (window_data->shell_surface.xdg.roleobj.toplevel) {
|
||||
xdg_toplevel_resize(window_data->shell_surface.xdg.roleobj.toplevel,
|
||||
input->seat,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
|
||||
#ifndef SDL_WAYLAND_MODULE
|
||||
#define SDL_WAYLAND_MODULE(modname)
|
||||
|
|
@ -204,12 +204,13 @@ SDL_WAYLAND_SYM(bool, libdecor_configuration_get_content_size, (struct libdecor_
|
|||
int *))
|
||||
SDL_WAYLAND_SYM(bool, libdecor_configuration_get_window_state, (struct libdecor_configuration *,\
|
||||
enum libdecor_window_state *))
|
||||
SDL_WAYLAND_SYM(bool, libdecor_dispatch, (struct libdecor *, int))
|
||||
#endif
|
||||
|
||||
#undef SDL_WAYLAND_MODULE
|
||||
#undef SDL_WAYLAND_SYM
|
||||
#undef SDL_WAYLAND_INTERFACE
|
||||
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
|||
|
|
@ -878,7 +878,7 @@ static const struct wl_registry_listener registry_listener = {
|
|||
};
|
||||
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
static SDL_bool should_use_libdecor(SDL_VideoData *data)
|
||||
static SDL_bool should_use_libdecor(SDL_VideoData *data, SDL_bool ignore_xdg)
|
||||
{
|
||||
if (!SDL_WAYLAND_HAVE_WAYLAND_LIBDECOR) {
|
||||
return SDL_FALSE;
|
||||
|
|
@ -892,6 +892,10 @@ static SDL_bool should_use_libdecor(SDL_VideoData *data)
|
|||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
if (ignore_xdg) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
if (data->decoration_manager) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
|
@ -900,6 +904,21 @@ static SDL_bool should_use_libdecor(SDL_VideoData *data)
|
|||
}
|
||||
#endif
|
||||
|
||||
SDL_bool
|
||||
Wayland_LoadLibdecor(SDL_VideoData *data, SDL_bool ignore_xdg)
|
||||
{
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
if (data->shell.libdecor != NULL) {
|
||||
return SDL_TRUE; /* Already loaded! */
|
||||
}
|
||||
if (should_use_libdecor(data, ignore_xdg)) {
|
||||
data->shell.libdecor = libdecor_new(data->display, &libdecor_interface);
|
||||
return data->shell.libdecor != NULL;
|
||||
}
|
||||
#endif
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
Wayland_VideoInit(_THIS)
|
||||
{
|
||||
|
|
@ -920,12 +939,8 @@ Wayland_VideoInit(_THIS)
|
|||
// First roundtrip to receive all registry objects.
|
||||
WAYLAND_wl_display_roundtrip(data->display);
|
||||
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
/* Don't have server-side decorations? Try client-side instead. */
|
||||
if (should_use_libdecor(data)) {
|
||||
data->shell.libdecor = libdecor_new(data->display, &libdecor_interface);
|
||||
}
|
||||
#endif
|
||||
/* Now that we have all the protocols, load libdecor if applicable */
|
||||
Wayland_LoadLibdecor(data, SDL_FALSE);
|
||||
|
||||
// Second roundtrip to receive all output events.
|
||||
WAYLAND_wl_display_roundtrip(data->display);
|
||||
|
|
|
|||
|
|
@ -122,6 +122,8 @@ extern void SDL_WAYLAND_register_output(struct wl_output *output);
|
|||
extern SDL_bool SDL_WAYLAND_own_surface(struct wl_surface *surface);
|
||||
extern SDL_bool SDL_WAYLAND_own_output(struct wl_output *output);
|
||||
|
||||
extern SDL_bool Wayland_LoadLibdecor(SDL_VideoData *data, SDL_bool ignore_xdg);
|
||||
|
||||
#endif /* SDL_waylandvideo_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
|||
|
|
@ -683,6 +683,34 @@ Wayland_PopupWatch(void *data, SDL_Event *event)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
handle_configure_zxdg_decoration(void *data,
|
||||
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1,
|
||||
uint32_t mode)
|
||||
{
|
||||
SDL_Window *window = (SDL_Window *) data;
|
||||
SDL_WindowData *driverdata = (SDL_WindowData *) window->driverdata;
|
||||
|
||||
/* If the compositor tries to force CSD anyway, bail on direct XDG support
|
||||
* and fall back to libdecor, it will handle these events from then on.
|
||||
*
|
||||
* To do this we have to fully unmap, then map with libdecor loaded.
|
||||
*/
|
||||
if (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE) {
|
||||
if (!Wayland_LoadLibdecor(driverdata->waylandData, SDL_TRUE)) {
|
||||
/* libdecor isn't available, so no borders for you... oh well */
|
||||
return;
|
||||
}
|
||||
SDL_HideWindow(window);
|
||||
driverdata->shell_surface_type = WAYLAND_SURFACE_LIBDECOR;
|
||||
SDL_ShowWindow(window);
|
||||
}
|
||||
}
|
||||
|
||||
static const struct zxdg_toplevel_decoration_v1_listener decoration_listener = {
|
||||
handle_configure_zxdg_decoration
|
||||
};
|
||||
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
static void
|
||||
decoration_frame_configure(struct libdecor_frame *frame,
|
||||
|
|
@ -1258,6 +1286,9 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
|
|||
/* Create the window decorations */
|
||||
if (!WINDOW_IS_XDG_POPUP(window) && data->shell_surface.xdg.roleobj.toplevel && c->decoration_manager) {
|
||||
data->server_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(c->decoration_manager, data->shell_surface.xdg.roleobj.toplevel);
|
||||
zxdg_toplevel_decoration_v1_add_listener(data->server_decoration,
|
||||
&decoration_listener,
|
||||
window);
|
||||
}
|
||||
} else {
|
||||
/* Nothing to see here, just commit. */
|
||||
|
|
@ -1628,7 +1659,6 @@ void
|
|||
Wayland_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable)
|
||||
{
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
SDL_VideoData *data = _this->driverdata;
|
||||
const SDL_WindowData *wind = window->driverdata;
|
||||
|
||||
if (WINDOW_IS_LIBDECOR(data, window)) {
|
||||
|
|
@ -1874,6 +1904,22 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window)
|
|||
/* We may need to create an idle inhibitor for this new window */
|
||||
Wayland_SuspendScreenSaver(_this);
|
||||
|
||||
#define IS_POPUP(window) \
|
||||
(window->flags & (SDL_WINDOW_TOOLTIP | SDL_WINDOW_POPUP_MENU))
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
if (c->shell.libdecor && !IS_POPUP(window)) {
|
||||
data->shell_surface_type = WAYLAND_SURFACE_LIBDECOR;
|
||||
} else
|
||||
#endif
|
||||
if (c->shell.xdg) {
|
||||
if (IS_POPUP(window)) {
|
||||
data->shell_surface_type = WAYLAND_SURFACE_XDG_POPUP;
|
||||
} else {
|
||||
data->shell_surface_type = WAYLAND_SURFACE_XDG_TOPLEVEL;
|
||||
}
|
||||
} /* All other cases will be WAYLAND_SURFACE_UNKNOWN */
|
||||
#undef IS_POPUP
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,32 +32,11 @@
|
|||
|
||||
struct SDL_WaylandInput;
|
||||
|
||||
typedef struct {
|
||||
struct xdg_surface *surface;
|
||||
union {
|
||||
struct xdg_toplevel *toplevel;
|
||||
struct {
|
||||
struct xdg_popup *popup;
|
||||
struct xdg_positioner *positioner;
|
||||
Uint32 parentID;
|
||||
SDL_Window *child;
|
||||
} popup;
|
||||
} roleobj;
|
||||
SDL_bool initial_configure_seen;
|
||||
} SDL_xdg_shell_surface;
|
||||
|
||||
/* TODO: Remove these helpers, they're from before we had shell_surface_type */
|
||||
#define WINDOW_IS_XDG_POPUP(window) \
|
||||
(window->flags & (SDL_WINDOW_TOOLTIP | SDL_WINDOW_POPUP_MENU))
|
||||
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
typedef struct {
|
||||
struct libdecor_frame *frame;
|
||||
SDL_bool initial_configure_seen;
|
||||
} SDL_libdecor_surface;
|
||||
|
||||
#define WINDOW_IS_LIBDECOR(viddata, window) \
|
||||
(viddata->shell.libdecor && !WINDOW_IS_XDG_POPUP(window))
|
||||
#endif
|
||||
(((SDL_WindowData*) window->driverdata)->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP)
|
||||
#define WINDOW_IS_LIBDECOR(ignoreme, window) \
|
||||
(((SDL_WindowData*) window->driverdata)->shell_surface_type == WAYLAND_SURFACE_LIBDECOR)
|
||||
|
||||
typedef struct {
|
||||
SDL_Window *sdlwindow;
|
||||
|
|
@ -66,12 +45,35 @@ typedef struct {
|
|||
struct wl_callback *frame_callback;
|
||||
struct wl_event_queue *frame_event_queue;
|
||||
struct wl_surface *frame_surface_wrapper;
|
||||
|
||||
union {
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
SDL_libdecor_surface libdecor;
|
||||
struct {
|
||||
struct libdecor_frame *frame;
|
||||
SDL_bool initial_configure_seen;
|
||||
} libdecor;
|
||||
#endif
|
||||
SDL_xdg_shell_surface xdg;
|
||||
struct {
|
||||
struct xdg_surface *surface;
|
||||
union {
|
||||
struct xdg_toplevel *toplevel;
|
||||
struct {
|
||||
struct xdg_popup *popup;
|
||||
struct xdg_positioner *positioner;
|
||||
Uint32 parentID;
|
||||
SDL_Window *child;
|
||||
} popup;
|
||||
} roleobj;
|
||||
SDL_bool initial_configure_seen;
|
||||
} xdg;
|
||||
} shell_surface;
|
||||
enum {
|
||||
WAYLAND_SURFACE_UNKNOWN = 0,
|
||||
WAYLAND_SURFACE_XDG_TOPLEVEL,
|
||||
WAYLAND_SURFACE_XDG_POPUP,
|
||||
WAYLAND_SURFACE_LIBDECOR
|
||||
} shell_surface_type;
|
||||
|
||||
struct wl_egl_window *egl_window;
|
||||
struct SDL_WaylandInput *keyboard_device;
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include "SDL_timer.h"
|
||||
#include "SDL_vkeys.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_main.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
#include "../../events/SDL_touch_c.h"
|
||||
#include "../../events/scancodes_windows.h"
|
||||
|
|
@ -1370,10 +1371,15 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
{
|
||||
SDL_Window *window = data->window;
|
||||
if (window->hit_test) {
|
||||
POINT winpoint = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
||||
POINT winpoint;
|
||||
winpoint.x = GET_X_LPARAM(lParam);
|
||||
winpoint.y = GET_Y_LPARAM(lParam);
|
||||
if (ScreenToClient(hwnd, &winpoint)) {
|
||||
const SDL_Point point = { (int) winpoint.x, (int) winpoint.y };
|
||||
const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data);
|
||||
SDL_Point point;
|
||||
SDL_HitTestResult rc;
|
||||
point.x = winpoint.x;
|
||||
point.y = winpoint.y;
|
||||
rc = window->hit_test(window, &point, window->hit_test_data);
|
||||
switch (rc) {
|
||||
#define POST_HIT_TEST(ret) { SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIT_TEST, 0, 0); return ret; }
|
||||
case SDL_HITTEST_DRAGGABLE: POST_HIT_TEST(HTCAPTION);
|
||||
|
|
|
|||
|
|
@ -265,6 +265,22 @@ WIN_VideoQuit(_THIS)
|
|||
#define D3D_DEBUG_INFO
|
||||
#include <d3d9.h>
|
||||
|
||||
#ifdef D3D_DEBUG_INFO
|
||||
#ifndef D3D_SDK_VERSION
|
||||
#define D3D_SDK_VERSION (32 | 0x80000000)
|
||||
#endif
|
||||
#ifndef D3D9b_SDK_VERSION
|
||||
#define D3D9b_SDK_VERSION (31 | 0x80000000)
|
||||
#endif
|
||||
#else /**/
|
||||
#ifndef D3D_SDK_VERSION
|
||||
#define D3D_SDK_VERSION 32
|
||||
#endif
|
||||
#ifndef D3D9b_SDK_VERSION
|
||||
#define D3D9b_SDK_VERSION 31
|
||||
#endif
|
||||
#endif
|
||||
|
||||
SDL_bool
|
||||
D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -47,9 +47,6 @@ typedef struct
|
|||
#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR
|
||||
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR NULL
|
||||
#endif
|
||||
#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA
|
||||
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA NULL
|
||||
#endif
|
||||
#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2
|
||||
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 NULL
|
||||
#endif
|
||||
|
|
@ -62,20 +59,15 @@ typedef struct
|
|||
#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS
|
||||
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS NULL
|
||||
#endif
|
||||
#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE
|
||||
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE NULL
|
||||
#endif
|
||||
|
||||
static x11dynlib x11libs[] = {
|
||||
{NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC},
|
||||
{NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT},
|
||||
{NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR},
|
||||
{NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA},
|
||||
{NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2},
|
||||
{NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES},
|
||||
{NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR},
|
||||
{NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS},
|
||||
{NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE}
|
||||
{NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS}
|
||||
};
|
||||
|
||||
static void *
|
||||
|
|
|
|||
|
|
@ -52,9 +52,6 @@
|
|||
#if SDL_VIDEO_DRIVER_X11_XDBE
|
||||
#include <X11/extensions/Xdbe.h>
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_X11_XINPUT2
|
||||
#include <X11/extensions/XInput2.h>
|
||||
#endif
|
||||
|
|
@ -70,9 +67,6 @@
|
|||
#if SDL_VIDEO_DRIVER_X11_XSHAPE
|
||||
#include <X11/extensions/shape.h>
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_X11_XVIDMODE
|
||||
#include <X11/extensions/xf86vmode.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
static const struct {
|
||||
KeySym keysym;
|
||||
SDL_Scancode scancode;
|
||||
|
|
@ -160,7 +160,7 @@ static const struct
|
|||
{ xfree86_scancode_table2, SDL_arraysize(xfree86_scancode_table2) },
|
||||
{ xvnc_scancode_table, SDL_arraysize(xvnc_scancode_table) },
|
||||
};
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
|
||||
/* This function only works for keyboards in US QWERTY layout */
|
||||
static SDL_Scancode
|
||||
|
|
@ -267,13 +267,6 @@ X11_InitKeyboard(_THIS)
|
|||
int best_index;
|
||||
int distance;
|
||||
Bool xkb_repeat = 0;
|
||||
XKeyboardState values;
|
||||
SDL_zero(values);
|
||||
values.global_auto_repeat = AutoRepeatModeOff;
|
||||
|
||||
X11_XGetKeyboardControl(data->display, &values);
|
||||
if (values.global_auto_repeat != AutoRepeatModeOn)
|
||||
X11_XAutoRepeatOn(data->display);
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
|
||||
{
|
||||
|
|
|
|||
|
|
@ -148,61 +148,29 @@ X11_GetPixelFormatFromVisualInfo(Display * display, XVisualInfo * vinfo)
|
|||
return SDL_PIXELFORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
static SDL_bool
|
||||
CheckXinerama(Display * display, int *major, int *minor)
|
||||
{
|
||||
int event_base = 0;
|
||||
int error_base = 0;
|
||||
|
||||
/* Default the extension not available */
|
||||
*major = *minor = 0;
|
||||
|
||||
/* Allow environment override */
|
||||
if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_XINERAMA, SDL_TRUE)) {
|
||||
#ifdef X11MODES_DEBUG
|
||||
printf("Xinerama disabled due to hint\n");
|
||||
#endif
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (!SDL_X11_HAVE_XINERAMA) {
|
||||
#ifdef X11MODES_DEBUG
|
||||
printf("Xinerama support not available\n");
|
||||
#endif
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Query the extension version */
|
||||
if (!X11_XineramaQueryExtension(display, &event_base, &error_base) ||
|
||||
!X11_XineramaQueryVersion(display, major, minor) ||
|
||||
!X11_XineramaIsActive(display)) {
|
||||
#ifdef X11MODES_DEBUG
|
||||
printf("Xinerama not active on the display\n");
|
||||
#endif
|
||||
return SDL_FALSE;
|
||||
}
|
||||
#ifdef X11MODES_DEBUG
|
||||
printf("Xinerama available at version %d.%d!\n", *major, *minor);
|
||||
#endif
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
/* !!! FIXME: remove this later. */
|
||||
/* we have a weird bug where XineramaQueryScreens() throws an X error, so this
|
||||
is here to help track it down (and not crash, too!). */
|
||||
static SDL_bool xinerama_triggered_error = SDL_FALSE;
|
||||
static int
|
||||
X11_XineramaFailed(Display * d, XErrorEvent * e)
|
||||
GetXftDPI(Display* dpy)
|
||||
{
|
||||
xinerama_triggered_error = SDL_TRUE;
|
||||
fprintf(stderr, "XINERAMA X ERROR: type=%d serial=%lu err=%u req=%u minor=%u\n",
|
||||
e->type, e->serial, (unsigned int) e->error_code,
|
||||
(unsigned int) e->request_code, (unsigned int) e->minor_code);
|
||||
fflush(stderr);
|
||||
return 0;
|
||||
char* xdefault_resource;
|
||||
int xft_dpi, err;
|
||||
|
||||
xdefault_resource = X11_XGetDefault(dpy, "Xft", "dpi");
|
||||
|
||||
if(!xdefault_resource) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* It's possible for SDL_atoi to call SDL_strtol, if it fails due to a
|
||||
* overflow or an underflow, it will return LONG_MAX or LONG_MIN and set
|
||||
* errno to ERANGE. So we need to check for this so we dont get crazy dpi
|
||||
* values
|
||||
*/
|
||||
xft_dpi = SDL_atoi(xdefault_resource);
|
||||
err = errno;
|
||||
|
||||
return err == ERANGE ? 0 : xft_dpi;
|
||||
}
|
||||
#endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XRANDR
|
||||
static SDL_bool
|
||||
|
|
@ -345,30 +313,6 @@ SetXRandRDisplayName(Display *dpy, Atom EDID, char *name, const size_t namelen,
|
|||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
GetXftDPI(Display* dpy)
|
||||
{
|
||||
char* xdefault_resource;
|
||||
int xft_dpi, err;
|
||||
|
||||
xdefault_resource = X11_XGetDefault(dpy, "Xft", "dpi");
|
||||
|
||||
if(!xdefault_resource) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* It's possible for SDL_atoi to call SDL_strtol, if it fails due to a
|
||||
* overflow or an underflow, it will return LONG_MAX or LONG_MIN and set
|
||||
* errno to ERANGE. So we need to check for this so we dont get crazy dpi
|
||||
* values
|
||||
*/
|
||||
xft_dpi = SDL_atoi(xdefault_resource);
|
||||
err = errno;
|
||||
|
||||
return err == ERANGE ? 0 : xft_dpi;
|
||||
}
|
||||
|
||||
static int
|
||||
X11_InitModes_XRandR(_THIS)
|
||||
{
|
||||
|
|
@ -506,7 +450,7 @@ X11_InitModes_XRandR(_THIS)
|
|||
displaydata->scanline_pad = scanline_pad;
|
||||
displaydata->x = display_x;
|
||||
displaydata->y = display_y;
|
||||
displaydata->use_xrandr = 1;
|
||||
displaydata->use_xrandr = SDL_TRUE;
|
||||
displaydata->xrandr_output = res->outputs[output];
|
||||
|
||||
SetXRandRModeInfo(dpy, res, output_crtc, modeID, &mode);
|
||||
|
|
@ -534,343 +478,124 @@ X11_InitModes_XRandR(_THIS)
|
|||
}
|
||||
#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XVIDMODE
|
||||
static SDL_bool
|
||||
CheckVidMode(Display * display, int *major, int *minor)
|
||||
/* This is used if there's no better functionality--like XRandR--to use.
|
||||
It won't attempt to supply different display modes at all, but it can
|
||||
enumerate the current displays and their current sizes. */
|
||||
static int X11_InitModes_StdXlib(_THIS)
|
||||
{
|
||||
int vm_event, vm_error = -1;
|
||||
/* Default the extension not available */
|
||||
*major = *minor = 0;
|
||||
/* !!! FIXME: a lot of copy/paste from X11_InitModes_XRandR in this function. */
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
Display *dpy = data->display;
|
||||
const int default_screen = DefaultScreen(dpy);
|
||||
Screen *screen = ScreenOfDisplay(dpy, default_screen);
|
||||
int display_mm_width, display_mm_height, xft_dpi, scanline_pad, n, i;
|
||||
SDL_DisplayModeData *modedata;
|
||||
SDL_DisplayData *displaydata;
|
||||
SDL_DisplayMode mode;
|
||||
XPixmapFormatValues *pixmapformats;
|
||||
Uint32 pixelformat;
|
||||
XVisualInfo vinfo;
|
||||
SDL_VideoDisplay display;
|
||||
|
||||
/* Allow environment override */
|
||||
if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_XVIDMODE, SDL_TRUE)) {
|
||||
#ifdef X11MODES_DEBUG
|
||||
printf("XVidMode disabled due to hint\n");
|
||||
#endif
|
||||
return SDL_FALSE;
|
||||
/* note that generally even if you have a multiple physical monitors, ScreenCount(dpy) still only reports ONE screen. */
|
||||
|
||||
if (get_visualinfo(dpy, default_screen, &vinfo) < 0) {
|
||||
return SDL_SetError("Failed to find an X11 visual for the primary display");
|
||||
}
|
||||
|
||||
if (!SDL_X11_HAVE_XVIDMODE) {
|
||||
#ifdef X11MODES_DEBUG
|
||||
printf("XVidMode support not available\n");
|
||||
#endif
|
||||
return SDL_FALSE;
|
||||
pixelformat = X11_GetPixelFormatFromVisualInfo(dpy, &vinfo);
|
||||
if (SDL_ISPIXELFORMAT_INDEXED(pixelformat)) {
|
||||
return SDL_SetError("Palettized video modes are no longer supported");
|
||||
}
|
||||
|
||||
/* Query the extension version */
|
||||
if (!X11_XF86VidModeQueryExtension(display, &vm_event, &vm_error)
|
||||
|| !X11_XF86VidModeQueryVersion(display, major, minor)) {
|
||||
#ifdef X11MODES_DEBUG
|
||||
printf("XVidMode not active on the display\n");
|
||||
#endif
|
||||
return SDL_FALSE;
|
||||
SDL_zero(mode);
|
||||
mode.w = WidthOfScreen(screen);
|
||||
mode.h = HeightOfScreen(screen);
|
||||
mode.format = pixelformat;
|
||||
mode.refresh_rate = 0; /* don't know it, sorry. */
|
||||
|
||||
displaydata = (SDL_DisplayData *) SDL_calloc(1, sizeof(*displaydata));
|
||||
if (!displaydata) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
#ifdef X11MODES_DEBUG
|
||||
printf("XVidMode available at version %d.%d!\n", *major, *minor);
|
||||
#endif
|
||||
return SDL_TRUE;
|
||||
|
||||
modedata = (SDL_DisplayModeData *) SDL_calloc(1, sizeof(SDL_DisplayModeData));
|
||||
if (!modedata) {
|
||||
SDL_free(displaydata);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
mode.driverdata = modedata;
|
||||
|
||||
display_mm_width = WidthMMOfScreen(screen);
|
||||
display_mm_height = HeightMMOfScreen(screen);
|
||||
|
||||
displaydata->screen = default_screen;
|
||||
displaydata->visual = vinfo.visual;
|
||||
displaydata->depth = vinfo.depth;
|
||||
displaydata->hdpi = display_mm_width ? (((float) mode.w) * 25.4f / display_mm_width) : 0.0f;
|
||||
displaydata->vdpi = display_mm_height ? (((float) mode.h) * 25.4f / display_mm_height) : 0.0f;
|
||||
displaydata->ddpi = SDL_ComputeDiagonalDPI(mode.w, mode.h, ((float) display_mm_width) / 25.4f,((float) display_mm_height) / 25.4f);
|
||||
|
||||
xft_dpi = GetXftDPI(dpy);
|
||||
if(xft_dpi > 0) {
|
||||
displaydata->hdpi = (float)xft_dpi;
|
||||
displaydata->vdpi = (float)xft_dpi;
|
||||
}
|
||||
|
||||
scanline_pad = SDL_BYTESPERPIXEL(pixelformat) * 8;
|
||||
pixmapformats = X11_XListPixmapFormats(dpy, &n);
|
||||
if (pixmapformats) {
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (pixmapformats[i].depth == vinfo.depth) {
|
||||
scanline_pad = pixmapformats[i].scanline_pad;
|
||||
break;
|
||||
}
|
||||
}
|
||||
X11_XFree(pixmapformats);
|
||||
}
|
||||
|
||||
displaydata->scanline_pad = scanline_pad;
|
||||
displaydata->x = 0;
|
||||
displaydata->y = 0;
|
||||
displaydata->use_xrandr = SDL_FALSE;
|
||||
|
||||
SDL_zero(display);
|
||||
display.name = (char *) "Generic X11 Display"; /* this is just copied and thrown away, it's safe to cast to char* here. */
|
||||
display.desktop_mode = mode;
|
||||
display.current_mode = mode;
|
||||
display.driverdata = displaydata;
|
||||
SDL_AddVideoDisplay(&display, SDL_FALSE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
Bool XF86VidModeGetModeInfo(Display * dpy, int scr,
|
||||
XF86VidModeModeInfo* info)
|
||||
{
|
||||
Bool retval;
|
||||
int dotclock;
|
||||
XF86VidModeModeLine l;
|
||||
SDL_zerop(info);
|
||||
SDL_zero(l);
|
||||
retval = X11_XF86VidModeGetModeLine(dpy, scr, &dotclock, &l);
|
||||
info->dotclock = dotclock;
|
||||
info->hdisplay = l.hdisplay;
|
||||
info->hsyncstart = l.hsyncstart;
|
||||
info->hsyncend = l.hsyncend;
|
||||
info->htotal = l.htotal;
|
||||
info->hskew = l.hskew;
|
||||
info->vdisplay = l.vdisplay;
|
||||
info->vsyncstart = l.vsyncstart;
|
||||
info->vsyncend = l.vsyncend;
|
||||
info->vtotal = l.vtotal;
|
||||
info->flags = l.flags;
|
||||
info->privsize = l.privsize;
|
||||
info->private = l.private;
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int
|
||||
CalculateXVidModeRefreshRate(const XF86VidModeModeInfo * info)
|
||||
{
|
||||
return (info->htotal
|
||||
&& info->vtotal) ? (1000 * info->dotclock / (info->htotal *
|
||||
info->vtotal)) : 0;
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
SetXVidModeModeInfo(const XF86VidModeModeInfo *info, SDL_DisplayMode *mode)
|
||||
{
|
||||
mode->w = info->hdisplay;
|
||||
mode->h = info->vdisplay;
|
||||
mode->refresh_rate = CalculateXVidModeRefreshRate(info);
|
||||
((SDL_DisplayModeData*)mode->driverdata)->vm_mode = *info;
|
||||
return SDL_TRUE;
|
||||
}
|
||||
#endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */
|
||||
|
||||
int
|
||||
X11_InitModes(_THIS)
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
int snum, screen, screencount = 0;
|
||||
#if SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
int xinerama_major, xinerama_minor;
|
||||
int use_xinerama = 0;
|
||||
XineramaScreenInfo *xinerama = NULL;
|
||||
#endif
|
||||
/* XRandR is the One True Modern Way to do this on X11. If this
|
||||
fails, we just won't report any display modes except the current
|
||||
desktop size. */
|
||||
#if SDL_VIDEO_DRIVER_X11_XRANDR
|
||||
int xrandr_major, xrandr_minor;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_X11_XVIDMODE
|
||||
int vm_major, vm_minor;
|
||||
int use_vidmode = 0;
|
||||
#endif
|
||||
|
||||
/* XRandR is the One True Modern Way to do this on X11. If it's enabled and
|
||||
available, don't even look at other ways of doing things. */
|
||||
#if SDL_VIDEO_DRIVER_X11_XRANDR
|
||||
/* require at least XRandR v1.3 */
|
||||
if (CheckXRandR(data->display, &xrandr_major, &xrandr_minor) &&
|
||||
(xrandr_major >= 2 || (xrandr_major == 1 && xrandr_minor >= 3))) {
|
||||
if (X11_InitModes_XRandR(_this) == 0)
|
||||
return 0;
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
int xrandr_major, xrandr_minor;
|
||||
/* require at least XRandR v1.3 */
|
||||
if (CheckXRandR(data->display, &xrandr_major, &xrandr_minor) &&
|
||||
(xrandr_major >= 2 || (xrandr_major == 1 && xrandr_minor >= 3))) {
|
||||
return X11_InitModes_XRandR(_this);
|
||||
}
|
||||
}
|
||||
#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
|
||||
|
||||
/* !!! FIXME: eventually remove support for Xinerama and XVidMode (everything below here). */
|
||||
|
||||
/* This is a workaround for some apps (UnrealEngine4, for example) until
|
||||
we sort out the ramifications of removing XVidMode support outright.
|
||||
This block should be removed with the XVidMode support. */
|
||||
{
|
||||
if (SDL_GetHintBoolean("SDL_VIDEO_X11_REQUIRE_XRANDR", SDL_FALSE)) {
|
||||
#if SDL_VIDEO_DRIVER_X11_XRANDR
|
||||
return SDL_SetError("XRandR support is required but not available");
|
||||
#else
|
||||
return SDL_SetError("XRandR support is required but not built into SDL!");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
/* Query Xinerama extention
|
||||
* NOTE: This works with Nvidia Twinview correctly, but you need version 302.17 (released on June 2012)
|
||||
* or newer of the Nvidia binary drivers
|
||||
*/
|
||||
if (CheckXinerama(data->display, &xinerama_major, &xinerama_minor)) {
|
||||
int (*handler) (Display *, XErrorEvent *);
|
||||
X11_XSync(data->display, False);
|
||||
handler = X11_XSetErrorHandler(X11_XineramaFailed);
|
||||
xinerama = X11_XineramaQueryScreens(data->display, &screencount);
|
||||
X11_XSync(data->display, False);
|
||||
X11_XSetErrorHandler(handler);
|
||||
if (xinerama_triggered_error) {
|
||||
xinerama = 0;
|
||||
}
|
||||
if (xinerama) {
|
||||
use_xinerama = xinerama_major * 100 + xinerama_minor;
|
||||
}
|
||||
}
|
||||
if (!xinerama) {
|
||||
screencount = ScreenCount(data->display);
|
||||
}
|
||||
#else
|
||||
screencount = ScreenCount(data->display);
|
||||
#endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XVIDMODE
|
||||
if (CheckVidMode(data->display, &vm_major, &vm_minor)) {
|
||||
use_vidmode = vm_major * 100 + vm_minor;
|
||||
}
|
||||
#endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */
|
||||
|
||||
for (snum = 0; snum < screencount; ++snum) {
|
||||
XVisualInfo vinfo;
|
||||
SDL_VideoDisplay display;
|
||||
SDL_DisplayData *displaydata;
|
||||
SDL_DisplayMode mode;
|
||||
SDL_DisplayModeData *modedata;
|
||||
XPixmapFormatValues *pixmapFormats;
|
||||
char display_name[128];
|
||||
int i, n;
|
||||
|
||||
/* Re-order screens to always put default screen first */
|
||||
if (snum == 0) {
|
||||
screen = DefaultScreen(data->display);
|
||||
} else if (snum == DefaultScreen(data->display)) {
|
||||
screen = 0;
|
||||
} else {
|
||||
screen = snum;
|
||||
}
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
if (xinerama) {
|
||||
if (get_visualinfo(data->display, 0, &vinfo) < 0) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (get_visualinfo(data->display, screen, &vinfo) < 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (get_visualinfo(data->display, screen, &vinfo) < 0) {
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
displaydata = (SDL_DisplayData *) SDL_calloc(1, sizeof(*displaydata));
|
||||
if (!displaydata) {
|
||||
continue;
|
||||
}
|
||||
display_name[0] = '\0';
|
||||
|
||||
mode.format = X11_GetPixelFormatFromVisualInfo(data->display, &vinfo);
|
||||
if (SDL_ISPIXELFORMAT_INDEXED(mode.format)) {
|
||||
/* We don't support palettized modes now */
|
||||
SDL_free(displaydata);
|
||||
continue;
|
||||
}
|
||||
#if SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
if (xinerama) {
|
||||
mode.w = xinerama[screen].width;
|
||||
mode.h = xinerama[screen].height;
|
||||
} else {
|
||||
mode.w = DisplayWidth(data->display, screen);
|
||||
mode.h = DisplayHeight(data->display, screen);
|
||||
}
|
||||
#else
|
||||
mode.w = DisplayWidth(data->display, screen);
|
||||
mode.h = DisplayHeight(data->display, screen);
|
||||
#endif
|
||||
mode.refresh_rate = 0;
|
||||
|
||||
modedata = (SDL_DisplayModeData *) SDL_calloc(1, sizeof(SDL_DisplayModeData));
|
||||
if (!modedata) {
|
||||
SDL_free(displaydata);
|
||||
continue;
|
||||
}
|
||||
mode.driverdata = modedata;
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
/* Most of SDL's calls to X11 are unwaware of Xinerama, and to X11 standard calls, when Xinerama is active,
|
||||
* there's only one screen available. So we force the screen number to zero and
|
||||
* let Xinerama specific code handle specific functionality using displaydata->xinerama_info
|
||||
*/
|
||||
if (use_xinerama) {
|
||||
displaydata->screen = 0;
|
||||
displaydata->use_xinerama = use_xinerama;
|
||||
displaydata->xinerama_info = xinerama[screen];
|
||||
displaydata->xinerama_screen = screen;
|
||||
}
|
||||
else displaydata->screen = screen;
|
||||
#else
|
||||
displaydata->screen = screen;
|
||||
#endif
|
||||
displaydata->visual = vinfo.visual;
|
||||
displaydata->depth = vinfo.depth;
|
||||
|
||||
/* We use the displaydata screen index here so that this works
|
||||
for both the Xinerama case, where we get the overall DPI,
|
||||
and the regular X11 screen info case. */
|
||||
displaydata->hdpi = (float)DisplayWidth(data->display, displaydata->screen) * 25.4f /
|
||||
DisplayWidthMM(data->display, displaydata->screen);
|
||||
displaydata->vdpi = (float)DisplayHeight(data->display, displaydata->screen) * 25.4f /
|
||||
DisplayHeightMM(data->display, displaydata->screen);
|
||||
displaydata->ddpi = SDL_ComputeDiagonalDPI(DisplayWidth(data->display, displaydata->screen),
|
||||
DisplayHeight(data->display, displaydata->screen),
|
||||
(float)DisplayWidthMM(data->display, displaydata->screen) / 25.4f,
|
||||
(float)DisplayHeightMM(data->display, displaydata->screen) / 25.4f);
|
||||
|
||||
displaydata->scanline_pad = SDL_BYTESPERPIXEL(mode.format) * 8;
|
||||
pixmapFormats = X11_XListPixmapFormats(data->display, &n);
|
||||
if (pixmapFormats) {
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (pixmapFormats[i].depth == displaydata->depth) {
|
||||
displaydata->scanline_pad = pixmapFormats[i].scanline_pad;
|
||||
break;
|
||||
}
|
||||
}
|
||||
X11_XFree(pixmapFormats);
|
||||
}
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
if (use_xinerama) {
|
||||
displaydata->x = xinerama[screen].x_org;
|
||||
displaydata->y = xinerama[screen].y_org;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
displaydata->x = 0;
|
||||
displaydata->y = 0;
|
||||
}
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XVIDMODE
|
||||
if (!displaydata->use_xrandr &&
|
||||
#if SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
/* XVidMode only works on the screen at the origin */
|
||||
(!displaydata->use_xinerama ||
|
||||
(displaydata->x == 0 && displaydata->y == 0)) &&
|
||||
#endif
|
||||
use_vidmode) {
|
||||
displaydata->use_vidmode = use_vidmode;
|
||||
if (displaydata->use_xinerama) {
|
||||
displaydata->vidmode_screen = 0;
|
||||
} else {
|
||||
displaydata->vidmode_screen = screen;
|
||||
}
|
||||
XF86VidModeGetModeInfo(data->display, displaydata->vidmode_screen, &modedata->vm_mode);
|
||||
}
|
||||
#endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */
|
||||
|
||||
SDL_zero(display);
|
||||
if (*display_name) {
|
||||
display.name = display_name;
|
||||
}
|
||||
display.desktop_mode = mode;
|
||||
display.current_mode = mode;
|
||||
display.driverdata = displaydata;
|
||||
SDL_AddVideoDisplay(&display, SDL_FALSE);
|
||||
}
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
if (xinerama) X11_XFree(xinerama);
|
||||
#endif
|
||||
|
||||
if (_this->num_displays == 0) {
|
||||
return SDL_SetError("No available displays");
|
||||
}
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XVIDMODE
|
||||
if (use_vidmode) { /* we intend to remove support for XVidMode soon. */
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "SDL is using XVidMode to manage your displays!");
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "This almost always means either SDL was misbuilt");
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "or your X server is insufficient. Please check your setup!");
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "Fullscreen and/or multiple displays will not work well.");
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
/* still here? Just set up an extremely basic display. */
|
||||
return X11_InitModes_StdXlib(_this);
|
||||
}
|
||||
|
||||
void
|
||||
X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display)
|
||||
{
|
||||
Display *display = ((SDL_VideoData *) _this->driverdata)->display;
|
||||
SDL_DisplayData *data = (SDL_DisplayData *) sdl_display->driverdata;
|
||||
#if SDL_VIDEO_DRIVER_X11_XVIDMODE
|
||||
int nmodes;
|
||||
XF86VidModeModeInfo ** modes;
|
||||
#endif
|
||||
SDL_DisplayMode mode;
|
||||
|
||||
/* Unfortunately X11 requires the window to be created with the correct
|
||||
|
|
@ -882,54 +607,9 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display)
|
|||
mode.format = sdl_display->current_mode.format;
|
||||
mode.driverdata = NULL;
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
if (data->use_xinerama) {
|
||||
int screen_w;
|
||||
int screen_h;
|
||||
|
||||
screen_w = DisplayWidth(display, data->screen);
|
||||
screen_h = DisplayHeight(display, data->screen);
|
||||
|
||||
if (data->use_vidmode && !data->xinerama_info.x_org && !data->xinerama_info.y_org &&
|
||||
(screen_w > data->xinerama_info.width || screen_h > data->xinerama_info.height)) {
|
||||
SDL_DisplayModeData *modedata;
|
||||
/* Add the full (both screens combined) xinerama mode only on the display that starts at 0,0
|
||||
* if we're using vidmode.
|
||||
*/
|
||||
mode.w = screen_w;
|
||||
mode.h = screen_h;
|
||||
mode.refresh_rate = 0;
|
||||
modedata = (SDL_DisplayModeData *) SDL_calloc(1, sizeof(SDL_DisplayModeData));
|
||||
if (modedata) {
|
||||
*modedata = *(SDL_DisplayModeData *)sdl_display->desktop_mode.driverdata;
|
||||
}
|
||||
mode.driverdata = modedata;
|
||||
if (!SDL_AddDisplayMode(sdl_display, &mode)) {
|
||||
SDL_free(modedata);
|
||||
}
|
||||
}
|
||||
else if (!data->use_xrandr)
|
||||
{
|
||||
SDL_DisplayModeData *modedata;
|
||||
/* Add the current mode of each monitor otherwise if we can't get them from xrandr */
|
||||
mode.w = data->xinerama_info.width;
|
||||
mode.h = data->xinerama_info.height;
|
||||
mode.refresh_rate = 0;
|
||||
modedata = (SDL_DisplayModeData *) SDL_calloc(1, sizeof(SDL_DisplayModeData));
|
||||
if (modedata) {
|
||||
*modedata = *(SDL_DisplayModeData *)sdl_display->desktop_mode.driverdata;
|
||||
}
|
||||
mode.driverdata = modedata;
|
||||
if (!SDL_AddDisplayMode(sdl_display, &mode)) {
|
||||
SDL_free(modedata);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XRANDR
|
||||
if (data->use_xrandr) {
|
||||
Display *display = ((SDL_VideoData *) _this->driverdata)->display;
|
||||
XRRScreenResources *res;
|
||||
|
||||
res = X11_XRRGetScreenResources (display, RootWindow(display, data->screen));
|
||||
|
|
@ -960,37 +640,7 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display)
|
|||
}
|
||||
#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XVIDMODE
|
||||
if (data->use_vidmode &&
|
||||
X11_XF86VidModeGetAllModeLines(display, data->vidmode_screen, &nmodes, &modes)) {
|
||||
int i;
|
||||
SDL_DisplayModeData *modedata;
|
||||
|
||||
#ifdef X11MODES_DEBUG
|
||||
printf("VidMode modes: (unsorted)\n");
|
||||
for (i = 0; i < nmodes; ++i) {
|
||||
printf("Mode %d: %d x %d @ %d, flags: 0x%x\n", i,
|
||||
modes[i]->hdisplay, modes[i]->vdisplay,
|
||||
CalculateXVidModeRefreshRate(modes[i]), modes[i]->flags);
|
||||
}
|
||||
#endif
|
||||
for (i = 0; i < nmodes; ++i) {
|
||||
modedata = (SDL_DisplayModeData *) SDL_calloc(1, sizeof(SDL_DisplayModeData));
|
||||
if (!modedata) {
|
||||
continue;
|
||||
}
|
||||
mode.driverdata = modedata;
|
||||
|
||||
if (!SetXVidModeModeInfo(modes[i], &mode) || !SDL_AddDisplayMode(sdl_display, &mode)) {
|
||||
SDL_free(modedata);
|
||||
}
|
||||
}
|
||||
X11_XFree(modes);
|
||||
return;
|
||||
}
|
||||
#endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */
|
||||
|
||||
if (!data->use_xrandr && !data->use_vidmode) {
|
||||
if (!data->use_xrandr) {
|
||||
SDL_DisplayModeData *modedata;
|
||||
/* Add the desktop mode */
|
||||
mode = sdl_display->desktop_mode;
|
||||
|
|
@ -1005,6 +655,7 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display)
|
|||
}
|
||||
}
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XRANDR
|
||||
/* This catches an error from XRRSetScreenSize, as a workaround for now. */
|
||||
/* !!! FIXME: remove this later when we have a better solution. */
|
||||
static int (*PreXRRSetScreenSizeErrorHandler)(Display *, XErrorEvent *) = NULL;
|
||||
|
|
@ -1019,20 +670,21 @@ SDL_XRRSetScreenSizeErrHandler(Display *d, XErrorEvent *e)
|
|||
|
||||
return PreXRRSetScreenSizeErrorHandler(d, e);
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
X11_SetDisplayMode(_THIS, SDL_VideoDisplay * sdl_display, SDL_DisplayMode * mode)
|
||||
{
|
||||
SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata;
|
||||
Display *display = viddata->display;
|
||||
SDL_DisplayData *data = (SDL_DisplayData *) sdl_display->driverdata;
|
||||
SDL_DisplayModeData *modedata = (SDL_DisplayModeData *)mode->driverdata;
|
||||
int mm_width, mm_height;
|
||||
|
||||
viddata->last_mode_change_deadline = SDL_GetTicks() + (PENDING_FOCUS_TIME * 2);
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XRANDR
|
||||
if (data->use_xrandr) {
|
||||
Display *display = viddata->display;
|
||||
SDL_DisplayModeData *modedata = (SDL_DisplayModeData *)mode->driverdata;
|
||||
int mm_width, mm_height;
|
||||
XRRScreenResources *res;
|
||||
XRROutputInfo *output_info;
|
||||
XRRCrtcInfo *crtc;
|
||||
|
|
@ -1105,12 +757,6 @@ freeInfo:
|
|||
}
|
||||
#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XVIDMODE
|
||||
if (data->use_vidmode) {
|
||||
X11_XF86VidModeSwitchToMode(display, data->vidmode_screen, &modedata->vm_mode);
|
||||
}
|
||||
#endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1129,19 +775,6 @@ X11_GetDisplayBounds(_THIS, SDL_VideoDisplay * sdl_display, SDL_Rect * rect)
|
|||
rect->w = sdl_display->current_mode.w;
|
||||
rect->h = sdl_display->current_mode.h;
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
/* Get the real current bounds of the display */
|
||||
if (data->use_xinerama) {
|
||||
Display *display = ((SDL_VideoData *) _this->driverdata)->display;
|
||||
int screencount;
|
||||
XineramaScreenInfo *xinerama = X11_XineramaQueryScreens(display, &screencount);
|
||||
if (xinerama) {
|
||||
rect->x = xinerama[data->xinerama_screen].x_org;
|
||||
rect->y = xinerama[data->xinerama_screen].y_org;
|
||||
X11_XFree(xinerama);
|
||||
}
|
||||
}
|
||||
#endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,35 +35,20 @@ typedef struct
|
|||
float hdpi;
|
||||
float vdpi;
|
||||
|
||||
int use_xinerama;
|
||||
int use_xrandr;
|
||||
int use_vidmode;
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
XineramaScreenInfo xinerama_info;
|
||||
int xinerama_screen;
|
||||
#endif
|
||||
SDL_bool use_xrandr;
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XRANDR
|
||||
RROutput xrandr_output;
|
||||
#endif
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XVIDMODE
|
||||
int vidmode_screen;
|
||||
#endif
|
||||
|
||||
} SDL_DisplayData;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
#if SDL_VIDEO_DRIVER_X11_XRANDR
|
||||
RRMode xrandr_mode;
|
||||
#else
|
||||
int unused; /* just so struct isn't empty. */
|
||||
#endif
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XVIDMODE
|
||||
XF86VidModeModeInfo vm_mode;
|
||||
#endif
|
||||
|
||||
} SDL_DisplayModeData;
|
||||
|
||||
extern int X11_InitModes(_THIS);
|
||||
|
|
|
|||
|
|
@ -244,8 +244,8 @@ X11_CreateSystemCursor(SDL_SystemCursor id)
|
|||
case SDL_SYSTEM_CURSOR_WAIT: shape = XC_watch; break;
|
||||
case SDL_SYSTEM_CURSOR_CROSSHAIR: shape = XC_tcross; break;
|
||||
case SDL_SYSTEM_CURSOR_WAITARROW: shape = XC_watch; break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENWSE: shape = XC_fleur; break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENESW: shape = XC_fleur; break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENWSE: shape = XC_top_left_corner; break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENESW: shape = XC_top_right_corner; break;
|
||||
case SDL_SYSTEM_CURSOR_SIZEWE: shape = XC_sb_h_double_arrow; break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENS: shape = XC_sb_v_double_arrow; break;
|
||||
case SDL_SYSTEM_CURSOR_SIZEALL: shape = XC_fleur; break;
|
||||
|
|
@ -406,6 +406,8 @@ X11_GetGlobalMouseState(int *x, int *y)
|
|||
buttons |= (mask & Button1Mask) ? SDL_BUTTON_LMASK : 0;
|
||||
buttons |= (mask & Button2Mask) ? SDL_BUTTON_MMASK : 0;
|
||||
buttons |= (mask & Button3Mask) ? SDL_BUTTON_RMASK : 0;
|
||||
/* Use the SDL state for the extended buttons - it's better than nothing */
|
||||
buttons |= (SDL_GetMouseState(NULL, NULL) & (SDL_BUTTON_X1MASK|SDL_BUTTON_X2MASK));
|
||||
/* SDL_DisplayData->x,y point to screen origin, and adding them to mouse coordinates relative to root window doesn't do the right thing
|
||||
* (observed on dual monitor setup with primary display being the rightmost one - mouse was offset to the right).
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
|
||||
#ifndef SDL_X11_MODULE
|
||||
#define SDL_X11_MODULE(modname)
|
||||
|
|
@ -33,8 +33,6 @@ SDL_X11_MODULE(BASEXLIB)
|
|||
SDL_X11_SYM(XSizeHints*,XAllocSizeHints,(void),(),return)
|
||||
SDL_X11_SYM(XWMHints*,XAllocWMHints,(void),(),return)
|
||||
SDL_X11_SYM(XClassHint*,XAllocClassHint,(void),(),return)
|
||||
SDL_X11_SYM(int,XAutoRepeatOn,(Display* a),(a),return)
|
||||
SDL_X11_SYM(int,XAutoRepeatOff,(Display* a),(a),return)
|
||||
SDL_X11_SYM(int,XChangePointerControl,(Display* a,Bool b,Bool c,int d,int e,int f),(a,b,c,d,e,f),return)
|
||||
SDL_X11_SYM(int,XChangeProperty,(Display* a,Window b,Atom c,Atom d,int e,int f,_Xconst unsigned char* g,int h),(a,b,c,d,e,f,g,h),return)
|
||||
SDL_X11_SYM(Bool,XCheckIfEvent,(Display* a,XEvent *b,Bool (*c)(Display*,XEvent*,XPointer),XPointer d),(a,b,c,d),return)
|
||||
|
|
@ -72,7 +70,6 @@ SDL_X11_SYM(char*,XGetAtomName,(Display *a,Atom b),(a,b),return)
|
|||
SDL_X11_SYM(int,XGetInputFocus,(Display *a,Window *b,int *c),(a,b,c),return)
|
||||
SDL_X11_SYM(int,XGetErrorDatabaseText,(Display* a,_Xconst char* b,_Xconst char* c,_Xconst char* d,char* e,int f),(a,b,c,d,e,f),return)
|
||||
SDL_X11_SYM(XModifierKeymap*,XGetModifierMapping,(Display* a),(a),return)
|
||||
SDL_X11_SYM(int,XGetKeyboardControl,(Display* a, XKeyboardState* b),(a,b),return)
|
||||
SDL_X11_SYM(int,XGetPointerControl,(Display* a,int* b,int* c,int* d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(Window,XGetSelectionOwner,(Display* a,Atom b),(a,b),return)
|
||||
SDL_X11_SYM(XVisualInfo*,XGetVisualInfo,(Display* a,long b,XVisualInfo* c,int* d),(a,b,c,d),return)
|
||||
|
|
@ -263,15 +260,6 @@ SDL_X11_SYM(void,XdbeFreeVisualInfo,(XdbeScreenVisualInfo *visual_info),(visual_
|
|||
SDL_X11_SYM(XdbeBackBufferAttributes*,XdbeGetBackBufferAttributes,(Display *dpy,XdbeBackBuffer buffer),(dpy,buffer),return)
|
||||
#endif
|
||||
|
||||
/* Xinerama support */
|
||||
#if SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
SDL_X11_MODULE(XINERAMA)
|
||||
SDL_X11_SYM(Bool,XineramaIsActive,(Display *a),(a),return)
|
||||
SDL_X11_SYM(Bool,XineramaQueryExtension,(Display *a,int *b,int *c),(a,b,c),return)
|
||||
SDL_X11_SYM(Status,XineramaQueryVersion,(Display *a,int *b,int *c),(a,b,c),return)
|
||||
SDL_X11_SYM(XineramaScreenInfo*,XineramaQueryScreens,(Display *a, int *b),(a,b),return)
|
||||
#endif
|
||||
|
||||
/* XInput2 support for multiple mice, tablets, etc. */
|
||||
#if SDL_VIDEO_DRIVER_X11_XINPUT2
|
||||
SDL_X11_MODULE(XINPUT2)
|
||||
|
|
@ -324,20 +312,9 @@ SDL_X11_MODULE(XSHAPE)
|
|||
SDL_X11_SYM(void,XShapeCombineMask,(Display *dpy,Window dest,int dest_kind,int x_off,int y_off,Pixmap src,int op),(dpy,dest,dest_kind,x_off,y_off,src,op),)
|
||||
#endif
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XVIDMODE
|
||||
SDL_X11_MODULE(XVIDMODE)
|
||||
SDL_X11_SYM(Bool,XF86VidModeGetAllModeLines,(Display *a,int b,int *c,XF86VidModeModeInfo ***d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(Bool,XF86VidModeGetModeLine,(Display *a,int b,int *c,XF86VidModeModeLine *d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(Bool,XF86VidModeGetViewPort,(Display *a,int b,int *c,int *d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(Bool,XF86VidModeQueryExtension,(Display *a,int *b,int *c),(a,b,c),return)
|
||||
SDL_X11_SYM(Bool,XF86VidModeQueryVersion,(Display *a,int *b,int *c),(a,b,c),return)
|
||||
SDL_X11_SYM(Bool,XF86VidModeSwitchToMode,(Display *a,int b,XF86VidModeModeInfo *c),(a,b,c),return)
|
||||
SDL_X11_SYM(Bool,XF86VidModeLockModeSwitch,(Display *a,int b,int c),(a,b,c),return)
|
||||
#endif
|
||||
|
||||
#undef SDL_X11_MODULE
|
||||
#undef SDL_X11_SYM
|
||||
|
||||
/* *INDENT-ON* */
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
|||
|
|
@ -37,9 +37,6 @@
|
|||
#if SDL_VIDEO_DRIVER_X11_XDBE
|
||||
#include <X11/extensions/Xdbe.h>
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_X11_XINPUT2
|
||||
#include <X11/extensions/XInput2.h>
|
||||
#endif
|
||||
|
|
@ -52,9 +49,6 @@
|
|||
#if SDL_VIDEO_DRIVER_X11_XSHAPE
|
||||
#include <X11/extensions/shape.h>
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_X11_XVIDMODE
|
||||
#include <X11/extensions/xf86vmode.h>
|
||||
#endif
|
||||
|
||||
#include "../../core/linux/SDL_dbus.h"
|
||||
#include "../../core/linux/SDL_ime.h"
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include "../SDL_pixels_c.h"
|
||||
#include "../../events/SDL_keyboard_c.h"
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
|
||||
#include "SDL_x11video.h"
|
||||
#include "SDL_x11mouse.h"
|
||||
|
|
@ -72,13 +73,6 @@ X11_XIfEventTimeout(Display *display, XEvent *event_return, Bool (*predicate)(),
|
|||
}
|
||||
*/
|
||||
|
||||
static SDL_bool
|
||||
X11_IsWindowLegacyFullscreen(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
return (data->fswindow != 0);
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
X11_IsWindowMapped(_THIS, SDL_Window * window)
|
||||
{
|
||||
|
|
@ -1392,12 +1386,19 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis
|
|||
attrs.x, attrs.y, &x, &y, &childReturn);
|
||||
|
||||
if (!caught_x11_error) {
|
||||
if ((x != orig_x) || (y != orig_y) || (attrs.width != orig_w) || (attrs.height != orig_h)) {
|
||||
window->x = x;
|
||||
window->y = y;
|
||||
window->w = attrs.width;
|
||||
window->h = attrs.height;
|
||||
break; /* window moved, time to go. */
|
||||
SDL_bool window_changed = SDL_FALSE;
|
||||
if ((x != orig_x) || (y != orig_y)) {
|
||||
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MOVED, x, y);
|
||||
window_changed = SDL_TRUE;
|
||||
}
|
||||
|
||||
if ((attrs.width != orig_w) || (attrs.height != orig_h)) {
|
||||
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESIZED, attrs.width, attrs.height);
|
||||
window_changed = SDL_TRUE;
|
||||
}
|
||||
|
||||
if (window_changed) {
|
||||
break; /* window changed, time to go. */
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1433,161 +1434,12 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis
|
|||
X11_XFlush(display);
|
||||
}
|
||||
|
||||
/* This handles fullscreen itself, outside the Window Manager. */
|
||||
static void
|
||||
X11_BeginWindowFullscreenLegacy(_THIS, SDL_Window * window, SDL_VideoDisplay * _display)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
SDL_DisplayData *displaydata = (SDL_DisplayData *) _display->driverdata;
|
||||
Visual *visual = data->visual;
|
||||
Display *display = data->videodata->display;
|
||||
const int screen = displaydata->screen;
|
||||
Window root = RootWindow(display, screen);
|
||||
const int def_vis = (visual == DefaultVisual(display, screen));
|
||||
unsigned long xattrmask = 0;
|
||||
XSetWindowAttributes xattr;
|
||||
XEvent ev;
|
||||
SDL_Rect rect;
|
||||
|
||||
if ( data->fswindow ) {
|
||||
return; /* already fullscreen, I hope. */
|
||||
}
|
||||
|
||||
X11_GetDisplayBounds(_this, _display, &rect);
|
||||
|
||||
SDL_zero(xattr);
|
||||
xattr.override_redirect = True;
|
||||
xattrmask |= CWOverrideRedirect;
|
||||
xattr.background_pixel = def_vis ? BlackPixel(display, screen) : 0;
|
||||
xattrmask |= CWBackPixel;
|
||||
xattr.border_pixel = 0;
|
||||
xattrmask |= CWBorderPixel;
|
||||
xattr.colormap = data->colormap;
|
||||
xattrmask |= CWColormap;
|
||||
|
||||
data->fswindow = X11_XCreateWindow(display, root,
|
||||
rect.x, rect.y, rect.w, rect.h, 0,
|
||||
displaydata->depth, InputOutput,
|
||||
visual, xattrmask, &xattr);
|
||||
|
||||
X11_XSelectInput(display, data->fswindow, StructureNotifyMask);
|
||||
X11_XSetWindowBackground(display, data->fswindow, 0);
|
||||
X11_XInstallColormap(display, data->colormap);
|
||||
X11_XClearWindow(display, data->fswindow);
|
||||
X11_XMapRaised(display, data->fswindow);
|
||||
|
||||
/* Make sure the fswindow is in view by warping mouse to the corner */
|
||||
X11_XUngrabPointer(display, CurrentTime);
|
||||
X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y);
|
||||
|
||||
/* Wait to be mapped, filter Unmap event out if it arrives. */
|
||||
X11_XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->fswindow);
|
||||
X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->fswindow);
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XVIDMODE
|
||||
if ( displaydata->use_vidmode ) {
|
||||
X11_XF86VidModeLockModeSwitch(display, screen, True);
|
||||
}
|
||||
#endif
|
||||
|
||||
SetWindowBordered(display, displaydata->screen, data->xwindow, SDL_FALSE);
|
||||
|
||||
/* Center actual window within our cover-the-screen window. */
|
||||
X11_XReparentWindow(display, data->xwindow, data->fswindow,
|
||||
(rect.w - window->w) / 2, (rect.h - window->h) / 2);
|
||||
|
||||
/* Move the mouse to the upper left to make sure it's on-screen */
|
||||
X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y);
|
||||
|
||||
/* Center mouse in the fullscreen window. */
|
||||
rect.x += (rect.w / 2);
|
||||
rect.y += (rect.h / 2);
|
||||
X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y);
|
||||
|
||||
/* Wait to be mapped, filter Unmap event out if it arrives. */
|
||||
X11_XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow);
|
||||
X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow);
|
||||
|
||||
SDL_UpdateWindowGrab(window);
|
||||
}
|
||||
|
||||
static void
|
||||
X11_EndWindowFullscreenLegacy(_THIS, SDL_Window * window, SDL_VideoDisplay * _display)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
SDL_DisplayData *displaydata = (SDL_DisplayData *) _display->driverdata;
|
||||
Display *display = data->videodata->display;
|
||||
const int screen = displaydata->screen;
|
||||
Window root = RootWindow(display, screen);
|
||||
Window fswindow = data->fswindow;
|
||||
XEvent ev;
|
||||
|
||||
if (!data->fswindow) {
|
||||
return; /* already not fullscreen, I hope. */
|
||||
}
|
||||
|
||||
data->fswindow = None;
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_VIDMODE
|
||||
if ( displaydata->use_vidmode ) {
|
||||
X11_XF86VidModeLockModeSwitch(display, screen, False);
|
||||
}
|
||||
#endif
|
||||
|
||||
SDL_UpdateWindowGrab(window);
|
||||
|
||||
X11_XReparentWindow(display, data->xwindow, root, window->x, window->y);
|
||||
|
||||
/* flush these events so they don't confuse normal event handling */
|
||||
X11_XSync(display, False);
|
||||
X11_XCheckIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow);
|
||||
X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow);
|
||||
|
||||
SetWindowBordered(display, screen, data->xwindow,
|
||||
(window->flags & SDL_WINDOW_BORDERLESS) == 0);
|
||||
|
||||
X11_XWithdrawWindow(display, fswindow, screen);
|
||||
|
||||
/* Wait to be unmapped. */
|
||||
X11_XIfEvent(display, &ev, &isUnmapNotify, (XPointer)&fswindow);
|
||||
X11_XDestroyWindow(display, fswindow);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
X11_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * _display, SDL_bool fullscreen)
|
||||
{
|
||||
/* !!! FIXME: SDL_Hint? */
|
||||
SDL_bool legacy = SDL_FALSE;
|
||||
const char *env = SDL_getenv("SDL_VIDEO_X11_LEGACY_FULLSCREEN");
|
||||
if (env) {
|
||||
legacy = SDL_atoi(env);
|
||||
} else {
|
||||
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
||||
SDL_DisplayData *displaydata = (SDL_DisplayData *) _display->driverdata;
|
||||
if ( displaydata->use_vidmode ) {
|
||||
legacy = SDL_TRUE; /* the new stuff only works with XRandR. */
|
||||
} else if ( !videodata->net_wm ) {
|
||||
legacy = SDL_TRUE; /* The window manager doesn't support it */
|
||||
} else {
|
||||
/* !!! FIXME: look at the window manager name, and blacklist certain ones? */
|
||||
/* http://stackoverflow.com/questions/758648/find-the-name-of-the-x-window-manager */
|
||||
legacy = SDL_FALSE; /* try the new way. */
|
||||
}
|
||||
}
|
||||
|
||||
if (legacy) {
|
||||
if (fullscreen) {
|
||||
X11_BeginWindowFullscreenLegacy(_this, window, _display);
|
||||
} else {
|
||||
X11_EndWindowFullscreenLegacy(_this, window, _display);
|
||||
}
|
||||
} else {
|
||||
X11_SetWindowFullscreenViaWM(_this, window, _display, fullscreen);
|
||||
}
|
||||
X11_SetWindowFullscreenViaWM(_this, window, _display, fullscreen);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
X11_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
|
||||
{
|
||||
|
|
@ -1699,7 +1551,7 @@ X11_GetWindowICCProfile(_THIS, SDL_Window * window, size_t * size)
|
|||
unsigned long real_nitems;
|
||||
SDL_x11Prop atomProp;
|
||||
|
||||
X11_XGetWindowAttributes(display, X11_IsWindowLegacyFullscreen(_this, window) ? data->fswindow : data->xwindow, &attributes);
|
||||
X11_XGetWindowAttributes(display, data->xwindow, &attributes);
|
||||
if (X11_XScreenNumberOfScreen(attributes.screen) > 0) {
|
||||
SDL_snprintf(icc_atom_string, sizeof("_ICC_PROFILE_") + 12, "%s%d", "_ICC_PROFILE_", X11_XScreenNumberOfScreen(attributes.screen));
|
||||
} else {
|
||||
|
|
@ -1740,7 +1592,6 @@ X11_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
|||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
Display *display;
|
||||
SDL_bool oldstyle_fullscreen;
|
||||
|
||||
if (data == NULL) {
|
||||
return;
|
||||
|
|
@ -1748,13 +1599,7 @@ X11_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
|||
|
||||
display = data->videodata->display;
|
||||
|
||||
/* ICCCM2.0-compliant window managers can handle fullscreen windows
|
||||
If we're using XVidMode to change resolution we need to confine
|
||||
the cursor so we don't pan around the virtual desktop.
|
||||
*/
|
||||
oldstyle_fullscreen = X11_IsWindowLegacyFullscreen(_this, window);
|
||||
|
||||
if (oldstyle_fullscreen || grabbed) {
|
||||
if (grabbed) {
|
||||
/* If the window is unmapped, XGrab calls return GrabNotViewable,
|
||||
so when we get a MapNotify later, we'll try to update the grab as
|
||||
appropriate. */
|
||||
|
|
@ -1788,11 +1633,6 @@ X11_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
|||
|
||||
/* Raise the window if we grab the mouse */
|
||||
X11_XRaiseWindow(display, data->xwindow);
|
||||
|
||||
/* Now grab the keyboard on old-style fullscreen */
|
||||
if (oldstyle_fullscreen) {
|
||||
X11_SetWindowKeyboardGrab(_this, window, SDL_TRUE);
|
||||
}
|
||||
} else {
|
||||
X11_XUngrabPointer(display, CurrentTime);
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ typedef struct
|
|||
{
|
||||
SDL_Window *window;
|
||||
Window xwindow;
|
||||
Window fswindow; /* used if we can't have the WM handle fullscreen. */
|
||||
Visual *visual;
|
||||
Colormap colormap;
|
||||
#ifndef NO_SHARED_MEMORY
|
||||
|
|
|
|||
|
|
@ -97,10 +97,13 @@ void STD_FUNCTION_NAME(
|
|||
for(y=0; y<(height-(uv_y_sample_interval-1)); y+=uv_y_sample_interval)
|
||||
{
|
||||
const uint8_t *y_ptr1=Y+y*Y_stride,
|
||||
*y_ptr2=Y+(y+1)*Y_stride,
|
||||
*u_ptr=U+(y/uv_y_sample_interval)*UV_stride,
|
||||
*v_ptr=V+(y/uv_y_sample_interval)*UV_stride;
|
||||
|
||||
|
||||
#if uv_y_sample_interval > 1
|
||||
const uint8_t *y_ptr2=Y+(y+1)*Y_stride;
|
||||
#endif
|
||||
|
||||
uint8_t *rgb_ptr1=RGB+y*RGB_stride;
|
||||
|
||||
#if uv_y_sample_interval > 1
|
||||
|
|
@ -135,7 +138,9 @@ void STD_FUNCTION_NAME(
|
|||
#endif
|
||||
|
||||
y_ptr1+=2*y_pixel_stride;
|
||||
#if uv_y_sample_interval > 1
|
||||
y_ptr2+=2*y_pixel_stride;
|
||||
#endif
|
||||
u_ptr+=2*uv_pixel_stride/uv_x_sample_interval;
|
||||
v_ptr+=2*uv_pixel_stride/uv_x_sample_interval;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue