diff --git a/modules/juce_gui_basics/native/juce_linux_Windowing.cpp b/modules/juce_gui_basics/native/juce_linux_Windowing.cpp index e8aa9191d7..eb8c4cf1f1 100644 --- a/modules/juce_gui_basics/native/juce_linux_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_linux_Windowing.cpp @@ -31,11 +31,10 @@ static int numAlwaysOnTopPeers = 0; bool juce_areThereAnyAlwaysOnTopWindows() { return numAlwaysOnTopPeers > 0; } //============================================================================== -template class LinuxComponentPeer : public ComponentPeer { public: - LinuxComponentPeer (Component& comp, int windowStyleFlags, WindowHandleType parentToAddTo) + LinuxComponentPeer (Component& comp, int windowStyleFlags, ::Window parentToAddTo) : ComponentPeer (comp, windowStyleFlags), isAlwaysOnTop (comp.isAlwaysOnTop()) { @@ -295,8 +294,8 @@ public: } //============================================================================== - WindowHandleType getParentWindow() { return parentWindow; } - void setParentWindow (WindowHandleType newParent) { parentWindow = newParent; } + ::Window getParentWindow() { return parentWindow; } + void setParentWindow (::Window newParent) { parentWindow = newParent; } //============================================================================== void updateWindowBounds() @@ -450,7 +449,7 @@ private: //============================================================================== std::unique_ptr repainter; - WindowHandleType windowH = {}, parentWindow = {}, keyProxy = {}; + ::Window windowH = {}, parentWindow = {}; Rectangle bounds; BorderSize windowBorder; bool fullScreen = false, isAlwaysOnTop = false; @@ -461,17 +460,16 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LinuxComponentPeer) }; -template -bool LinuxComponentPeer::isActiveApplication = false; +bool LinuxComponentPeer::isActiveApplication = false; //============================================================================== ComponentPeer* Component::createNewPeer (int styleFlags, void* nativeWindowToAttachTo) { - return new LinuxComponentPeer<::Window> (*this, styleFlags, (::Window) nativeWindowToAttachTo); + return new LinuxComponentPeer (*this, styleFlags, (::Window) nativeWindowToAttachTo); } //============================================================================== -JUCE_API bool JUCE_CALLTYPE Process::isForegroundProcess() { return LinuxComponentPeer<::Window>::isActiveApplication; } +JUCE_API bool JUCE_CALLTYPE Process::isForegroundProcess() { return LinuxComponentPeer::isActiveApplication; } JUCE_API void JUCE_CALLTYPE Process::makeForegroundProcess() {} JUCE_API void JUCE_CALLTYPE Process::hide() {} @@ -571,15 +569,14 @@ void MouseCursor::showInWindow (ComponentPeer* peer) const } //============================================================================== -template -static LinuxComponentPeer* getPeerForDragEvent (Component* sourceComp) +static LinuxComponentPeer* getPeerForDragEvent (Component* sourceComp) { if (sourceComp == nullptr) if (auto* draggingSource = Desktop::getInstance().getDraggingMouseSource (0)) sourceComp = draggingSource->getComponentUnderMouse(); if (sourceComp != nullptr) - if (auto* lp = dynamic_cast*> (sourceComp->getPeer())) + if (auto* lp = dynamic_cast (sourceComp->getPeer())) return lp; jassertfalse; // This method must be called in response to a component's mouseDown or mouseDrag event! @@ -592,7 +589,7 @@ bool DragAndDropContainer::performExternalDragDropOfFiles (const StringArray& fi if (files.isEmpty()) return false; - if (auto* peer = getPeerForDragEvent<::Window> (sourceComp)) + if (auto* peer = getPeerForDragEvent (sourceComp)) return XWindowSystem::getInstance()->externalDragFileInit (peer, files, canMoveFiles, std::move (callback)); // This method must be called in response to a component's mouseDown or mouseDrag event! @@ -606,7 +603,7 @@ bool DragAndDropContainer::performExternalDragDropOfText (const String& text, Co if (text.isEmpty()) return false; - if (auto* peer = getPeerForDragEvent<::Window> (sourceComp)) + if (auto* peer = getPeerForDragEvent (sourceComp)) return XWindowSystem::getInstance()->externalDragTextInit (peer, text, std::move (callback)); // This method must be called in response to a component's mouseDown or mouseDrag event! @@ -688,13 +685,13 @@ Image juce_createIconForFile (const File&) void juce_LinuxAddRepaintListener (ComponentPeer* peer, Component* dummy) { - if (auto* linuxPeer = dynamic_cast*> (peer)) + if (auto* linuxPeer = dynamic_cast (peer)) linuxPeer->addOpenGLRepaintListener (dummy); } void juce_LinuxRemoveRepaintListener (ComponentPeer* peer, Component* dummy) { - if (auto* linuxPeer = dynamic_cast*> (peer)) + if (auto* linuxPeer = dynamic_cast (peer)) linuxPeer->removeOpenGLRepaintListener (dummy); } diff --git a/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.cpp b/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.cpp index 6db86f3e3b..df7303012a 100644 --- a/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.cpp +++ b/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.cpp @@ -1232,7 +1232,7 @@ ComponentPeer* getPeerFor (::Window windowH) } //============================================================================== -static std::unordered_map*, X11DragState> dragAndDropStateMap; +static std::unordered_map dragAndDropStateMap; XWindowSystem::XWindowSystem() { @@ -1296,7 +1296,7 @@ static int getAllEventsMask (bool ignoresMouseClicks) | (ignoresMouseClicks ? 0 : (ButtonPressMask | ButtonReleaseMask)); } -::Window XWindowSystem::createWindow (::Window parentToAddTo, LinuxComponentPeer<::Window>* peer) const +::Window XWindowSystem::createWindow (::Window parentToAddTo, LinuxComponentPeer* peer) const { if (! xIsAvailable) { @@ -1398,7 +1398,7 @@ static int getAllEventsMask (bool ignoresMouseClicks) void XWindowSystem::destroyWindow (::Window windowH) { - auto* peer = dynamic_cast*> (getPeerFor (windowH)); + auto* peer = dynamic_cast (getPeerFor (windowH)); if (peer == nullptr) { @@ -1746,7 +1746,7 @@ bool XWindowSystem::isFocused (::Window windowH) const jassert (windowH != 0); #if JUCE_X11_SUPPORTS_XEMBED - if (auto w = (::Window) juce_getCurrentFocusWindow (dynamic_cast*> (getPeerFor (windowH)))) + if (auto w = (::Window) juce_getCurrentFocusWindow (dynamic_cast (getPeerFor (windowH)))) return w; #endif @@ -2384,7 +2384,7 @@ void XWindowSystem::deleteKeyProxy (::Window keyProxy) const {} } -bool XWindowSystem::externalDragFileInit (LinuxComponentPeer<::Window>* peer, const StringArray& files, bool, std::function&& callback) const +bool XWindowSystem::externalDragFileInit (LinuxComponentPeer* peer, const StringArray& files, bool, std::function&& callback) const { auto& dragState = dragAndDropStateMap[peer]; @@ -2404,7 +2404,7 @@ bool XWindowSystem::externalDragFileInit (LinuxComponentPeer<::Window>* peer, co return dragState.externalDragInit ((::Window) peer->getNativeHandle(), false, uriList.joinIntoString ("\r\n"), std::move (callback)); } -bool XWindowSystem::externalDragTextInit (LinuxComponentPeer<::Window>* peer, const String& text, std::function&& callback) const +bool XWindowSystem::externalDragTextInit (LinuxComponentPeer* peer, const String& text, std::function&& callback) const { auto& dragState = dragAndDropStateMap[peer]; @@ -2499,9 +2499,9 @@ bool XWindowSystem::isFrontWindow (::Window windowH) const { for (int i = (int) windowListSize; --i >= 0;) { - if (auto* peer = dynamic_cast*> (getPeerFor (windowList[i]))) + if (auto* peer = dynamic_cast (getPeerFor (windowList[i]))) { - result = (peer == dynamic_cast*> (getPeerFor (windowH))); + result = (peer == dynamic_cast (getPeerFor (windowH))); break; } } @@ -2936,7 +2936,7 @@ static int64 getEventTime (const EventType& t) return getEventTime (t.time); } -void XWindowSystem::handleWindowMessage (LinuxComponentPeer<::Window>* peer, XEvent& event) const +void XWindowSystem::handleWindowMessage (LinuxComponentPeer* peer, XEvent& event) const { switch (event.xany.type) { @@ -2984,7 +2984,7 @@ void XWindowSystem::handleWindowMessage (LinuxComponentPeer<::Window>* peer, XEv } } -void XWindowSystem::handleKeyPressEvent (LinuxComponentPeer<::Window>* peer, XKeyEvent& keyEvent) const +void XWindowSystem::handleKeyPressEvent (LinuxComponentPeer* peer, XKeyEvent& keyEvent) const { auto oldMods = ModifierKeys::currentModifiers; @@ -3104,7 +3104,7 @@ void XWindowSystem::handleKeyPressEvent (LinuxComponentPeer<::Window>* peer, XKe peer->handleKeyPress (keyCode, unicodeChar); } -void XWindowSystem::handleKeyReleaseEvent (LinuxComponentPeer<::Window>* peer, const XKeyEvent& keyEvent) const +void XWindowSystem::handleKeyReleaseEvent (LinuxComponentPeer* peer, const XKeyEvent& keyEvent) const { auto isKeyReleasePartOfAutoRepeat = [&]() -> bool { @@ -3143,7 +3143,7 @@ void XWindowSystem::handleKeyReleaseEvent (LinuxComponentPeer<::Window>* peer, c } } -void XWindowSystem::handleWheelEvent (LinuxComponentPeer<::Window>* peer, const XButtonPressedEvent& buttonPressEvent, float amount) const +void XWindowSystem::handleWheelEvent (LinuxComponentPeer* peer, const XButtonPressedEvent& buttonPressEvent, float amount) const { MouseWheelDetails wheel; wheel.deltaX = 0.0f; @@ -3156,7 +3156,7 @@ void XWindowSystem::handleWheelEvent (LinuxComponentPeer<::Window>* peer, const getEventTime (buttonPressEvent), wheel); } -void XWindowSystem::handleButtonPressEvent (LinuxComponentPeer<::Window>* peer, const XButtonPressedEvent& buttonPressEvent, int buttonModifierFlag) const +void XWindowSystem::handleButtonPressEvent (LinuxComponentPeer* peer, const XButtonPressedEvent& buttonPressEvent, int buttonModifierFlag) const { ModifierKeys::currentModifiers = ModifierKeys::currentModifiers.withFlags (buttonModifierFlag); peer->toFront (true); @@ -3165,7 +3165,7 @@ void XWindowSystem::handleButtonPressEvent (LinuxComponentPeer<::Window>* peer, MouseInputSource::invalidOrientation, getEventTime (buttonPressEvent), {}); } -void XWindowSystem::handleButtonPressEvent (LinuxComponentPeer<::Window>* peer, const XButtonPressedEvent& buttonPressEvent) const +void XWindowSystem::handleButtonPressEvent (LinuxComponentPeer* peer, const XButtonPressedEvent& buttonPressEvent) const { updateKeyModifiers ((int) buttonPressEvent.state); @@ -3185,7 +3185,7 @@ void XWindowSystem::handleButtonPressEvent (LinuxComponentPeer<::Window>* peer, } } -void XWindowSystem::handleButtonReleaseEvent (LinuxComponentPeer<::Window>* peer, const XButtonReleasedEvent& buttonRelEvent) const +void XWindowSystem::handleButtonReleaseEvent (LinuxComponentPeer* peer, const XButtonReleasedEvent& buttonRelEvent) const { updateKeyModifiers ((int) buttonRelEvent.state); @@ -3214,7 +3214,7 @@ void XWindowSystem::handleButtonReleaseEvent (LinuxComponentPeer<::Window>* peer ModifierKeys::currentModifiers, MouseInputSource::invalidPressure, MouseInputSource::invalidOrientation, getEventTime (buttonRelEvent)); } -void XWindowSystem::handleMotionNotifyEvent (LinuxComponentPeer<::Window>* peer, const XPointerMovedEvent& movedEvent) const +void XWindowSystem::handleMotionNotifyEvent (LinuxComponentPeer* peer, const XPointerMovedEvent& movedEvent) const { updateKeyModifiers ((int) movedEvent.state); @@ -3228,7 +3228,7 @@ void XWindowSystem::handleMotionNotifyEvent (LinuxComponentPeer<::Window>* peer, MouseInputSource::invalidOrientation, getEventTime (movedEvent)); } -void XWindowSystem::handleEnterNotifyEvent (LinuxComponentPeer<::Window>* peer, const XEnterWindowEvent& enterEvent) const +void XWindowSystem::handleEnterNotifyEvent (LinuxComponentPeer* peer, const XEnterWindowEvent& enterEvent) const { if (peer->getParentWindow() != 0) peer->updateWindowBounds(); @@ -3242,7 +3242,7 @@ void XWindowSystem::handleEnterNotifyEvent (LinuxComponentPeer<::Window>* peer, } } -void XWindowSystem::handleLeaveNotifyEvent (LinuxComponentPeer<::Window>* peer, const XLeaveWindowEvent& leaveEvent) const +void XWindowSystem::handleLeaveNotifyEvent (LinuxComponentPeer* peer, const XLeaveWindowEvent& leaveEvent) const { // Suppress the normal leave if we've got a pointer grab, or if // it's a bogus one caused by clicking a mouse button when running @@ -3257,7 +3257,7 @@ void XWindowSystem::handleLeaveNotifyEvent (LinuxComponentPeer<::Window>* peer, } } -void XWindowSystem::handleFocusInEvent (LinuxComponentPeer<::Window>* peer) const +void XWindowSystem::handleFocusInEvent (LinuxComponentPeer* peer) const { peer->isActiveApplication = true; @@ -3268,7 +3268,7 @@ void XWindowSystem::handleFocusInEvent (LinuxComponentPeer<::Window>* peer) cons } } -void XWindowSystem::handleFocusOutEvent (LinuxComponentPeer<::Window>* peer) const +void XWindowSystem::handleFocusOutEvent (LinuxComponentPeer* peer) const { if (! isFocused ((::Window) peer->getNativeHandle()) && peer->focused) { @@ -3279,7 +3279,7 @@ void XWindowSystem::handleFocusOutEvent (LinuxComponentPeer<::Window>* peer) con } } -void XWindowSystem::handleExposeEvent (LinuxComponentPeer<::Window>* peer, XExposeEvent& exposeEvent) const +void XWindowSystem::handleExposeEvent (LinuxComponentPeer* peer, XExposeEvent& exposeEvent) const { // Batch together all pending expose events XEvent nextEvent; @@ -3321,7 +3321,7 @@ void XWindowSystem::handleExposeEvent (LinuxComponentPeer<::Window>* peer, XExpo } } -void XWindowSystem::handleConfigureNotifyEvent (LinuxComponentPeer<::Window>* peer, XConfigureEvent& confEvent) const +void XWindowSystem::handleConfigureNotifyEvent (LinuxComponentPeer* peer, XConfigureEvent& confEvent) const { peer->updateWindowBounds(); peer->updateBorderSize(); @@ -3341,14 +3341,14 @@ void XWindowSystem::handleConfigureNotifyEvent (LinuxComponentPeer<::Window>* pe peer->handleBroughtToFront(); } -void XWindowSystem::handleGravityNotify (LinuxComponentPeer<::Window>* peer) const +void XWindowSystem::handleGravityNotify (LinuxComponentPeer* peer) const { peer->updateWindowBounds(); peer->updateBorderSize(); peer->handleMovedOrResized(); } -void XWindowSystem::propertyNotifyEvent (LinuxComponentPeer<::Window>* peer, const XPropertyEvent& event) const +void XWindowSystem::propertyNotifyEvent (LinuxComponentPeer* peer, const XPropertyEvent& event) const { const auto isStateChangeEvent = [&] { @@ -3391,7 +3391,7 @@ void XWindowSystem::handleMappingNotify (XMappingEvent& mappingEvent) const } } -void XWindowSystem::handleClientMessageEvent (LinuxComponentPeer<::Window>* peer, XClientMessageEvent& clientMsg, XEvent& event) const +void XWindowSystem::handleClientMessageEvent (LinuxComponentPeer* peer, XClientMessageEvent& clientMsg, XEvent& event) const { if (clientMsg.message_type == atoms.protocols && clientMsg.format == 32) { @@ -3463,7 +3463,7 @@ void XWindowSystem::handleClientMessageEvent (LinuxComponentPeer<::Window>* peer } } -void XWindowSystem::handleXEmbedMessage (LinuxComponentPeer<::Window>* peer, XClientMessageEvent& clientMsg) const +void XWindowSystem::handleXEmbedMessage (LinuxComponentPeer* peer, XClientMessageEvent& clientMsg) const { switch (clientMsg.data.l[1]) { @@ -3495,7 +3495,7 @@ namespace WindowingHelpers if (! juce_handleXEmbedEvent (nullptr, &event)) #endif { - if (auto* peer = dynamic_cast*> (getPeerFor (event.xany.window))) + if (auto* peer = dynamic_cast (getPeerFor (event.xany.window))) XWindowSystem::getInstance()->handleWindowMessage (peer, event); } } diff --git a/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.h b/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.h index bd8900cfbe..14b888ff7a 100644 --- a/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.h +++ b/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.h @@ -93,14 +93,13 @@ namespace XWindowSystemUtilities } //============================================================================== -template class LinuxComponentPeer; class XWindowSystem : public DeletedAtShutdown { public: //============================================================================== - ::Window createWindow (::Window parentWindow, LinuxComponentPeer<::Window>* peer) const; + ::Window createWindow (::Window parentWindow, LinuxComponentPeer* peer) const; void destroyWindow (::Window windowH); void setTitle (::Window windowH, const String& title) const; @@ -152,8 +151,8 @@ public: ::Window createKeyProxy (::Window windowH) const; void deleteKeyProxy (::Window keyProxy) const; - bool externalDragFileInit (LinuxComponentPeer<::Window>* peer, const StringArray& files, bool canMove, std::function&& callback) const; - bool externalDragTextInit (LinuxComponentPeer<::Window>* peer, const String& text, std::function&& callback) const; + bool externalDragFileInit (LinuxComponentPeer* peer, const StringArray& files, bool canMove, std::function&& callback) const; + bool externalDragTextInit (LinuxComponentPeer* peer, const String& text, std::function&& callback) const; void copyTextToClipboard (const String& clipText); String getTextFromClipboard() const; @@ -164,7 +163,7 @@ public: XWindowSystemUtilities::Atoms& getAtoms() { return atoms; } //============================================================================== - void handleWindowMessage (LinuxComponentPeer<::Window>* peer, XEvent& event) const; + void handleWindowMessage (LinuxComponentPeer* peer, XEvent& event) const; //============================================================================== JUCE_DECLARE_SINGLETON (XWindowSystem, false) @@ -215,24 +214,24 @@ private: long getUserTime (::Window windowH) const; //============================================================================== - void handleKeyPressEvent (LinuxComponentPeer<::Window>*, XKeyEvent&) const; - void handleKeyReleaseEvent (LinuxComponentPeer<::Window>*, const XKeyEvent&) const; - void handleWheelEvent (LinuxComponentPeer<::Window>*, const XButtonPressedEvent&, float) const; - void handleButtonPressEvent (LinuxComponentPeer<::Window>*, const XButtonPressedEvent&, int) const; - void handleButtonPressEvent (LinuxComponentPeer<::Window>*, const XButtonPressedEvent&) const; - void handleButtonReleaseEvent (LinuxComponentPeer<::Window>*, const XButtonReleasedEvent&) const; - void handleMotionNotifyEvent (LinuxComponentPeer<::Window>*, const XPointerMovedEvent&) const; - void handleEnterNotifyEvent (LinuxComponentPeer<::Window>*, const XEnterWindowEvent&) const; - void handleLeaveNotifyEvent (LinuxComponentPeer<::Window>*, const XLeaveWindowEvent&) const; - void handleFocusInEvent (LinuxComponentPeer<::Window>*) const; - void handleFocusOutEvent (LinuxComponentPeer<::Window>*) const; - void handleExposeEvent (LinuxComponentPeer<::Window>*, XExposeEvent&) const; - void handleConfigureNotifyEvent (LinuxComponentPeer<::Window>*, XConfigureEvent&) const; - void handleGravityNotify (LinuxComponentPeer<::Window>*) const; - void propertyNotifyEvent (LinuxComponentPeer<::Window>*, const XPropertyEvent& ) const; + void handleKeyPressEvent (LinuxComponentPeer*, XKeyEvent&) const; + void handleKeyReleaseEvent (LinuxComponentPeer*, const XKeyEvent&) const; + void handleWheelEvent (LinuxComponentPeer*, const XButtonPressedEvent&, float) const; + void handleButtonPressEvent (LinuxComponentPeer*, const XButtonPressedEvent&, int) const; + void handleButtonPressEvent (LinuxComponentPeer*, const XButtonPressedEvent&) const; + void handleButtonReleaseEvent (LinuxComponentPeer*, const XButtonReleasedEvent&) const; + void handleMotionNotifyEvent (LinuxComponentPeer*, const XPointerMovedEvent&) const; + void handleEnterNotifyEvent (LinuxComponentPeer*, const XEnterWindowEvent&) const; + void handleLeaveNotifyEvent (LinuxComponentPeer*, const XLeaveWindowEvent&) const; + void handleFocusInEvent (LinuxComponentPeer*) const; + void handleFocusOutEvent (LinuxComponentPeer*) const; + void handleExposeEvent (LinuxComponentPeer*, XExposeEvent&) const; + void handleConfigureNotifyEvent (LinuxComponentPeer*, XConfigureEvent&) const; + void handleGravityNotify (LinuxComponentPeer*) const; + void propertyNotifyEvent (LinuxComponentPeer*, const XPropertyEvent& ) const; void handleMappingNotify (XMappingEvent&) const; - void handleClientMessageEvent (LinuxComponentPeer<::Window>*, XClientMessageEvent&, XEvent&) const; - void handleXEmbedMessage (LinuxComponentPeer<::Window>*, XClientMessageEvent&) const; + void handleClientMessageEvent (LinuxComponentPeer*, XClientMessageEvent&, XEvent&) const; + void handleXEmbedMessage (LinuxComponentPeer*, XClientMessageEvent&) const; //============================================================================== bool xIsAvailable = false;