mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
Add clang-tidy readability-else-after-return
check
This commit is contained in:
parent
be63ffa8d4
commit
d7eeaea240
@ -63,7 +63,6 @@ Checks: >
|
||||
-readability-avoid-nested-conditional-operator,
|
||||
-readability-braces-around-statements,
|
||||
-readability-convert-member-functions-to-static,
|
||||
-readability-else-after-return,
|
||||
-readability-function-cognitive-complexity,
|
||||
-readability-function-size,
|
||||
-readability-identifier-length,
|
||||
|
@ -58,7 +58,7 @@
|
||||
|
||||
if (cstr != nullptr)
|
||||
return std::string(cstr);
|
||||
else
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -58,11 +58,9 @@ private:
|
||||
std::cout << "Connected to server " << m_host << std::endl;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \see SoundRecorder::onProcessSamples
|
||||
|
@ -630,7 +630,7 @@ public:
|
||||
gpu = dev;
|
||||
break;
|
||||
}
|
||||
else if (deviceProperties.deviceType == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU)
|
||||
if (deviceProperties.deviceType == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU)
|
||||
{
|
||||
gpu = dev;
|
||||
}
|
||||
|
@ -103,10 +103,8 @@ constexpr std::optional<Rect<T>> Rect<T>::findIntersection(const Rect<T>& rectan
|
||||
{
|
||||
return Rect<T>({interLeft, interTop}, {interRight - interLeft, interBottom - interTop});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,10 +85,8 @@ constexpr Transform Transform::getInverse() const
|
||||
(m_matrix[5] * m_matrix[0] - m_matrix[1] * m_matrix[4]) / det};
|
||||
// clang-format on
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return Identity;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -118,8 +118,7 @@ std::optional<SoundBuffer> SoundBuffer::loadFromSamples(
|
||||
return std::nullopt;
|
||||
return soundBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Error...
|
||||
err() << "Failed to load sound buffer from samples ("
|
||||
<< "array: " << samples << ", "
|
||||
@ -128,7 +127,6 @@ std::optional<SoundBuffer> SoundBuffer::loadFromSamples(
|
||||
<< "samplerate: " << sampleRate << ")" << std::endl;
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -143,10 +141,8 @@ bool SoundBuffer::saveToFile(const std::filesystem::path& filename) const
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -233,10 +229,8 @@ std::optional<SoundBuffer> SoundBuffer::initialize(InputSoundFile& file)
|
||||
|
||||
return soundBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,15 +51,11 @@ FLAC__StreamDecoderReadStatus streamRead(const FLAC__StreamDecoder*, FLAC__byte
|
||||
*bytes = *count;
|
||||
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
|
||||
}
|
||||
}
|
||||
|
||||
FLAC__StreamDecoderSeekStatus streamSeek(const FLAC__StreamDecoder*, FLAC__uint64 absoluteByteOffset, void* clientData)
|
||||
@ -68,7 +64,7 @@ FLAC__StreamDecoderSeekStatus streamSeek(const FLAC__StreamDecoder*, FLAC__uint6
|
||||
|
||||
if (data->stream->seek(static_cast<std::size_t>(absoluteByteOffset)).has_value())
|
||||
return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
|
||||
else
|
||||
|
||||
return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
|
||||
}
|
||||
|
||||
@ -81,10 +77,8 @@ FLAC__StreamDecoderTellStatus streamTell(const FLAC__StreamDecoder*, FLAC__uint6
|
||||
*absoluteByteOffset = *position;
|
||||
return FLAC__STREAM_DECODER_TELL_STATUS_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return FLAC__STREAM_DECODER_TELL_STATUS_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
FLAC__StreamDecoderLengthStatus streamLength(const FLAC__StreamDecoder*, FLAC__uint64* streamLength, void* clientData)
|
||||
@ -96,10 +90,8 @@ FLAC__StreamDecoderLengthStatus streamLength(const FLAC__StreamDecoder*, FLAC__u
|
||||
*streamLength = *count;
|
||||
return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
FLAC__bool streamEof(const FLAC__StreamDecoder*, void* clientData)
|
||||
@ -379,12 +371,10 @@ std::uint64_t SoundFileReaderFlac::read(std::int16_t* samples, std::uint64_t max
|
||||
m_clientData.leftovers.swap(leftovers);
|
||||
return maxCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// We can use all the leftovers and decode new frames
|
||||
std::copy(m_clientData.leftovers.begin(), m_clientData.leftovers.end(), samples);
|
||||
}
|
||||
}
|
||||
|
||||
// Reset the data that will be used in the callback
|
||||
m_clientData.buffer = samples + left;
|
||||
|
@ -83,10 +83,8 @@ bool SoundFileReaderOgg::check(InputStream& stream)
|
||||
ov_clear(&file);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -97,7 +97,8 @@ bool SoundFileWriterWav::open(const std::filesystem::path& filename,
|
||||
err() << "WAV sound file channel count 0" << std::endl;
|
||||
return false;
|
||||
}
|
||||
else if (channelCount == 1)
|
||||
|
||||
if (channelCount == 1)
|
||||
{
|
||||
m_remapTable[0] = 0;
|
||||
}
|
||||
|
@ -60,10 +60,10 @@ unsigned long read(FT_Stream rec, unsigned long offset, unsigned char* buffer, u
|
||||
{
|
||||
if (count > 0)
|
||||
return static_cast<unsigned long>(stream->read(reinterpret_cast<char*>(buffer), count).value());
|
||||
else
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
||||
return count > 0 ? 0 : 1; // error code is 0 if we're reading, or nonzero if we're seeking
|
||||
}
|
||||
void close(FT_Stream)
|
||||
@ -313,12 +313,10 @@ const Glyph& Font::getGlyph(std::uint32_t codePoint, unsigned int characterSize,
|
||||
// Found: just return it
|
||||
return it->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Not found: we have to load it
|
||||
const Glyph glyph = loadGlyph(codePoint, characterSize, bold, outlineThickness);
|
||||
return glyphs.emplace(key, glyph).first->second;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -364,11 +362,9 @@ float Font::getKerning(std::uint32_t first, std::uint32_t second, unsigned int c
|
||||
// Flooring is required as we use FT_KERNING_UNFITTED flag which is not quantized in 64 based grid
|
||||
return std::floor((secondLsbDelta - firstRsbDelta + static_cast<float>(kerning.x) + 32) / float{1 << 6});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Invalid font
|
||||
return 0.f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -383,10 +379,8 @@ float Font::getLineSpacing(unsigned int characterSize) const
|
||||
{
|
||||
return static_cast<float>(face->size->metrics.height) / float{1 << 6};
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return 0.f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -405,10 +399,8 @@ float Font::getUnderlinePosition(unsigned int characterSize) const
|
||||
|
||||
return -static_cast<float>(FT_MulFix(face->underline_position, face->size->metrics.y_scale)) / float{1 << 6};
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return 0.f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -427,10 +419,8 @@ float Font::getUnderlineThickness(unsigned int characterSize) const
|
||||
|
||||
return static_cast<float>(FT_MulFix(face->underline_thickness, face->size->metrics.y_scale)) / float{1 << 6};
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return 0.f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -185,14 +185,13 @@ std::optional<Image> Image::loadFromFile(const std::filesystem::path& filename)
|
||||
{
|
||||
return Image(Vector2u(Vector2i(width, height)), {ptr.get(), ptr.get() + width * height * 4});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
// Error, failed to load the image
|
||||
err() << "Failed to load image\n"
|
||||
<< formatDebugPathInfo(filename) << "\nReason: " << stbi_failure_reason() << std::endl;
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -214,19 +213,15 @@ std::optional<Image> Image::loadFromMemory(const void* data, std::size_t size)
|
||||
{
|
||||
return Image(Vector2u(Vector2i(width, height)), {ptr.get(), ptr.get() + width * height * 4});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Error, failed to load the image
|
||||
err() << "Failed to load image from memory. Reason: " << stbi_failure_reason() << std::endl;
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
err() << "Failed to load image from memory, no data provided" << std::endl;
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -256,12 +251,11 @@ std::optional<Image> Image::loadFromStream(InputStream& stream)
|
||||
{
|
||||
return Image(Vector2u(Vector2i(width, height)), {ptr.get(), ptr.get() + width * height * 4});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Error, failed to load the image
|
||||
err() << "Failed to load image from stream. Reason: " << stbi_failure_reason() << std::endl;
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -503,11 +497,9 @@ const std::uint8_t* Image::getPixelsPtr() const
|
||||
{
|
||||
return m_pixels.data();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
err() << "Trying to access the pixels of an empty image" << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -99,10 +99,8 @@ unsigned int RenderTexture::getMaximumAntialiasingLevel()
|
||||
{
|
||||
return priv::RenderTextureImplFBO::getMaximumAntialiasingLevel();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return priv::RenderTextureImplDefault::getMaximumAntialiasingLevel();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -95,10 +95,8 @@ bool getFileContents(const std::filesystem::path& filename, std::vector<char>& b
|
||||
buffer.push_back('\0');
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Read the contents of a stream into an array of char
|
||||
@ -283,9 +281,10 @@ std::optional<Shader> Shader::loadFromFile(const std::filesystem::path& filename
|
||||
// Compile the shader program
|
||||
if (type == Type::Vertex)
|
||||
return compile(shader.data(), {}, {});
|
||||
else if (type == Type::Geometry)
|
||||
|
||||
if (type == Type::Geometry)
|
||||
return compile({}, shader.data(), {});
|
||||
else
|
||||
|
||||
return compile({}, {}, shader.data());
|
||||
}
|
||||
|
||||
@ -355,9 +354,10 @@ std::optional<Shader> Shader::loadFromMemory(std::string_view shader, Type type)
|
||||
// Compile the shader program
|
||||
if (type == Type::Vertex)
|
||||
return compile(shader, {}, {});
|
||||
else if (type == Type::Geometry)
|
||||
|
||||
if (type == Type::Geometry)
|
||||
return compile({}, shader, {});
|
||||
else
|
||||
|
||||
return compile({}, {}, shader);
|
||||
}
|
||||
|
||||
@ -394,9 +394,10 @@ std::optional<Shader> Shader::loadFromStream(InputStream& stream, Type type)
|
||||
// Compile the shader program
|
||||
if (type == Type::Vertex)
|
||||
return compile(shader.data(), {}, {});
|
||||
else if (type == Type::Geometry)
|
||||
|
||||
if (type == Type::Geometry)
|
||||
return compile({}, shader.data(), {});
|
||||
else
|
||||
|
||||
return compile({}, {}, shader.data());
|
||||
}
|
||||
|
||||
@ -939,8 +940,7 @@ int Shader::getUniformLocation(const std::string& name)
|
||||
// Already in cache, return it
|
||||
return it->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Not in cache, request the location from OpenGL
|
||||
const int location = GLEXT_glGetUniformLocation(castToGlHandle(m_shaderProgram), name.c_str());
|
||||
m_uniforms.emplace(name, location);
|
||||
@ -949,7 +949,6 @@ int Shader::getUniformLocation(const std::string& name)
|
||||
err() << "Uniform " << std::quoted(name) << " not found in shader" << std::endl;
|
||||
|
||||
return location;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace sf
|
||||
|
@ -312,14 +312,11 @@ std::optional<Texture> Texture::loadFromImage(const Image& image, bool sRgb, con
|
||||
texture->update(image);
|
||||
return texture;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Error message generated in called function.
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Load a sub-area of the image
|
||||
|
||||
// Adjust the rectangle to the size of the image
|
||||
@ -355,12 +352,9 @@ std::optional<Texture> Texture::loadFromImage(const Image& image, bool sRgb, con
|
||||
|
||||
return texture;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Error message generated in called function.
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -974,15 +968,13 @@ unsigned int Texture::getValidSize(unsigned int size)
|
||||
// If hardware supports NPOT textures, then just return the unmodified size
|
||||
return size;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// If hardware doesn't support NPOT textures, we calculate the nearest power of two
|
||||
unsigned int powerOfTwo = 1;
|
||||
while (powerOfTwo < size)
|
||||
powerOfTwo *= 2;
|
||||
|
||||
return powerOfTwo;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -126,11 +126,9 @@ FloatRect VertexArray::getBounds() const
|
||||
|
||||
return {{left, top}, {right - left, bottom - top}};
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Array is empty
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -457,8 +457,7 @@ Ftp::Response Ftp::getResponse()
|
||||
// Return the response code and message
|
||||
return Response(static_cast<Response::Status>(code), message);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// The line we just read was actually not a response,
|
||||
// only a new part of the current multiline response
|
||||
|
||||
@ -478,7 +477,6 @@ Ftp::Response Ftp::getResponse()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (lastCode != 0)
|
||||
{
|
||||
// It seems we are in the middle of a multiline response
|
||||
|
@ -141,8 +141,7 @@ Socket::Status TcpSocket::connect(const IpAddress& remoteAddress, unsigned short
|
||||
// Connection succeeded
|
||||
return Status::Done;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// ----- We're using a timeout: we'll need a few tricks to make it work -----
|
||||
|
||||
// Save the previous blocking state
|
||||
@ -207,7 +206,6 @@ Socket::Status TcpSocket::connect(const IpAddress& remoteAddress, unsigned short
|
||||
setBlocking(true);
|
||||
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -299,14 +297,12 @@ Socket::Status TcpSocket::receive(void* data, std::size_t size, std::size_t& rec
|
||||
received = static_cast<std::size_t>(sizeReceived);
|
||||
return Status::Done;
|
||||
}
|
||||
else if (sizeReceived == 0)
|
||||
if (sizeReceived == 0)
|
||||
{
|
||||
return Socket::Status::Disconnected;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return priv::SocketImpl::getErrorStatus();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,18 +65,16 @@ private:
|
||||
// Valid character
|
||||
return sputc(static_cast<char>(character));
|
||||
}
|
||||
else if (character != EOF)
|
||||
if (character != EOF)
|
||||
{
|
||||
// Not enough space in the buffer: synchronize output and try again
|
||||
sync();
|
||||
return overflow(character);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Invalid character: synchronize output
|
||||
return sync();
|
||||
}
|
||||
}
|
||||
|
||||
int sync() override
|
||||
{
|
||||
|
@ -444,7 +444,7 @@ int WindowImplAndroid::processKeyEvent(AInputEvent* inputEvent, ActivityStates&
|
||||
// https://code.google.com/p/android/issues/detail?id=33998
|
||||
return 0;
|
||||
}
|
||||
else if (auto unicode = static_cast<std::uint32_t>(getUnicode(inputEvent))) // This is a repeated sequence
|
||||
if (auto unicode = static_cast<std::uint32_t>(getUnicode(inputEvent))) // This is a repeated sequence
|
||||
{
|
||||
const Event event(Event::TextEntered{static_cast<std::uint32_t>(unicode)});
|
||||
|
||||
|
@ -113,7 +113,7 @@ const Context* Context::getActiveContext()
|
||||
// We have to check that the last activated sf::Context is still active (a RenderTarget activation may have deactivated it)
|
||||
if (currentContext && currentContext->m_context.get() == priv::GlContext::getActiveContext())
|
||||
return currentContext;
|
||||
else
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -377,11 +377,10 @@ std::optional<sf::Event> eventProcess()
|
||||
|
||||
if (inputEvent.value)
|
||||
return sf::Event::MouseButtonPressed{*mb, mousePos};
|
||||
else
|
||||
|
||||
return sf::Event::MouseButtonReleased{*mb, mousePos};
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
const sf::Keyboard::Key kb = toKey(inputEvent.code);
|
||||
|
||||
unsigned int special = 0;
|
||||
@ -416,11 +415,10 @@ std::optional<sf::Event> eventProcess()
|
||||
|
||||
if (inputEvent.value)
|
||||
return sf::Event::KeyPressed{keyChanged};
|
||||
else
|
||||
|
||||
return sf::Event::KeyReleased{keyChanged};
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (inputEvent.type == EV_REL)
|
||||
{
|
||||
bool posChange = false;
|
||||
|
@ -60,7 +60,7 @@ VideoMode VideoModeImpl::getDesktopMode()
|
||||
drmModeModeInfoPtr ptr = drm.mode;
|
||||
if (ptr)
|
||||
return VideoMode({ptr->hdisplay, ptr->vdisplay});
|
||||
else
|
||||
|
||||
return VideoMode({0, 0});
|
||||
}
|
||||
|
||||
|
@ -764,19 +764,14 @@ bool GlContext::setActive(bool active)
|
||||
currentContext.ptr = this;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// This context is already the active one on this thread, don't do anything
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (m_impl->id == currentContext.id)
|
||||
{
|
||||
// We can't and don't need to lock when we are currently creating the shared context
|
||||
@ -792,17 +787,12 @@ bool GlContext::setActive(bool active)
|
||||
currentContext.ptr = nullptr;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// This context is not the active one on this thread, don't do anything
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -314,7 +314,7 @@ void ClipboardImpl::processEvent(XEvent& windowEvent)
|
||||
|
||||
break;
|
||||
}
|
||||
else if ((selectionRequestEvent.target == XA_STRING) ||
|
||||
if ((selectionRequestEvent.target == XA_STRING) ||
|
||||
((m_utf8String == None) && (selectionRequestEvent.target == m_text)))
|
||||
{
|
||||
// Respond to a request for conversion to a Latin-1 string
|
||||
@ -340,7 +340,7 @@ void ClipboardImpl::processEvent(XEvent& windowEvent)
|
||||
|
||||
break;
|
||||
}
|
||||
else if ((m_utf8String != None) &&
|
||||
if ((m_utf8String != None) &&
|
||||
((selectionRequestEvent.target == m_utf8String) || (selectionRequestEvent.target == m_text)))
|
||||
{
|
||||
// Respond to a request for conversion to a UTF-8 string
|
||||
|
@ -70,7 +70,7 @@ bool CursorImpl::loadFromPixels(const std::uint8_t* pixels, Vector2u size, Vecto
|
||||
|
||||
if (isColorCursorSupported())
|
||||
return loadFromPixelsARGB(pixels, size, hotspot);
|
||||
else
|
||||
|
||||
return loadFromPixelsMonochrome(pixels, size, hotspot);
|
||||
}
|
||||
|
||||
|
@ -379,13 +379,11 @@ XVisualInfo GlxContext::selectBestVisual(::Display* display, unsigned int bitsPe
|
||||
|
||||
return bestVisual;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Should never happen...
|
||||
err() << "No GLX visual found. You should check your graphics driver" << std::endl;
|
||||
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -158,10 +158,8 @@ Vector2i getMousePosition(const WindowBase& relativeTo)
|
||||
|
||||
return {x, y};
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -141,7 +141,7 @@ void updatePluggedList(udev_device* udevDevice = nullptr)
|
||||
recordIt->systemPath = syspath ? syspath : "";
|
||||
break;
|
||||
}
|
||||
else if (std::strstr(action, "remove"))
|
||||
if (std::strstr(action, "remove"))
|
||||
{
|
||||
recordIt->plugged = false;
|
||||
break;
|
||||
@ -561,11 +561,9 @@ bool JoystickImpl::open(unsigned int index)
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
err() << "Failed to open joystick " << devnode << ": " << errno << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -767,15 +767,12 @@ void WindowImplX11::processEvents()
|
||||
event = nextEvent;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Ignore both events
|
||||
processThisEvent = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// This sequence of events does not come from maintaining a key down,
|
||||
// so process the KeyRelease event normally,
|
||||
processEvent(event);
|
||||
@ -783,7 +780,6 @@ void WindowImplX11::processEvents()
|
||||
// of a sequence coming from maintaining a key down.
|
||||
event = nextEvent;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// No event after this KeyRelease event so assume it can be processed.
|
||||
@ -2106,7 +2102,7 @@ RROutput WindowImplX11::getOutputPrimary(::Window& rootWindow, XRRScreenResource
|
||||
// Check if returned output is valid, otherwise use the first screen
|
||||
if (output == None)
|
||||
return res->outputs[0];
|
||||
else
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
@ -96,15 +96,11 @@ bool operator<(const VideoMode& left, const VideoMode& right)
|
||||
{
|
||||
return left.size.y < right.size.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return left.size.x < right.size.x;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return left.bitsPerPixel < right.bitsPerPixel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -117,11 +117,9 @@ bool CursorImpl::loadFromPixels(const std::uint8_t* pixels, Vector2u size, Vecto
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
err() << "Failed to create cursor from bitmaps" << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -167,11 +165,9 @@ bool CursorImpl::loadFromSystem(Cursor::Type type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
err() << "Could not create copy of a system cursor" << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -711,10 +711,8 @@ Vector2i getMousePosition(const WindowBase& relativeTo)
|
||||
ScreenToClient(handle, &point);
|
||||
return {point.x, point.y};
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -362,11 +362,9 @@ JoystickState JoystickImpl::update()
|
||||
{
|
||||
return updateDInputBuffered();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return updateDInputPolled();
|
||||
}
|
||||
}
|
||||
|
||||
JoystickState state;
|
||||
|
||||
@ -1147,7 +1145,7 @@ BOOL CALLBACK JoystickImpl::deviceObjectEnumerationCallback(const DIDEVICEOBJECT
|
||||
|
||||
return DIENUM_CONTINUE;
|
||||
}
|
||||
else if (DIDFT_GETTYPE(deviceObjectInstance->dwType) & DIDFT_POV)
|
||||
if (DIDFT_GETTYPE(deviceObjectInstance->dwType) & DIDFT_POV)
|
||||
{
|
||||
// POVs
|
||||
if (deviceObjectInstance->guidType == guids::GUID_POV)
|
||||
@ -1161,7 +1159,7 @@ BOOL CALLBACK JoystickImpl::deviceObjectEnumerationCallback(const DIDEVICEOBJECT
|
||||
|
||||
return DIENUM_CONTINUE;
|
||||
}
|
||||
else if (DIDFT_GETTYPE(deviceObjectInstance->dwType) & DIDFT_BUTTON)
|
||||
if (DIDFT_GETTYPE(deviceObjectInstance->dwType) & DIDFT_BUTTON)
|
||||
{
|
||||
// Buttons
|
||||
for (unsigned int i = 0; i < Joystick::ButtonCount; ++i)
|
||||
|
@ -164,16 +164,12 @@ bool Window::setActive(bool active) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
err() << "Failed to activate the window's context" << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,10 +47,8 @@ String ClipboardImpl::getString()
|
||||
|
||||
return String::fromUtf8(utf8, utf8 + length);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -235,7 +235,7 @@ std::vector<sf::Vector2i> touchPositions;
|
||||
{
|
||||
if (index < touchPositions.size())
|
||||
return touchPositions[index];
|
||||
else
|
||||
|
||||
return sf::Vector2i(-1, -1);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ NSCursor* loadFromSelector(SEL selector)
|
||||
// The caller is responsible for retaining the cursor.
|
||||
if ([NSCursor respondsToSelector:selector])
|
||||
return [NSCursor performSelector:selector];
|
||||
else
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
@ -128,11 +128,9 @@ bool SFContext::makeCurrent(bool current)
|
||||
[m_context makeCurrentContext];
|
||||
return m_context == [NSOpenGLContext currentContext]; // Should be true.
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
[NSOpenGLContext clearCurrentContext];
|
||||
return m_context != [NSOpenGLContext currentContext]; // Should be true.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -197,15 +197,13 @@
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if ([[event characters] length] > 0)
|
||||
if ([[event characters] length] > 0)
|
||||
{
|
||||
unichar code = [[event characters] characterAtIndex:0];
|
||||
return (code < 0xF700) || (code > 0xF8FF);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in New Issue
Block a user