| @@ -68,7 +68,7 @@ namespace Keys | |||
| static const int extendedKeyModifier = 0x10000000; | |||
| } | |||
| bool KeyPress::isKeyCurrentlyDown (const int keyCode) | |||
| bool KeyPress::isKeyCurrentlyDown (int keyCode) | |||
| { | |||
| ScopedXDisplay xDisplay; | |||
| @@ -96,9 +96,9 @@ bool KeyPress::isKeyCurrentlyDown (const int keyCode) | |||
| ScopedXLock xlock (display); | |||
| const int keycode = XKeysymToKeycode (display, (KeySym) keysym); | |||
| const int keybyte = keycode >> 3; | |||
| const int keybit = (1 << (keycode & 7)); | |||
| return (Keys::keyStates [keybyte] & keybit) != 0; | |||
| } | |||
| @@ -366,7 +366,7 @@ namespace XRender | |||
| namespace Visuals | |||
| { | |||
| static Visual* findVisualWithDepth (::Display* display, const int desiredDepth) noexcept | |||
| static Visual* findVisualWithDepth (::Display* display, int desiredDepth) noexcept | |||
| { | |||
| ScopedXLock xlock (display); | |||
| @@ -395,10 +395,7 @@ namespace Visuals | |||
| desiredMask |= VisualBitsPerRGBMask; | |||
| } | |||
| if (XVisualInfo* xvinfos = XGetVisualInfo (display, | |||
| desiredMask, | |||
| &desiredVisual, | |||
| &numVisuals)) | |||
| if (auto* xvinfos = XGetVisualInfo (display, desiredMask, &desiredVisual, &numVisuals)) | |||
| { | |||
| for (int i = 0; i < numVisuals; i++) | |||
| { | |||
| @@ -415,7 +412,7 @@ namespace Visuals | |||
| return visual; | |||
| } | |||
| static Visual* findVisualFormat (::Display* display, const int desiredDepth, int& matchedDepth) noexcept | |||
| static Visual* findVisualFormat (::Display* display, int desiredDepth, int& matchedDepth) noexcept | |||
| { | |||
| Visual* visual = nullptr; | |||
| @@ -427,7 +424,7 @@ namespace Visuals | |||
| #if JUCE_USE_XRENDER | |||
| if (XRender::isAvailable (display)) | |||
| { | |||
| if (XRenderPictFormat* pictFormat = XRender::findPictureFormat (display)) | |||
| if (auto pictFormat = XRender::findPictureFormat (display)) | |||
| { | |||
| int numVisuals = 0; | |||
| XVisualInfo desiredVisual; | |||
| @@ -435,13 +432,13 @@ namespace Visuals | |||
| desiredVisual.depth = 32; | |||
| desiredVisual.bits_per_rgb = 8; | |||
| if (XVisualInfo* xvinfos = XGetVisualInfo (display, | |||
| VisualScreenMask | VisualDepthMask | VisualBitsPerRGBMask, | |||
| &desiredVisual, &numVisuals)) | |||
| if (auto xvinfos = XGetVisualInfo (display, | |||
| VisualScreenMask | VisualDepthMask | VisualBitsPerRGBMask, | |||
| &desiredVisual, &numVisuals)) | |||
| { | |||
| for (int i = 0; i < numVisuals; ++i) | |||
| { | |||
| XRenderPictFormat* pictVisualFormat = XRender::xRenderFindVisualFormat (display, xvinfos[i].visual); | |||
| auto pictVisualFormat = XRender::xRenderFindVisualFormat (display, xvinfos[i].visual); | |||
| if (pictVisualFormat != nullptr | |||
| && pictVisualFormat->type == PictTypeDirect | |||
| @@ -461,6 +458,7 @@ namespace Visuals | |||
| if (visual == nullptr) | |||
| { | |||
| visual = findVisualWithDepth (display, 32); | |||
| if (visual != nullptr) | |||
| matchedDepth = 32; | |||
| } | |||
| @@ -471,6 +469,7 @@ namespace Visuals | |||
| if (visual == nullptr && desiredDepth >= 24) | |||
| { | |||
| visual = findVisualWithDepth (display, 24); | |||
| if (visual != nullptr) | |||
| matchedDepth = 24; | |||
| } | |||
| @@ -478,6 +477,7 @@ namespace Visuals | |||
| if (visual == nullptr && desiredDepth >= 16) | |||
| { | |||
| visual = findVisualWithDepth (display, 16); | |||
| if (visual != nullptr) | |||
| matchedDepth = 16; | |||
| } | |||
| @@ -626,7 +626,8 @@ public: | |||
| return new LowLevelGraphicsSoftwareRenderer (Image (this)); | |||
| } | |||
| void initialiseBitmapData (Image::BitmapData& bitmap, int x, int y, Image::BitmapData::ReadWriteMode mode) override | |||
| void initialiseBitmapData (Image::BitmapData& bitmap, int x, int y, | |||
| Image::BitmapData::ReadWriteMode mode) override | |||
| { | |||
| bitmap.data = imageData + x * pixelStride + y * lineStride; | |||
| bitmap.pixelFormat = pixelFormat; | |||
| @@ -645,7 +646,8 @@ public: | |||
| ImageType* createType() const override { return new NativeImageType(); } | |||
| void blitToWindow (Window window, int dx, int dy, unsigned int dw, unsigned int dh, int sx, int sy) | |||
| void blitToWindow (Window window, int dx, int dy, | |||
| unsigned int dw, unsigned int dh, int sx, int sy) | |||
| { | |||
| ScopedXLock xlock (display); | |||
| @@ -666,15 +668,15 @@ public: | |||
| if (imageDepth == 16) | |||
| { | |||
| const uint32 rMask = (uint32) xImage->red_mask; | |||
| const uint32 gMask = (uint32) xImage->green_mask; | |||
| const uint32 bMask = (uint32) xImage->blue_mask; | |||
| const uint32 rShiftL = (uint32) jmax (0, getShiftNeeded (rMask)); | |||
| const uint32 rShiftR = (uint32) jmax (0, -getShiftNeeded (rMask)); | |||
| const uint32 gShiftL = (uint32) jmax (0, getShiftNeeded (gMask)); | |||
| const uint32 gShiftR = (uint32) jmax (0, -getShiftNeeded (gMask)); | |||
| const uint32 bShiftL = (uint32) jmax (0, getShiftNeeded (bMask)); | |||
| const uint32 bShiftR = (uint32) jmax (0, -getShiftNeeded (bMask)); | |||
| auto rMask = (uint32) xImage->red_mask; | |||
| auto gMask = (uint32) xImage->green_mask; | |||
| auto bMask = (uint32) xImage->blue_mask; | |||
| auto rShiftL = (uint32) jmax (0, getShiftNeeded (rMask)); | |||
| auto rShiftR = (uint32) jmax (0, -getShiftNeeded (rMask)); | |||
| auto gShiftL = (uint32) jmax (0, getShiftNeeded (gMask)); | |||
| auto gShiftR = (uint32) jmax (0, -getShiftNeeded (gMask)); | |||
| auto bShiftL = (uint32) jmax (0, getShiftNeeded (bMask)); | |||
| auto bShiftR = (uint32) jmax (0, -getShiftNeeded (bMask)); | |||
| const Image::BitmapData srcData (Image (this), Image::BitmapData::readOnly); | |||
| @@ -737,28 +739,6 @@ private: | |||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (XBitmapImage) | |||
| }; | |||
| //============================================================================== | |||
| #if JUCE_USE_XRANDR | |||
| template <> | |||
| struct ContainerDeletePolicy<XRRScreenResources> | |||
| { | |||
| static void destroy (XRRScreenResources* object); | |||
| }; | |||
| template <> | |||
| struct ContainerDeletePolicy<XRROutputInfo> | |||
| { | |||
| static void destroy (XRROutputInfo* object); | |||
| }; | |||
| template <> | |||
| struct ContainerDeletePolicy<XRRCrtcInfo> | |||
| { | |||
| static void destroy (XRRCrtcInfo* object); | |||
| }; | |||
| #endif | |||
| //================================ X11 - DisplayGeometry ======================= | |||
| class DisplayGeometry | |||
| @@ -967,10 +947,6 @@ private: | |||
| //============================================================================== | |||
| #if JUCE_USE_XRANDR | |||
| friend struct ContainerDeletePolicy<XRRScreenResources>; | |||
| friend struct ContainerDeletePolicy<XRROutputInfo>; | |||
| friend struct ContainerDeletePolicy<XRRCrtcInfo>; | |||
| class XRandrWrapper | |||
| { | |||
| private: | |||
| @@ -1041,12 +1017,7 @@ private: | |||
| return 0; | |||
| } | |||
| private: | |||
| //============================================================================== | |||
| friend struct ContainerDeletePolicy<XRRScreenResources>; | |||
| friend struct ContainerDeletePolicy<XRROutputInfo>; | |||
| friend struct ContainerDeletePolicy<XRRCrtcInfo>; | |||
| void freeScreenResources (XRRScreenResources* ptr) | |||
| { | |||
| if (freeScreenResourcesPtr != nullptr) | |||
| @@ -1064,16 +1035,17 @@ private: | |||
| if (freeCrtcInfoPtr != nullptr) | |||
| freeCrtcInfoPtr (ptr); | |||
| } | |||
| private: | |||
| static XRandrWrapper* instance; | |||
| typedef XRRScreenResources* (*tXRRGetScreenResources) (::Display*, ::Window); | |||
| typedef void (*tXRRFreeScreenResources) (XRRScreenResources*); | |||
| typedef XRROutputInfo* (*tXRRGetOutputInfo) (::Display*, XRRScreenResources*, RROutput); | |||
| typedef void (*tXRRFreeOutputInfo) (XRROutputInfo*); | |||
| typedef XRRCrtcInfo* (*tXRRGetCrtcInfo) (::Display*, XRRScreenResources*, RRCrtc); | |||
| typedef void (*tXRRFreeCrtcInfo) (XRRCrtcInfo*); | |||
| typedef RROutput (*tXRRGetOutputPrimary) (::Display*, ::Window); | |||
| using tXRRGetScreenResources = XRRScreenResources* (*) (::Display*, ::Window); | |||
| using tXRRFreeScreenResources = void (*) (XRRScreenResources*); | |||
| using tXRRGetOutputInfo = XRROutputInfo* (*) (::Display*, XRRScreenResources*, RROutput); | |||
| using tXRRFreeOutputInfo = void (*) (XRROutputInfo*); | |||
| using tXRRGetCrtcInfo = XRRCrtcInfo* (*) (::Display*, XRRScreenResources*, RRCrtc); | |||
| using tXRRFreeCrtcInfo = void (*) (XRRCrtcInfo*); | |||
| using tXRRGetOutputPrimary = RROutput (*) (::Display*, ::Window); | |||
| void* libXrandr = nullptr; | |||
| tXRRGetScreenResources getScreenResourcesPtr = nullptr; | |||
| @@ -1096,28 +1068,30 @@ private: | |||
| static double getScaleForDisplay (const String& name, const ExtendedInfo& info) | |||
| { | |||
| if (! name.isEmpty()) | |||
| if (name.isNotEmpty()) | |||
| { | |||
| // Ubuntu and derived distributions now save a per-display scale factor as a configuration | |||
| // variable. This can be changed in the Monitor system settings panel. | |||
| ChildProcess dconf; | |||
| if (File ("/usr/bin/dconf").existsAsFile() && | |||
| dconf.start ("/usr/bin/dconf read /com/ubuntu/user-interface/scale-factor", ChildProcess::wantStdOut)) | |||
| if (File ("/usr/bin/dconf").existsAsFile() | |||
| && dconf.start ("/usr/bin/dconf read /com/ubuntu/user-interface/scale-factor", ChildProcess::wantStdOut)) | |||
| { | |||
| if (dconf.waitForProcessToFinish (200)) | |||
| { | |||
| String jsonOutput = dconf.readAllProcessOutput().replaceCharacter ('\'', '"'); | |||
| auto jsonOutput = dconf.readAllProcessOutput().replaceCharacter ('\'', '"'); | |||
| if (dconf.getExitCode() == 0 && jsonOutput.isNotEmpty()) | |||
| { | |||
| var jsonVar = JSON::parse (jsonOutput); | |||
| auto jsonVar = JSON::parse (jsonOutput); | |||
| if (DynamicObject* object = jsonVar.getDynamicObject()) | |||
| if (auto* object = jsonVar.getDynamicObject()) | |||
| { | |||
| var scaleFactorVar = object->getProperty (name); | |||
| auto scaleFactorVar = object->getProperty (name); | |||
| if (! scaleFactorVar.isVoid()) | |||
| { | |||
| double scaleFactor = ((double) scaleFactorVar) / 8.0; | |||
| auto scaleFactor = ((double) scaleFactorVar) / 8.0; | |||
| if (scaleFactor > 0.0) | |||
| return scaleFactor; | |||
| @@ -1167,71 +1141,70 @@ private: | |||
| if (XQueryExtension (display, "RANDR", &major_opcode, &first_event, &first_error)) | |||
| { | |||
| XRandrWrapper& xrandr = XRandrWrapper::getInstance(); | |||
| auto& xrandr = XRandrWrapper::getInstance(); | |||
| std::unique_ptr<XRRScreenResources> screens; | |||
| const int numMonitors = ScreenCount (display); | |||
| RROutput mainDisplay = xrandr.getOutputPrimary (display, RootWindow (display, 0)); | |||
| auto numMonitors = ScreenCount (display); | |||
| auto mainDisplay = xrandr.getOutputPrimary (display, RootWindow (display, 0)); | |||
| for (int i = 0; i < numMonitors; ++i) | |||
| { | |||
| screens.reset (xrandr.getScreenResources (display, RootWindow (display, i))); | |||
| if (screens != nullptr) | |||
| if (auto* screens = xrandr.getScreenResources (display, RootWindow (display, i))) | |||
| { | |||
| for (int j = 0; j < screens->noutput; ++j) | |||
| { | |||
| if (! screens->outputs[j]) | |||
| continue; | |||
| // Xrandr on the raspberry pi fails to determine the main display (mainDisplay == 0)! | |||
| // Detect this edge case and make the first found display the main display | |||
| if (! mainDisplay) | |||
| mainDisplay = screens->outputs[j]; | |||
| std::unique_ptr<XRROutputInfo> output (xrandr.getOutputInfo (display, screens.get(), screens->outputs[j])); | |||
| if (output != nullptr) | |||
| if (screens->outputs[j]) | |||
| { | |||
| if (! output->crtc) | |||
| continue; | |||
| std::unique_ptr<XRRCrtcInfo> crtc (xrandr.getCrtcInfo (display, screens.get(), output->crtc)); | |||
| // Xrandr on the raspberry pi fails to determine the main display (mainDisplay == 0)! | |||
| // Detect this edge case and make the first found display the main display | |||
| if (! mainDisplay) | |||
| mainDisplay = screens->outputs[j]; | |||
| if (crtc != nullptr) | |||
| if (auto* output = xrandr.getOutputInfo (display, screens, screens->outputs[j])) | |||
| { | |||
| ExtendedInfo e; | |||
| e.totalBounds = Rectangle<int> (crtc->x, crtc->y, | |||
| (int) crtc->width, (int) crtc->height); | |||
| e.usableBounds = e.totalBounds.withZeroOrigin(); // Support for usable area is not implemented in JUCE yet | |||
| e.topLeftScaled = e.totalBounds.getTopLeft(); | |||
| e.isMain = (mainDisplay == screens->outputs[j]) && (i == 0); | |||
| e.dpi = getDisplayDPI (display, 0); | |||
| // The raspberry pi returns a zero sized display, so we need to guard for divide-by-zero | |||
| if (output->mm_width > 0 && output->mm_height > 0) | |||
| e.dpi = ((static_cast<double> (crtc->width) * 25.4 * 0.5) / static_cast<double> (output->mm_width)) | |||
| + ((static_cast<double> (crtc->height) * 25.4 * 0.5) / static_cast<double> (output->mm_height)); | |||
| double scale = getScaleForDisplay (output->name, e); | |||
| scale = (scale <= 0.1 ? 1.0 : scale); | |||
| e.scale = masterScale * scale; | |||
| infos.add (e); | |||
| if (output->crtc) | |||
| { | |||
| if (auto* crtc = xrandr.getCrtcInfo (display, screens, output->crtc)) | |||
| { | |||
| ExtendedInfo e; | |||
| e.totalBounds = Rectangle<int> (crtc->x, crtc->y, | |||
| (int) crtc->width, (int) crtc->height); | |||
| e.usableBounds = e.totalBounds.withZeroOrigin(); // Support for usable area is not implemented in JUCE yet | |||
| e.topLeftScaled = e.totalBounds.getTopLeft(); | |||
| e.isMain = (mainDisplay == screens->outputs[j]) && (i == 0); | |||
| e.dpi = getDisplayDPI (display, 0); | |||
| // The raspberry pi returns a zero sized display, so we need to guard for divide-by-zero | |||
| if (output->mm_width > 0 && output->mm_height > 0) | |||
| e.dpi = ((static_cast<double> (crtc->width) * 25.4 * 0.5) / static_cast<double> (output->mm_width)) | |||
| + ((static_cast<double> (crtc->height) * 25.4 * 0.5) / static_cast<double> (output->mm_height)); | |||
| double scale = getScaleForDisplay (output->name, e); | |||
| scale = (scale <= 0.1 ? 1.0 : scale); | |||
| e.scale = masterScale * scale; | |||
| infos.add (e); | |||
| xrandr.freeCrtcInfo (crtc); | |||
| } | |||
| } | |||
| xrandr.freeOutputInfo (output); | |||
| } | |||
| } | |||
| } | |||
| xrandr.freeScreenResources (screens); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| if (infos.size() == 0) | |||
| if (infos.isEmpty()) | |||
| #endif | |||
| #if JUCE_USE_XINERAMA | |||
| { | |||
| Array<XineramaScreenInfo> screens = XineramaQueryDisplays (display); | |||
| auto screens = XineramaQueryDisplays (display); | |||
| int numMonitors = screens.size(); | |||
| for (int index = 0; index < numMonitors; ++index) | |||
| @@ -1257,14 +1230,14 @@ private: | |||
| } | |||
| } | |||
| if (infos.size() == 0) | |||
| if (infos.isEmpty()) | |||
| #endif | |||
| { | |||
| Atom hints = Atoms::getIfExists (display, "_NET_WORKAREA"); | |||
| if (hints != None) | |||
| { | |||
| const int numMonitors = ScreenCount (display); | |||
| auto numMonitors = ScreenCount (display); | |||
| for (int i = 0; i < numMonitors; ++i) | |||
| { | |||
| @@ -1272,14 +1245,14 @@ private: | |||
| if (prop.success && prop.actualType == XA_CARDINAL && prop.actualFormat == 32 && prop.numItems == 4) | |||
| { | |||
| const long* const position = (const long*) prop.data; | |||
| auto position = (const long*) prop.data; | |||
| ExtendedInfo e; | |||
| e.totalBounds = Rectangle<int> ((int) position[0], (int) position[1], | |||
| (int) position[2], (int) position[3]); | |||
| e.usableBounds = e.totalBounds.withZeroOrigin(); // Support for usable area is not implemented in JUCE yet | |||
| e.topLeftScaled = e.totalBounds.getTopLeft(); // this will be overwritten by updatePositions later | |||
| e.isMain = (infos.size() == 0); | |||
| e.isMain = infos.isEmpty(); | |||
| e.scale = masterScale; | |||
| e.dpi = getDisplayDPI (display, i); | |||
| @@ -1288,7 +1261,7 @@ private: | |||
| } | |||
| } | |||
| if (infos.size() == 0) | |||
| if (infos.isEmpty()) | |||
| { | |||
| ExtendedInfo e; | |||
| e.totalBounds = Rectangle<int> (DisplayWidth (display, DefaultScreen (display)), | |||
| @@ -1363,24 +1336,6 @@ DisplayGeometry* DisplayGeometry::instance = nullptr; | |||
| #if JUCE_USE_XRANDR | |||
| DisplayGeometry::XRandrWrapper* DisplayGeometry::XRandrWrapper::instance = nullptr; | |||
| void ContainerDeletePolicy<XRRScreenResources>::destroy (XRRScreenResources* ptr) | |||
| { | |||
| if (ptr != nullptr) | |||
| DisplayGeometry::XRandrWrapper::getInstance().freeScreenResources (ptr); | |||
| } | |||
| void ContainerDeletePolicy<XRROutputInfo>::destroy (XRROutputInfo* ptr) | |||
| { | |||
| if (ptr != nullptr) | |||
| DisplayGeometry::XRandrWrapper::getInstance().freeOutputInfo (ptr); | |||
| } | |||
| void ContainerDeletePolicy<XRRCrtcInfo>::destroy (XRRCrtcInfo* ptr) | |||
| { | |||
| if (ptr != nullptr) | |||
| DisplayGeometry::XRandrWrapper::getInstance().freeCrtcInfo (ptr); | |||
| } | |||
| #endif | |||
| //=============================== X11 - Pixmap ================================= | |||
| @@ -1391,8 +1346,8 @@ namespace PixmapHelpers | |||
| { | |||
| ScopedXLock xlock (display); | |||
| const unsigned int width = (unsigned int) image.getWidth(); | |||
| const unsigned int height = (unsigned int) image.getHeight(); | |||
| auto width = (unsigned int) image.getWidth(); | |||
| auto height = (unsigned int) image.getHeight(); | |||
| HeapBlock<uint32> colour (width * height); | |||
| int index = 0; | |||
| @@ -1418,9 +1373,9 @@ namespace PixmapHelpers | |||
| { | |||
| ScopedXLock xlock (display); | |||
| const unsigned int width = (unsigned int) image.getWidth(); | |||
| const unsigned int height = (unsigned int) image.getHeight(); | |||
| const unsigned int stride = (width + 7) >> 3; | |||
| auto width = (unsigned int) image.getWidth(); | |||
| auto height = (unsigned int) image.getHeight(); | |||
| auto stride = (width + 7) >> 3; | |||
| HeapBlock<char> mask; | |||
| mask.calloc (stride * height); | |||
| const bool msbfirst = (BitmapBitOrder (display) == MSBFirst); | |||
| @@ -1429,7 +1384,7 @@ namespace PixmapHelpers | |||
| { | |||
| for (unsigned int x = 0; x < width; ++x) | |||
| { | |||
| const char bit = (char) (1 << (msbfirst ? (7 - (x & 7)) : (x & 7))); | |||
| auto bit = (char) (1 << (msbfirst ? (7 - (x & 7)) : (x & 7))); | |||
| const unsigned int offset = y * stride + (x >> 3); | |||
| if (image.getPixelAt ((int) x, (int) y).getAlpha() >= 128) | |||
| @@ -1464,7 +1419,7 @@ bool juce_areThereAnyAlwaysOnTopWindows() | |||
| class LinuxComponentPeer : public ComponentPeer | |||
| { | |||
| public: | |||
| LinuxComponentPeer (Component& comp, const int windowStyleFlags, Window parentToAddTo) | |||
| LinuxComponentPeer (Component& comp, int windowStyleFlags, Window parentToAddTo) | |||
| : ComponentPeer (comp, windowStyleFlags), | |||
| isAlwaysOnTop (comp.isAlwaysOnTop()) | |||
| { | |||
| @@ -1625,7 +1580,7 @@ public: | |||
| WeakReference<Component> deletionChecker (&component); | |||
| ScopedXLock xlock (display); | |||
| XSizeHints* const hints = XAllocSizeHints(); | |||
| auto* hints = XAllocSizeHints(); | |||
| hints->flags = USSize | USPosition; | |||
| hints->x = physicalBounds.getX(); | |||
| hints->y = physicalBounds.getY(); | |||
| @@ -1713,7 +1668,7 @@ public: | |||
| && ((unsigned long*) prop.data)[0] == IconicState; | |||
| } | |||
| void setFullScreen (const bool shouldBeFullScreen) override | |||
| void setFullScreen (bool shouldBeFullScreen) override | |||
| { | |||
| auto r = lastNonFullscreenBounds; // (get a copy of this before de-minimising) | |||
| @@ -1794,7 +1749,7 @@ public: | |||
| { | |||
| for (int i = (int) windowListSize; --i >= 0;) | |||
| { | |||
| if (LinuxComponentPeer* const peer = LinuxComponentPeer::getPeerFor (windowList[i])) | |||
| if (auto* peer = LinuxComponentPeer::getPeerFor (windowList[i])) | |||
| { | |||
| result = (peer == this); | |||
| break; | |||
| @@ -2223,7 +2178,7 @@ public: | |||
| return Point<float> ((float) e.x, (float) e.y) / currentScaleFactor; | |||
| } | |||
| void handleWheelEvent (const XButtonPressedEvent& buttonPressEvent, const float amount) | |||
| void handleWheelEvent (const XButtonPressedEvent& buttonPressEvent, float amount) | |||
| { | |||
| MouseWheelDetails wheel; | |||
| wheel.deltaX = 0.0f; | |||
| @@ -2385,11 +2340,12 @@ public: | |||
| while (XEventsQueued (display, QueuedAfterFlush) > 0) | |||
| { | |||
| XPeekEvent (display, &nextEvent); | |||
| if (nextEvent.type != Expose || nextEvent.xany.window != exposeEvent.window) | |||
| break; | |||
| XNextEvent (display, &nextEvent); | |||
| const XExposeEvent& nextExposeEvent = (const XExposeEvent&) nextEvent.xexpose; | |||
| auto& nextExposeEvent = (const XExposeEvent&) nextEvent.xexpose; | |||
| repaint (Rectangle<int> (nextExposeEvent.x, nextExposeEvent.y, | |||
| nextExposeEvent.width, nextExposeEvent.height) / currentScaleFactor); | |||
| } | |||
| @@ -2453,7 +2409,7 @@ public: | |||
| { | |||
| if (clientMsg.message_type == atoms->protocols && clientMsg.format == 32) | |||
| { | |||
| const Atom atom = (Atom) clientMsg.data.l[0]; | |||
| auto atom = (Atom) clientMsg.data.l[0]; | |||
| if (atom == atoms->protocolList [Atoms::PING]) | |||
| { | |||
| @@ -2639,9 +2595,8 @@ private: | |||
| ScopedXLock xlock (display); | |||
| XShmSegmentInfo segmentinfo; | |||
| XImage* const testImage | |||
| = XShmCreateImage (display, DefaultVisual (display, DefaultScreen (display)), | |||
| 24, ZPixmap, 0, &segmentinfo, 64, 64); | |||
| auto testImage = XShmCreateImage (display, DefaultVisual (display, DefaultScreen (display)), | |||
| 24, ZPixmap, 0, &segmentinfo, 64, 64); | |||
| useARGBImagesForRendering = (testImage->bits_per_pixel == 32); | |||
| XDestroyImage (testImage); | |||
| @@ -2686,9 +2641,9 @@ private: | |||
| } | |||
| #endif | |||
| RectangleList<int> originalRepaintRegion (regionsNeedingRepaint); | |||
| auto originalRepaintRegion = regionsNeedingRepaint; | |||
| regionsNeedingRepaint.clear(); | |||
| const Rectangle<int> totalArea (originalRepaintRegion.getBounds()); | |||
| auto totalArea = originalRepaintRegion.getBounds(); | |||
| if (! totalArea.isEmpty()) | |||
| { | |||
| @@ -2790,7 +2745,7 @@ private: | |||
| unsigned long status; | |||
| }; | |||
| static void updateKeyStates (const int keycode, const bool press) noexcept | |||
| static void updateKeyStates (int keycode, bool press) noexcept | |||
| { | |||
| const int keybyte = keycode >> 3; | |||
| const int keybit = (1 << (keycode & 7)); | |||
| @@ -2801,7 +2756,7 @@ private: | |||
| Keys::keyStates [keybyte] &= ~keybit; | |||
| } | |||
| static void updateKeyModifiers (const int status) noexcept | |||
| static void updateKeyModifiers (int status) noexcept | |||
| { | |||
| int keyMods = 0; | |||
| @@ -2815,7 +2770,7 @@ private: | |||
| Keys::capsLock = ((status & LockMask) != 0); | |||
| } | |||
| static bool updateKeyModifiersFromSym (KeySym sym, const bool press) noexcept | |||
| static bool updateKeyModifiersFromSym (KeySym sym, bool press) noexcept | |||
| { | |||
| int modifier = 0; | |||
| bool isModifier = true; | |||
| @@ -2862,13 +2817,13 @@ private: | |||
| static void updateModifierMappings() noexcept | |||
| { | |||
| ScopedXLock xlock (display); | |||
| const int altLeftCode = XKeysymToKeycode (display, XK_Alt_L); | |||
| const int numLockCode = XKeysymToKeycode (display, XK_Num_Lock); | |||
| int altLeftCode = XKeysymToKeycode (display, XK_Alt_L); | |||
| int numLockCode = XKeysymToKeycode (display, XK_Num_Lock); | |||
| Keys::AltMask = 0; | |||
| Keys::NumLockMask = 0; | |||
| if (XModifierKeymap* const mapping = XGetModifierMapping (display)) | |||
| if (auto* mapping = XGetModifierMapping (display)) | |||
| { | |||
| for (int i = 0; i < 8; i++) | |||
| { | |||
| @@ -3144,7 +3099,7 @@ private: | |||
| static int64 getEventTime (::Time t) | |||
| { | |||
| static int64 eventTimeOffset = 0x12345678; | |||
| const int64 thisMessageTime = (int64) t; | |||
| auto thisMessageTime = (int64) t; | |||
| if (eventTimeOffset == 0x12345678) | |||
| eventTimeOffset = Time::currentTimeMillis() - thisMessageTime; | |||
| @@ -3175,7 +3130,7 @@ private: | |||
| if (prop.success && prop.actualFormat == 32) | |||
| { | |||
| const unsigned long* const sizes = (const unsigned long*) prop.data; | |||
| auto* sizes = (const unsigned long*) prop.data; | |||
| windowBorder = BorderSize<int> ((int) sizes[2], (int) sizes[0], | |||
| (int) sizes[3], (int) sizes[1]); | |||
| @@ -3258,7 +3213,7 @@ private: | |||
| XSendEvent (display, dragAndDropSourceWindow, False, 0, (XEvent*) &msg); | |||
| } | |||
| bool sendExternalDragAndDropMessage (XClientMessageEvent& msg, const Window targetWindow) | |||
| bool sendExternalDragAndDropMessage (XClientMessageEvent& msg, Window targetWindow) | |||
| { | |||
| msg.type = ClientMessage; | |||
| msg.display = display; | |||
| @@ -3270,7 +3225,7 @@ private: | |||
| return XSendEvent (display, targetWindow, False, 0, (XEvent*) &msg) != 0; | |||
| } | |||
| void sendExternalDragAndDropDrop (const Window targetWindow) | |||
| void sendExternalDragAndDropDrop (Window targetWindow) | |||
| { | |||
| XClientMessageEvent msg; | |||
| zerostruct (msg); | |||
| @@ -3281,7 +3236,7 @@ private: | |||
| sendExternalDragAndDropMessage (msg, targetWindow); | |||
| } | |||
| void sendExternalDragAndDropEnter (const Window targetWindow) | |||
| void sendExternalDragAndDropEnter (Window targetWindow) | |||
| { | |||
| XClientMessageEvent msg; | |||
| zerostruct (msg); | |||
| @@ -3295,7 +3250,7 @@ private: | |||
| sendExternalDragAndDropMessage (msg, targetWindow); | |||
| } | |||
| void sendExternalDragAndDropPosition (const Window targetWindow) | |||
| void sendExternalDragAndDropPosition (Window targetWindow) | |||
| { | |||
| XClientMessageEvent msg; | |||
| zerostruct (msg); | |||
| @@ -3316,7 +3271,7 @@ private: | |||
| dragState->expectingStatus = sendExternalDragAndDropMessage (msg, targetWindow); | |||
| } | |||
| void sendDragAndDropStatus (const bool acceptDrop, Atom dropAction) | |||
| void sendDragAndDropStatus (bool acceptDrop, Atom dropAction) | |||
| { | |||
| XClientMessageEvent msg; | |||
| zerostruct (msg); | |||
| @@ -3328,7 +3283,7 @@ private: | |||
| sendDragAndDropMessage (msg); | |||
| } | |||
| void sendExternalDragAndDropLeave (const Window targetWindow) | |||
| void sendExternalDragAndDropLeave (Window targetWindow) | |||
| { | |||
| XClientMessageEvent msg; | |||
| zerostruct (msg); | |||
| @@ -3523,7 +3478,7 @@ private: | |||
| srcMimeTypeAtomList.clear(); | |||
| dragAndDropCurrentMimeType = 0; | |||
| const unsigned long dndCurrentVersion = static_cast<unsigned long> (clientMsg.data.l[1] & 0xff000000) >> 24; | |||
| auto dndCurrentVersion = static_cast<unsigned long> (clientMsg.data.l[1] & 0xff000000) >> 24; | |||
| if (dndCurrentVersion < 3 || dndCurrentVersion > Atoms::DndVersion) | |||
| { | |||
| @@ -3543,7 +3498,7 @@ private: | |||
| && prop.actualFormat == 32 | |||
| && prop.numItems != 0) | |||
| { | |||
| const unsigned long* const types = (const unsigned long*) prop.data; | |||
| auto* types = (const unsigned long*) prop.data; | |||
| for (unsigned long i = 0; i < prop.numItems; ++i) | |||
| if (types[i] != None) | |||
| @@ -3551,13 +3506,13 @@ private: | |||
| } | |||
| } | |||
| if (srcMimeTypeAtomList.size() == 0) | |||
| if (srcMimeTypeAtomList.isEmpty()) | |||
| { | |||
| for (int i = 2; i < 5; ++i) | |||
| if (clientMsg.data.l[i] != None) | |||
| srcMimeTypeAtomList.add ((unsigned long) clientMsg.data.l[i]); | |||
| if (srcMimeTypeAtomList.size() == 0) | |||
| if (srcMimeTypeAtomList.isEmpty()) | |||
| { | |||
| dragAndDropSourceWindow = 0; | |||
| return; | |||
| @@ -3638,9 +3593,9 @@ private: | |||
| bool isWindowDnDAware (Window w) const | |||
| { | |||
| int numProperties = 0; | |||
| Atom* const properties = XListProperties (display, w, &numProperties); | |||
| auto* properties = XListProperties (display, w, &numProperties); | |||
| bool dndAwarePropFound = false; | |||
| for (int i = 0; i < numProperties; ++i) | |||
| if (properties[i] == atoms->XdndAware) | |||
| dndAwarePropFound = true; | |||
| @@ -3879,7 +3834,7 @@ void Desktop::Displays::findDisplays (float masterScale) | |||
| //============================================================================== | |||
| bool MouseInputSource::SourceList::addSource() | |||
| { | |||
| if (sources.size() == 0) | |||
| if (sources.isEmpty()) | |||
| { | |||
| addSource (0, MouseInputSource::InputSourceType::mouse); | |||
| return true; | |||
| @@ -3960,7 +3915,7 @@ Desktop::DisplayOrientation Desktop::getCurrentOrientation() const | |||
| //============================================================================== | |||
| static bool screenSaverAllowed = true; | |||
| void Desktop::setScreenSaverEnabled (const bool isEnabled) | |||
| void Desktop::setScreenSaverEnabled (bool isEnabled) | |||
| { | |||
| if (screenSaverAllowed != isEnabled) | |||
| { | |||
| @@ -4093,17 +4048,17 @@ void* CustomMouseCursorInfo::create() const | |||
| return nullptr; | |||
| ScopedXLock xlock (display); | |||
| const unsigned int imageW = (unsigned int) image.getWidth(); | |||
| const unsigned int imageH = (unsigned int) image.getHeight(); | |||
| auto imageW = (unsigned int) image.getWidth(); | |||
| auto imageH = (unsigned int) image.getHeight(); | |||
| int hotspotX = hotspot.x; | |||
| int hotspotY = hotspot.y; | |||
| #if JUCE_USE_XCURSOR | |||
| { | |||
| typedef XcursorBool (*tXcursorSupportsARGB) (Display*); | |||
| typedef XcursorImage* (*tXcursorImageCreate) (int, int); | |||
| typedef void (*tXcursorImageDestroy) (XcursorImage*); | |||
| typedef Cursor (*tXcursorImageLoadCursor) (Display*, const XcursorImage*); | |||
| using tXcursorSupportsARGB = XcursorBool (*) (Display*); | |||
| using tXcursorImageCreate = XcursorImage* (*) (int, int); | |||
| using tXcursorImageDestroy = void (*) (XcursorImage*); | |||
| using tXcursorImageLoadCursor = Cursor (*) (Display*, const XcursorImage*); | |||
| static tXcursorSupportsARGB xcursorSupportsARGB = nullptr; | |||
| static tXcursorImageCreate xcursorImageCreate = nullptr; | |||
| @@ -4186,10 +4141,10 @@ void* CustomMouseCursorInfo::create() const | |||
| { | |||
| for (int x = (int) cursorW; --x >= 0;) | |||
| { | |||
| const char mask = (char) (1 << (msbfirst ? (7 - (x & 7)) : (x & 7))); | |||
| const unsigned int offset = (unsigned int) y * stride + ((unsigned int) x >> 3); | |||
| auto mask = (char) (1 << (msbfirst ? (7 - (x & 7)) : (x & 7))); | |||
| auto offset = (unsigned int) y * stride + ((unsigned int) x >> 3); | |||
| const Colour c (im.getPixelAt (x, y)); | |||
| auto c = im.getPixelAt (x, y); | |||
| if (c.getAlpha() >= 128) maskPlane[offset] |= mask; | |||
| if (c.getBrightness() >= 0.5f) sourcePlane[offset] |= mask; | |||
| @@ -4212,7 +4167,7 @@ void* CustomMouseCursorInfo::create() const | |||
| return result; | |||
| } | |||
| void MouseCursor::deleteMouseCursor (void* const cursorHandle, const bool) | |||
| void MouseCursor::deleteMouseCursor (void* cursorHandle, bool) | |||
| { | |||
| if (cursorHandle != nullptr) | |||
| { | |||
| @@ -4306,10 +4261,10 @@ static LinuxComponentPeer* getPeerForDragEvent (Component* sourceComp) | |||
| return nullptr; | |||
| } | |||
| bool DragAndDropContainer::performExternalDragDropOfFiles (const StringArray& files, const bool canMoveFiles, | |||
| bool DragAndDropContainer::performExternalDragDropOfFiles (const StringArray& files, bool canMoveFiles, | |||
| Component* sourceComp) | |||
| { | |||
| if (files.size() == 0) | |||
| if (files.isEmpty()) | |||
| return false; | |||
| if (auto* lp = getPeerForDragEvent (sourceComp)) | |||