Fix conversion warnings for Unix
- Fix conversion & shadowing warnings - For the System & Window module
This commit is contained in:
parent
bc628c6b28
commit
e0f2356102
@ -293,7 +293,7 @@ In Utf<16>::decode(In begin, In end, Uint32& output, Uint32 replacement)
|
||||
if ((second >= 0xDC00) && (second <= 0xDFFF))
|
||||
{
|
||||
// The second element is valid: convert the two elements to a UTF-32 character
|
||||
output = ((first - 0xD800) << 10) + (second - 0xDC00) + 0x0010000;
|
||||
output = ((first - 0xD800u) << 10) + (second - 0xDC00) + 0x0010000;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ Int64 FileInputStream::read(void* data, Int64 size)
|
||||
return m_file->read(data, size);
|
||||
#else
|
||||
if (m_file)
|
||||
return std::fread(data, 1, static_cast<std::size_t>(size), m_file);
|
||||
return static_cast<Int64>(std::fread(data, 1, static_cast<std::size_t>(size), m_file));
|
||||
else
|
||||
return -1;
|
||||
#endif
|
||||
|
@ -44,7 +44,7 @@ m_offset(0)
|
||||
void MemoryInputStream::open(const void* data, std::size_t sizeInBytes)
|
||||
{
|
||||
m_data = static_cast<const char*>(data);
|
||||
m_size = sizeInBytes;
|
||||
m_size = static_cast<Int64>(sizeInBytes);
|
||||
m_offset = 0;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ m_microseconds(0)
|
||||
////////////////////////////////////////////////////////////
|
||||
float Time::asSeconds() const
|
||||
{
|
||||
return m_microseconds / 1000000.f;
|
||||
return static_cast<float>(static_cast<double>(m_microseconds) / 1000000.0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,7 +54,7 @@ Time ClockImpl::getCurrentTime()
|
||||
// POSIX implementation
|
||||
timespec time;
|
||||
clock_gettime(CLOCK_MONOTONIC, &time);
|
||||
return sf::microseconds(static_cast<Uint64>(time.tv_sec) * 1000000 + time.tv_nsec / 1000);
|
||||
return sf::microseconds(time.tv_sec * 1000000 + time.tv_nsec / 1000);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ namespace priv
|
||||
////////////////////////////////////////////////////////////
|
||||
void sleepImpl(Time time)
|
||||
{
|
||||
Uint64 usecs = time.asMicroseconds();
|
||||
Int64 usecs = time.asMicroseconds();
|
||||
|
||||
// Construct the time to wait
|
||||
timespec ti;
|
||||
|
@ -163,7 +163,7 @@ m_config (NULL)
|
||||
#if !defined(SFML_SYSTEM_ANDROID)
|
||||
// Create EGL surface (except on Android because the window is created
|
||||
// asynchronously, its activity manager will call it for us)
|
||||
createSurface((EGLNativeWindowType)owner->getSystemHandle());
|
||||
createSurface(owner->getSystemHandle());
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -215,7 +215,7 @@ GlFunctionPointer EglContext::getFunction(const char* name)
|
||||
{
|
||||
EglContextImpl::ensureInit();
|
||||
|
||||
return reinterpret_cast<GlFunctionPointer>(eglGetProcAddress(name));
|
||||
return eglGetProcAddress(name);
|
||||
}
|
||||
|
||||
|
||||
@ -306,7 +306,7 @@ EGLConfig EglContext::getBestConfig(EGLDisplay display, unsigned int bitsPerPixe
|
||||
EGL_BUFFER_SIZE, static_cast<EGLint>(bitsPerPixel),
|
||||
EGL_DEPTH_SIZE, static_cast<EGLint>(settings.depthBits),
|
||||
EGL_STENCIL_SIZE, static_cast<EGLint>(settings.stencilBits),
|
||||
EGL_SAMPLE_BUFFERS, static_cast<EGLint>(settings.antialiasingLevel ? 1 : 0),
|
||||
EGL_SAMPLE_BUFFERS, settings.antialiasingLevel ? 1 : 0,
|
||||
EGL_SAMPLES, static_cast<EGLint>(settings.antialiasingLevel),
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
|
||||
@ -337,21 +337,21 @@ void EglContext::updateSettings()
|
||||
if (result == EGL_FALSE)
|
||||
err() << "Failed to retrieve EGL_DEPTH_SIZE" << std::endl;
|
||||
|
||||
m_settings.depthBits = tmp;
|
||||
m_settings.depthBits = static_cast<unsigned int>(tmp);
|
||||
|
||||
eglCheck(result = eglGetConfigAttrib(m_display, m_config, EGL_STENCIL_SIZE, &tmp));
|
||||
|
||||
if (result == EGL_FALSE)
|
||||
err() << "Failed to retrieve EGL_STENCIL_SIZE" << std::endl;
|
||||
|
||||
m_settings.stencilBits = tmp;
|
||||
m_settings.stencilBits = static_cast<unsigned int>(tmp);
|
||||
|
||||
eglCheck(result = eglGetConfigAttrib(m_display, m_config, EGL_SAMPLES, &tmp));
|
||||
|
||||
if (result == EGL_FALSE)
|
||||
err() << "Failed to retrieve EGL_SAMPLES" << std::endl;
|
||||
|
||||
m_settings.antialiasingLevel = tmp;
|
||||
m_settings.antialiasingLevel = static_cast<unsigned int>(tmp);
|
||||
|
||||
m_settings.majorVersion = 1;
|
||||
m_settings.minorVersion = 1;
|
||||
|
@ -297,8 +297,8 @@ namespace
|
||||
(version[prefixLength + 1] == '.') &&
|
||||
std::isdigit(version[prefixLength + 2]))
|
||||
{
|
||||
major = version[prefixLength] - '0';
|
||||
minor = version[prefixLength + 2] - '0';
|
||||
major = static_cast<unsigned int>(version[prefixLength] - '0');
|
||||
minor = static_cast<unsigned int>(version[prefixLength + 2] - '0');
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -923,8 +923,8 @@ void GlContext::checkSettings(const ContextSettings& requestedSettings)
|
||||
}
|
||||
}
|
||||
|
||||
int version = m_settings.majorVersion * 10 + m_settings.minorVersion;
|
||||
int requestedVersion = requestedSettings.majorVersion * 10 + requestedSettings.minorVersion;
|
||||
int version = static_cast<int>(m_settings.majorVersion * 10u + m_settings.minorVersion);
|
||||
int requestedVersion = static_cast<int>(requestedSettings.majorVersion * 10u + requestedSettings.minorVersion);
|
||||
|
||||
if ((m_settings.attributeFlags != requestedSettings.attributeFlags) ||
|
||||
(version < requestedVersion) ||
|
||||
|
@ -64,7 +64,7 @@ const Joystick::Identification& JoystickManager::getIdentification(unsigned int
|
||||
////////////////////////////////////////////////////////////
|
||||
void JoystickManager::update()
|
||||
{
|
||||
for (int i = 0; i < Joystick::Count; ++i)
|
||||
for (unsigned int i = 0; i < Joystick::Count; ++i)
|
||||
{
|
||||
Item& item = m_joysticks[i];
|
||||
|
||||
|
@ -209,7 +209,7 @@ void ClipboardImpl::processEvent(XEvent& windowEvent)
|
||||
// Notification that the current selection owner
|
||||
// has responded to our request
|
||||
|
||||
XSelectionEvent& selectionEvent = *reinterpret_cast<XSelectionEvent*>(&windowEvent.xselection);
|
||||
XSelectionEvent& selectionEvent = windowEvent.xselection;
|
||||
|
||||
m_clipboardContents.clear();
|
||||
|
||||
@ -274,7 +274,7 @@ void ClipboardImpl::processEvent(XEvent& windowEvent)
|
||||
case SelectionRequest:
|
||||
{
|
||||
// Respond to a request for our clipboard contents
|
||||
XSelectionRequestEvent& selectionRequestEvent = *reinterpret_cast<XSelectionRequestEvent*>(&windowEvent.xselectionrequest);
|
||||
XSelectionRequestEvent& selectionRequestEvent = windowEvent.xselectionrequest;
|
||||
|
||||
// Our reply
|
||||
XSelectionEvent selectionEvent;
|
||||
@ -307,7 +307,7 @@ void ClipboardImpl::processEvent(XEvent& windowEvent)
|
||||
32,
|
||||
PropModeReplace,
|
||||
reinterpret_cast<unsigned char*>(&targets[0]),
|
||||
targets.size()
|
||||
static_cast<int>(targets.size())
|
||||
);
|
||||
|
||||
// Notify the requestor that they can read the targets from their window property
|
||||
@ -330,7 +330,7 @@ void ClipboardImpl::processEvent(XEvent& windowEvent)
|
||||
8,
|
||||
PropModeReplace,
|
||||
reinterpret_cast<const unsigned char*>(data.c_str()),
|
||||
data.size()
|
||||
static_cast<int>(data.size())
|
||||
);
|
||||
|
||||
// Notify the requestor that they can read the data from their window property
|
||||
@ -353,8 +353,8 @@ void ClipboardImpl::processEvent(XEvent& windowEvent)
|
||||
m_utf8String,
|
||||
8,
|
||||
PropModeReplace,
|
||||
reinterpret_cast<const unsigned char*>(data.c_str()),
|
||||
data.size()
|
||||
data.c_str(),
|
||||
static_cast<int>(data.size())
|
||||
);
|
||||
|
||||
// Notify the requestor that they can read the data from their window property
|
||||
|
@ -73,17 +73,17 @@ bool CursorImpl::loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hot
|
||||
bool CursorImpl::loadFromPixelsARGB(const Uint8* pixels, Vector2u size, Vector2u hotspot)
|
||||
{
|
||||
// Create cursor image, convert from RGBA to ARGB.
|
||||
XcursorImage* cursorImage = XcursorImageCreate(size.x, size.y);
|
||||
XcursorImage* cursorImage = XcursorImageCreate(static_cast<int>(size.x), static_cast<int>(size.y));
|
||||
cursorImage->xhot = hotspot.x;
|
||||
cursorImage->yhot = hotspot.y;
|
||||
|
||||
const std::size_t numPixels = size.x * size.y;
|
||||
for (std::size_t pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex)
|
||||
{
|
||||
cursorImage->pixels[pixelIndex] = pixels[pixelIndex * 4 + 2] +
|
||||
cursorImage->pixels[pixelIndex] = static_cast<Uint8>(pixels[pixelIndex * 4 + 2] +
|
||||
(pixels[pixelIndex * 4 + 1] << 8) +
|
||||
(pixels[pixelIndex * 4 + 0] << 16) +
|
||||
(pixels[pixelIndex * 4 + 3] << 24);
|
||||
(pixels[pixelIndex * 4 + 3] << 24));
|
||||
}
|
||||
|
||||
// Create the cursor.
|
||||
@ -119,26 +119,30 @@ bool CursorImpl::loadFromPixelsMonochrome(const Uint8* pixels, Vector2u size, Ve
|
||||
|
||||
// Turn on pixel that are not transparent
|
||||
Uint8 opacity = pixels[pixelIndex * 4 + 3] > 0 ? 1 : 0;
|
||||
mask[byteIndex] |= opacity << bitIndex;
|
||||
mask[byteIndex] |= static_cast<Uint8>(opacity << bitIndex);
|
||||
|
||||
// Choose between black/background & white/foreground color for each pixel,
|
||||
// based on the pixel color intensity: on average, if a channel is "active"
|
||||
// at 50%, the bit is white.
|
||||
int intensity = (pixels[pixelIndex * 4 + 0] + pixels[pixelIndex * 4 + 1] + pixels[pixelIndex * 4 + 2]) / 3;
|
||||
Uint8 bit = intensity > 128 ? 1 : 0;
|
||||
data[byteIndex] |= bit << bitIndex;
|
||||
data[byteIndex] |= static_cast<Uint8>(bit << bitIndex);
|
||||
}
|
||||
}
|
||||
|
||||
Pixmap maskPixmap = XCreateBitmapFromData(m_display, XDefaultRootWindow(m_display),
|
||||
(char*)&mask[0], size.x, size.y);
|
||||
reinterpret_cast<char*>(&mask[0]), size.x, size.y);
|
||||
Pixmap dataPixmap = XCreateBitmapFromData(m_display, XDefaultRootWindow(m_display),
|
||||
(char*)&data[0], size.x, size.y);
|
||||
reinterpret_cast<char*>(&data[0]), size.x, size.y);
|
||||
|
||||
// Define the foreground color as white and the background as black.
|
||||
XColor fg, bg;
|
||||
fg.red = fg.blue = fg.green = -1;
|
||||
bg.red = bg.blue = bg.green = 0;
|
||||
fg.red = 0xFFFF;
|
||||
fg.blue = 0xFFFF;
|
||||
fg.green = 0xFFFF;
|
||||
bg.red = 0x0000;
|
||||
bg.blue = 0x0000;
|
||||
bg.green = 0x0000;
|
||||
|
||||
// Create the monochrome cursor.
|
||||
m_cursor = XCreatePixmapCursor(m_display,
|
||||
|
@ -149,7 +149,7 @@ m_ownsWindow(false)
|
||||
ensureExtensionsInit(m_display, DefaultScreen(m_display));
|
||||
|
||||
// Create the rendering surface from the owner window
|
||||
createSurface(static_cast< ::Window>(owner->getSystemHandle()));
|
||||
createSurface(owner->getSystemHandle());
|
||||
|
||||
// Create the context
|
||||
createContext(shared);
|
||||
@ -224,7 +224,7 @@ GlxContext::~GlxContext()
|
||||
////////////////////////////////////////////////////////////
|
||||
GlFunctionPointer GlxContext::getFunction(const char* name)
|
||||
{
|
||||
return reinterpret_cast<GlFunctionPointer>(glXGetProcAddress(reinterpret_cast<const GLubyte*>(name)));
|
||||
return glXGetProcAddress(reinterpret_cast<const GLubyte*>(name));
|
||||
}
|
||||
|
||||
|
||||
@ -439,7 +439,7 @@ void GlxContext::updateSettingsFromVisualInfo(XVisualInfo* visualInfo)
|
||||
|
||||
m_settings.depthBits = static_cast<unsigned int>(depth);
|
||||
m_settings.stencilBits = static_cast<unsigned int>(stencil);
|
||||
m_settings.antialiasingLevel = multiSampling ? samples : 0;
|
||||
m_settings.antialiasingLevel = multiSampling ? static_cast<unsigned int>(samples) : 0;
|
||||
m_settings.sRgbCapable = (sRgb == True);
|
||||
}
|
||||
|
||||
@ -683,9 +683,9 @@ void GlxContext::createContext(GlxContext* shared)
|
||||
if ((m_settings.majorVersion > 1) || ((m_settings.majorVersion == 1) && (m_settings.minorVersion > 1)))
|
||||
{
|
||||
attributes.push_back(GLX_CONTEXT_MAJOR_VERSION_ARB);
|
||||
attributes.push_back(m_settings.majorVersion);
|
||||
attributes.push_back(static_cast<int>(m_settings.majorVersion));
|
||||
attributes.push_back(GLX_CONTEXT_MINOR_VERSION_ARB);
|
||||
attributes.push_back(m_settings.minorVersion);
|
||||
attributes.push_back(static_cast<int>(m_settings.minorVersion));
|
||||
}
|
||||
|
||||
// Check if setting the profile is supported
|
||||
|
@ -155,12 +155,12 @@ namespace
|
||||
// If not mapped before and it got added, map it now
|
||||
const char* syspath = udev_device_get_syspath(udevDevice);
|
||||
|
||||
JoystickRecord record;
|
||||
record.deviceNode = devnode;
|
||||
record.systemPath = syspath ? syspath : "";
|
||||
record.plugged = true;
|
||||
JoystickRecord newRecord;
|
||||
newRecord.deviceNode = devnode;
|
||||
newRecord.systemPath = syspath ? syspath : "";
|
||||
newRecord.plugged = true;
|
||||
|
||||
joystickList.push_back(record);
|
||||
joystickList.push_back(newRecord);
|
||||
}
|
||||
else if (std::strstr(action, "remove"))
|
||||
{
|
||||
@ -211,12 +211,12 @@ namespace
|
||||
|
||||
udev_list_entry_foreach(device, devices) {
|
||||
const char* syspath = udev_list_entry_get_name(device);
|
||||
udev_device* udevDevice = udev_device_new_from_syspath(udevContext, syspath);
|
||||
udev_device* newUdevDevice = udev_device_new_from_syspath(udevContext, syspath);
|
||||
|
||||
if (udevDevice && isJoystick(udevDevice))
|
||||
if (newUdevDevice && isJoystick(newUdevDevice))
|
||||
{
|
||||
// Since isJoystick returned true, this has to succeed
|
||||
const char* devnode = udev_device_get_devnode(udevDevice);
|
||||
const char* devnode = udev_device_get_devnode(newUdevDevice);
|
||||
|
||||
JoystickList::iterator record;
|
||||
|
||||
@ -233,16 +233,16 @@ namespace
|
||||
// If not mapped before, map it now
|
||||
if (record == joystickList.end())
|
||||
{
|
||||
JoystickRecord record;
|
||||
record.deviceNode = devnode;
|
||||
record.systemPath = syspath;
|
||||
record.plugged = true;
|
||||
JoystickRecord nweRecord;
|
||||
nweRecord.deviceNode = devnode;
|
||||
nweRecord.systemPath = syspath;
|
||||
nweRecord.plugged = true;
|
||||
|
||||
joystickList.push_back(record);
|
||||
joystickList.push_back(nweRecord);
|
||||
}
|
||||
}
|
||||
|
||||
udev_device_unref(udevDevice);
|
||||
udev_device_unref(newUdevDevice);
|
||||
}
|
||||
|
||||
udev_enumerate_unref(udevEnumerator);
|
||||
@ -602,7 +602,7 @@ JoystickCaps JoystickImpl::getCapabilities() const
|
||||
// Get the number of buttons
|
||||
char buttonCount;
|
||||
ioctl(m_file, JSIOCGBUTTONS, &buttonCount);
|
||||
caps.buttonCount = buttonCount;
|
||||
caps.buttonCount = static_cast<unsigned int>(buttonCount);
|
||||
if (caps.buttonCount > Joystick::ButtonCount)
|
||||
caps.buttonCount = Joystick::ButtonCount;
|
||||
|
||||
@ -649,7 +649,7 @@ JoystickState JoystickImpl::JoystickImpl::update()
|
||||
|
||||
// pop events from the joystick file
|
||||
js_event joyState;
|
||||
int result = read(m_file, &joyState, sizeof(joyState));
|
||||
ssize_t result = read(m_file, &joyState, sizeof(joyState));
|
||||
while (result > 0)
|
||||
{
|
||||
switch (joyState.type & ~JS_EVENT_INIT)
|
||||
|
@ -73,7 +73,9 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
|
||||
for (int j = 0; j < nbSizes; ++j)
|
||||
{
|
||||
// Convert to VideoMode
|
||||
VideoMode mode(sizes[j].width, sizes[j].height, depths[i]);
|
||||
VideoMode mode(static_cast<unsigned int>(sizes[j].width),
|
||||
static_cast<unsigned int>(sizes[j].height),
|
||||
static_cast<unsigned int>(depths[i]));
|
||||
|
||||
Rotation currentRotation;
|
||||
XRRConfigRotations(config, ¤tRotation);
|
||||
@ -149,12 +151,14 @@ VideoMode VideoModeImpl::getDesktopMode()
|
||||
XRRScreenSize* sizes = XRRConfigSizes(config, &nbSizes);
|
||||
if (sizes && (nbSizes > 0))
|
||||
{
|
||||
desktopMode = VideoMode(sizes[currentMode].width, sizes[currentMode].height, DefaultDepth(display, screen));
|
||||
desktopMode = VideoMode(static_cast<unsigned int>(sizes[currentMode].width),
|
||||
static_cast<unsigned int>(sizes[currentMode].height),
|
||||
static_cast<unsigned int>(DefaultDepth(display, screen)));
|
||||
|
||||
Rotation currentRotation;
|
||||
XRRConfigRotations(config, ¤tRotation);
|
||||
Rotation modeRotation;
|
||||
XRRConfigRotations(config, &modeRotation);
|
||||
|
||||
if (currentRotation == RR_Rotate_90 || currentRotation == RR_Rotate_270)
|
||||
if (modeRotation == RR_Rotate_90 || modeRotation == RR_Rotate_270)
|
||||
std::swap(desktopMode.width, desktopMode.height);
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ namespace
|
||||
// Predicate we use to find key repeat events in processEvent
|
||||
struct KeyRepeatFinder
|
||||
{
|
||||
KeyRepeatFinder(unsigned int keycode, Time time) : keycode(keycode), time(time) {}
|
||||
KeyRepeatFinder(unsigned int initalKeycode, Time initialTime) : keycode(initalKeycode), time(initialTime) {}
|
||||
|
||||
// Predicate operator that checks event type, keycode and timestamp
|
||||
bool operator()(const XEvent& event)
|
||||
@ -119,8 +119,8 @@ namespace
|
||||
|
||||
while ((result = read(file, &buffer[offset], 256)) > 0)
|
||||
{
|
||||
buffer.resize(buffer.size() + result, 0);
|
||||
offset += result;
|
||||
buffer.resize(buffer.size() + static_cast<std::size_t>(result), 0);
|
||||
offset += static_cast<std::size_t>(result);
|
||||
}
|
||||
|
||||
::close(file);
|
||||
@ -335,7 +335,7 @@ namespace
|
||||
{
|
||||
gotFrameExtents = true;
|
||||
|
||||
long* extents = (long*) data;
|
||||
long* extents = reinterpret_cast<long*>(data);
|
||||
|
||||
xFrameExtent = extents[0]; // Left.
|
||||
yFrameExtent = extents[2]; // Top.
|
||||
@ -573,12 +573,12 @@ m_lastInputTime (0)
|
||||
}
|
||||
else
|
||||
{
|
||||
windowPosition.x = (DisplayWidth(m_display, m_screen) - mode.width) / 2;
|
||||
windowPosition.y = (DisplayWidth(m_display, m_screen) - mode.height) / 2;
|
||||
windowPosition.x = (DisplayWidth(m_display, m_screen) - static_cast<int>(mode.width)) / 2;
|
||||
windowPosition.y = (DisplayWidth(m_display, m_screen) - static_cast<int>(mode.height)) / 2;
|
||||
}
|
||||
|
||||
int width = mode.width;
|
||||
int height = mode.height;
|
||||
unsigned int width = mode.width;
|
||||
unsigned int height = mode.height;
|
||||
|
||||
Visual* visual = NULL;
|
||||
int depth = 0;
|
||||
@ -626,11 +626,11 @@ m_lastInputTime (0)
|
||||
setProtocols();
|
||||
|
||||
// Set the WM initial state to the normal state
|
||||
XWMHints* hints = XAllocWMHints();
|
||||
hints->flags = StateHint;
|
||||
hints->initial_state = NormalState;
|
||||
XSetWMHints(m_display, m_window, hints);
|
||||
XFree(hints);
|
||||
XWMHints* xHints = XAllocWMHints();
|
||||
xHints->flags = StateHint;
|
||||
xHints->initial_state = NormalState;
|
||||
XSetWMHints(m_display, m_window, xHints);
|
||||
XFree(xHints);
|
||||
|
||||
// If not in fullscreen, set the window's style (tell the window manager to
|
||||
// change our window's decorations and functions according to the requested style)
|
||||
@ -705,8 +705,8 @@ m_lastInputTime (0)
|
||||
m_useSizeHints = true;
|
||||
XSizeHints* sizeHints = XAllocSizeHints();
|
||||
sizeHints->flags = PMinSize | PMaxSize | USPosition;
|
||||
sizeHints->min_width = sizeHints->max_width = width;
|
||||
sizeHints->min_height = sizeHints->max_height = height;
|
||||
sizeHints->min_width = sizeHints->max_width = static_cast<int>(width);
|
||||
sizeHints->min_height = sizeHints->max_height = static_cast<int>(height);
|
||||
sizeHints->x = windowPosition.x;
|
||||
sizeHints->y = windowPosition.y;
|
||||
XSetWMNormalHints(m_display, m_window, sizeHints);
|
||||
@ -867,7 +867,7 @@ Vector2i WindowImplX11::getPosition() const
|
||||
{
|
||||
// Get final X/Y coordinates: subtract EWMH frame extents from
|
||||
// absolute window position.
|
||||
return Vector2i((xAbsRelToRoot - xFrameExtent), (yAbsRelToRoot - yFrameExtent));
|
||||
return Vector2i((xAbsRelToRoot - static_cast<int>(xFrameExtent)), (yAbsRelToRoot - static_cast<int>(yFrameExtent)));
|
||||
}
|
||||
|
||||
// CASE 3: EWMH frame extents were not available, use geometry.
|
||||
@ -917,7 +917,7 @@ Vector2u WindowImplX11::getSize() const
|
||||
{
|
||||
XWindowAttributes attributes;
|
||||
XGetWindowAttributes(m_display, m_window, &attributes);
|
||||
return Vector2u(attributes.width, attributes.height);
|
||||
return Vector2u(Vector2i(attributes.width, attributes.height));
|
||||
}
|
||||
|
||||
|
||||
@ -929,8 +929,8 @@ void WindowImplX11::setSize(const Vector2u& size)
|
||||
{
|
||||
XSizeHints* sizeHints = XAllocSizeHints();
|
||||
sizeHints->flags = PMinSize | PMaxSize;
|
||||
sizeHints->min_width = sizeHints->max_width = size.x;
|
||||
sizeHints->min_height = sizeHints->max_height = size.y;
|
||||
sizeHints->min_width = sizeHints->max_width = static_cast<int>(size.x);
|
||||
sizeHints->min_height = sizeHints->max_height = static_cast<int>(size.y);
|
||||
XSetWMNormalHints(m_display, m_window, sizeHints);
|
||||
XFree(sizeHints);
|
||||
}
|
||||
@ -955,12 +955,12 @@ void WindowImplX11::setTitle(const String& title)
|
||||
// Set the _NET_WM_NAME atom, which specifies a UTF-8 encoded window title.
|
||||
Atom wmName = getAtom("_NET_WM_NAME", false);
|
||||
XChangeProperty(m_display, m_window, wmName, useUtf8, 8,
|
||||
PropModeReplace, utf8Title.c_str(), utf8Title.size());
|
||||
PropModeReplace, utf8Title.c_str(), static_cast<int>(utf8Title.size()));
|
||||
|
||||
// Set the _NET_WM_ICON_NAME atom, which specifies a UTF-8 encoded window title.
|
||||
Atom wmIconName = getAtom("_NET_WM_ICON_NAME", false);
|
||||
XChangeProperty(m_display, m_window, wmIconName, useUtf8, 8,
|
||||
PropModeReplace, utf8Title.c_str(), utf8Title.size());
|
||||
PropModeReplace, utf8Title.c_str(), static_cast<int>(utf8Title.size()));
|
||||
|
||||
// Set the non-Unicode title as a fallback for window managers who don't support _NET_WM_NAME.
|
||||
#ifdef X_HAVE_UTF8_STRING
|
||||
@ -1003,8 +1003,8 @@ void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8
|
||||
|
||||
// Create the icon pixmap
|
||||
Visual* defVisual = DefaultVisual(m_display, m_screen);
|
||||
unsigned int defDepth = DefaultDepth(m_display, m_screen);
|
||||
XImage* iconImage = XCreateImage(m_display, defVisual, defDepth, ZPixmap, 0, (char*)iconPixels, width, height, 32, 0);
|
||||
unsigned int defDepth = static_cast<unsigned int>(DefaultDepth(m_display, m_screen));
|
||||
XImage* iconImage = XCreateImage(m_display, defVisual, defDepth, ZPixmap, 0, reinterpret_cast<char*>(iconPixels), width, height, 32, 0);
|
||||
if (!iconImage)
|
||||
{
|
||||
err() << "Failed to set the window's icon" << std::endl;
|
||||
@ -1036,12 +1036,12 @@ void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8
|
||||
if (i * 8 + k < width)
|
||||
{
|
||||
Uint8 opacity = (pixels[(i * 8 + k + j * width) * 4 + 3] > 0) ? 1 : 0;
|
||||
maskPixels[i + j * pitch] |= (opacity << k);
|
||||
maskPixels[i + j * pitch] |= static_cast<Uint8>(opacity << k);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m_iconMaskPixmap = XCreatePixmapFromBitmapData(m_display, m_window, (char*)&maskPixels[0], width, height, 1, 0, 1);
|
||||
m_iconMaskPixmap = XCreatePixmapFromBitmapData(m_display, m_window, reinterpret_cast<char*>(&maskPixels[0]), width, height, 1, 0, 1);
|
||||
|
||||
// Send our new icon to the window through the WMHints
|
||||
XWMHints* hints = XAllocWMHints();
|
||||
@ -1061,10 +1061,10 @@ void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8
|
||||
|
||||
for (std::size_t i = 0; i < width * height; ++i)
|
||||
{
|
||||
*ptr++ = (pixels[i * 4 + 2] << 0 ) |
|
||||
*ptr++ = static_cast<unsigned long>((pixels[i * 4 + 2] << 0 ) |
|
||||
(pixels[i * 4 + 1] << 8 ) |
|
||||
(pixels[i * 4 + 0] << 16) |
|
||||
(pixels[i * 4 + 3] << 24);
|
||||
(pixels[i * 4 + 3] << 24));
|
||||
}
|
||||
|
||||
Atom netWmIcon = getAtom("_NET_WM_ICON");
|
||||
@ -1076,7 +1076,7 @@ void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8
|
||||
32,
|
||||
PropModeReplace,
|
||||
reinterpret_cast<const unsigned char*>(&icccmIconPixels[0]),
|
||||
2 + width * height);
|
||||
static_cast<int>(2 + width * height));
|
||||
|
||||
XFlush(m_display);
|
||||
}
|
||||
@ -1269,7 +1269,7 @@ void WindowImplX11::grabFocus()
|
||||
event.xclient.format = 32;
|
||||
event.xclient.message_type = netActiveWindow;
|
||||
event.xclient.data.l[0] = 1; // Normal application
|
||||
event.xclient.data.l[1] = m_lastInputTime;
|
||||
event.xclient.data.l[1] = static_cast<long>(m_lastInputTime);
|
||||
event.xclient.data.l[2] = 0; // We don't know the currently active window
|
||||
|
||||
int result = XSendEvent(m_display,
|
||||
@ -1504,7 +1504,7 @@ void WindowImplX11::switchToFullscreen()
|
||||
event.xclient.format = 32;
|
||||
event.xclient.message_type = netWmState;
|
||||
event.xclient.data.l[0] = 1; // _NET_WM_STATE_ADD
|
||||
event.xclient.data.l[1] = netWmStateFullscreen;
|
||||
event.xclient.data.l[1] = static_cast<long>(netWmStateFullscreen);
|
||||
event.xclient.data.l[2] = 0; // No second property
|
||||
event.xclient.data.l[3] = 1; // Normal window
|
||||
|
||||
@ -1579,7 +1579,7 @@ void WindowImplX11::setProtocols()
|
||||
32,
|
||||
PropModeReplace,
|
||||
reinterpret_cast<const unsigned char*>(&atoms[0]),
|
||||
atoms.size());
|
||||
static_cast<int>(atoms.size()));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1819,8 +1819,8 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::Resized;
|
||||
event.size.width = windowEvent.xconfigure.width;
|
||||
event.size.height = windowEvent.xconfigure.height;
|
||||
event.size.width = static_cast<unsigned int>(windowEvent.xconfigure.width);
|
||||
event.size.height = static_cast<unsigned int>(windowEvent.xconfigure.height);
|
||||
pushEvent(event);
|
||||
|
||||
m_previousSize.x = windowEvent.xconfigure.width;
|
||||
|
@ -307,7 +307,7 @@ private:
|
||||
XIC m_inputContext; ///< Input context used to get unicode input in our window
|
||||
std::deque<XEvent> m_events; ///< Queue we use to store pending events for this window
|
||||
bool m_isExternal; ///< Tell whether the window has been created externally or by SFML
|
||||
int m_oldVideoMode; ///< Video mode in use before we switch to fullscreen
|
||||
RRMode m_oldVideoMode; ///< Video mode in use before we switch to fullscreen
|
||||
RRCrtc m_oldRRCrtc; ///< RRCrtc in use before we switch to fullscreen
|
||||
::Cursor m_hiddenCursor; ///< As X11 doesn't provide cursor hiding, we must create a transparent one
|
||||
::Cursor m_lastCursor; ///< Last cursor used -- this data is not owned by the window and is required to be always valid
|
||||
|
@ -88,7 +88,7 @@ void Window::create(VideoMode mode, const String& title, Uint32 style, const Con
|
||||
if (getFullscreenWindow())
|
||||
{
|
||||
err() << "Creating two fullscreen windows is not allowed, switching to windowed mode" << std::endl;
|
||||
style &= ~Style::Fullscreen;
|
||||
style &= ~static_cast<Uint32>(Style::Fullscreen);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -107,7 +107,7 @@ void Window::create(VideoMode mode, const String& title, Uint32 style, const Con
|
||||
// Check validity of style according to the underlying platform
|
||||
#if defined(SFML_SYSTEM_IOS) || defined(SFML_SYSTEM_ANDROID)
|
||||
if (style & Style::Fullscreen)
|
||||
style &= ~Style::Titlebar;
|
||||
style &= ~static_cast<Uint32>(Style::Titlebar);
|
||||
else
|
||||
style |= Style::Titlebar;
|
||||
#else
|
||||
@ -183,7 +183,7 @@ void Window::setVerticalSyncEnabled(bool enabled)
|
||||
void Window::setFramerateLimit(unsigned int limit)
|
||||
{
|
||||
if (limit > 0)
|
||||
m_frameTimeLimit = seconds(1.f / limit);
|
||||
m_frameTimeLimit = seconds(1.f / static_cast<float>(limit));
|
||||
else
|
||||
m_frameTimeLimit = Time::Zero;
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ void WindowBase::create(VideoMode mode, const String& title, Uint32 style)
|
||||
if (getFullscreenWindow())
|
||||
{
|
||||
err() << "Creating two fullscreen windows is not allowed, switching to windowed mode" << std::endl;
|
||||
style &= ~Style::Fullscreen;
|
||||
style &= ~static_cast<Uint32>(Style::Fullscreen);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -109,7 +109,7 @@ void WindowBase::create(VideoMode mode, const String& title, Uint32 style)
|
||||
// Check validity of style according to the underlying platform
|
||||
#if defined(SFML_SYSTEM_IOS) || defined(SFML_SYSTEM_ANDROID)
|
||||
if (style & Style::Fullscreen)
|
||||
style &= ~Style::Titlebar;
|
||||
style &= ~static_cast<Uint32>(Style::Titlebar);
|
||||
else
|
||||
style |= Style::Titlebar;
|
||||
#else
|
||||
|
@ -208,7 +208,7 @@ void WindowImpl::processJoystickEvents()
|
||||
Joystick::Axis axis = static_cast<Joystick::Axis>(j);
|
||||
float prevPos = m_previousAxes[i][axis];
|
||||
float currPos = m_joystickStates[i].axes[axis];
|
||||
if (fabs(currPos - prevPos) >= m_joystickThreshold)
|
||||
if (std::abs(currPos - prevPos) >= m_joystickThreshold)
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::JoystickMoved;
|
||||
|
Loading…
Reference in New Issue
Block a user