Browse Source

Removed a redundant method and did some minor tidying

tags/2021-05-28
jules 7 years ago
parent
commit
df5be847c3
5 changed files with 27 additions and 42 deletions
  1. +2
    -3
      modules/juce_gui_basics/mouse/juce_MouseCursor.h
  2. +0
    -1
      modules/juce_gui_basics/native/juce_android_Windowing.cpp
  3. +0
    -6
      modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp
  4. +0
    -6
      modules/juce_gui_basics/native/juce_mac_MouseCursor.mm
  5. +25
    -26
      modules/juce_gui_basics/native/juce_win32_Windowing.cpp

+ 2
- 3
modules/juce_gui_basics/mouse/juce_MouseCursor.h View File

@@ -171,11 +171,10 @@ private:
SharedCursorHandle* cursorHandle = nullptr; SharedCursorHandle* cursorHandle = nullptr;
friend class MouseInputSourceInternal; friend class MouseInputSourceInternal;
void showInWindow (ComponentPeer* window) const;
void showInAllWindows() const;
void showInWindow (ComponentPeer*) const;
void* getHandle() const noexcept; void* getHandle() const noexcept;
static void* createStandardMouseCursor (MouseCursor::StandardCursorType type);
static void* createStandardMouseCursor (MouseCursor::StandardCursorType);
static void deleteMouseCursor (void* cursorHandle, bool isStandard); static void deleteMouseCursor (void* cursorHandle, bool isStandard);
JUCE_LEAK_DETECTOR (MouseCursor) JUCE_LEAK_DETECTOR (MouseCursor)


+ 0
- 1
modules/juce_gui_basics/native/juce_android_Windowing.cpp View File

@@ -1073,7 +1073,6 @@ void MouseCursor::deleteMouseCursor (void* const /*cursorHandle*/, const bool /*
//============================================================================== //==============================================================================
void MouseCursor::showInWindow (ComponentPeer*) const {} void MouseCursor::showInWindow (ComponentPeer*) const {}
void MouseCursor::showInAllWindows() const {}
//============================================================================== //==============================================================================
bool DragAndDropContainer::performExternalDragDropOfFiles (const StringArray& /*files*/, const bool /*canMove*/, bool DragAndDropContainer::performExternalDragDropOfFiles (const StringArray& /*files*/, const bool /*canMove*/,


+ 0
- 6
modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp View File

@@ -3985,12 +3985,6 @@ void MouseCursor::showInWindow (ComponentPeer* peer) const
lp->showMouseCursor ((Cursor) getHandle()); lp->showMouseCursor ((Cursor) getHandle());
} }
void MouseCursor::showInAllWindows() const
{
for (int i = ComponentPeer::getNumPeers(); --i >= 0;)
showInWindow (ComponentPeer::getPeer (i));
}
//=================================== X11 - DND ================================ //=================================== X11 - DND ================================
static LinuxComponentPeer* getPeerForDragEvent (Component* sourceComp) static LinuxComponentPeer* getPeerForDragEvent (Component* sourceComp)
{ {


+ 0
- 6
modules/juce_gui_basics/native/juce_mac_MouseCursor.mm View File

@@ -164,11 +164,6 @@ void MouseCursor::deleteMouseCursor (void* const cursorHandle, const bool /*isSt
[((NSCursor*) cursorHandle) release]; [((NSCursor*) cursorHandle) release];
} }
void MouseCursor::showInAllWindows() const
{
showInWindow (nullptr);
}
void MouseCursor::showInWindow (ComponentPeer*) const void MouseCursor::showInWindow (ComponentPeer*) const
{ {
auto c = (NSCursor*) getHandle(); auto c = (NSCursor*) getHandle();
@@ -184,7 +179,6 @@ void MouseCursor::showInWindow (ComponentPeer*) const
void* CustomMouseCursorInfo::create() const { return nullptr; } void* CustomMouseCursorInfo::create() const { return nullptr; }
void* MouseCursor::createStandardMouseCursor (MouseCursor::StandardCursorType) { return nullptr; } void* MouseCursor::createStandardMouseCursor (MouseCursor::StandardCursorType) { return nullptr; }
void MouseCursor::deleteMouseCursor (void*, bool) {} void MouseCursor::deleteMouseCursor (void*, bool) {}
void MouseCursor::showInAllWindows() const {}
void MouseCursor::showInWindow (ComponentPeer*) const {} void MouseCursor::showInWindow (ComponentPeer*) const {}
#endif #endif


+ 25
- 26
modules/juce_gui_basics/native/juce_win32_Windowing.cpp View File

@@ -1212,7 +1212,7 @@ public:
}; };
//============================================================================== //==============================================================================
HWNDComponentPeer (Component& comp, const int windowStyleFlags, HWND parent, bool nonRepainting)
HWNDComponentPeer (Component& comp, int windowStyleFlags, HWND parent, bool nonRepainting)
: ComponentPeer (comp, windowStyleFlags), : ComponentPeer (comp, windowStyleFlags),
dontRepaint (nonRepainting), dontRepaint (nonRepainting),
parentToAddTo (parent), parentToAddTo (parent),
@@ -1661,6 +1661,7 @@ public:
JUCE_COMRESULT DragEnter (IDataObject* pDataObject, DWORD grfKeyState, POINTL mousePos, DWORD* pdwEffect) override JUCE_COMRESULT DragEnter (IDataObject* pDataObject, DWORD grfKeyState, POINTL mousePos, DWORD* pdwEffect) override
{ {
auto hr = updateFileList (pDataObject); auto hr = updateFileList (pDataObject);
if (FAILED (hr)) if (FAILED (hr))
return hr; return hr;
@@ -1689,7 +1690,8 @@ public:
JUCE_COMRESULT Drop (IDataObject* pDataObject, DWORD /*grfKeyState*/, POINTL mousePos, DWORD* pdwEffect) override JUCE_COMRESULT Drop (IDataObject* pDataObject, DWORD /*grfKeyState*/, POINTL mousePos, DWORD* pdwEffect) override
{ {
HRESULT hr = updateFileList (pDataObject);
auto hr = updateFileList (pDataObject);
if (FAILED (hr)) if (FAILED (hr))
return hr; return hr;
@@ -1717,7 +1719,8 @@ public:
for (unsigned int i = 0;;) for (unsigned int i = 0;;)
{ {
unsigned int len = 0; unsigned int len = 0;
while (i + len < totalLen && names [i + len] != 0)
while (i + len < totalLen && names[i + len] != 0)
++len; ++len;
if (len == 0) if (len == 0)
@@ -1767,7 +1770,7 @@ public:
if (SUCCEEDED (fileData.error)) if (SUCCEEDED (fileData.error))
{ {
const LPDROPFILES dropFiles = static_cast<const LPDROPFILES> (fileData.data);
auto dropFiles = static_cast<const LPDROPFILES> (fileData.data);
const void* const names = addBytesToPointer (dropFiles, sizeof (DROPFILES)); const void* const names = addBytesToPointer (dropFiles, sizeof (DROPFILES));
if (dropFiles->fWide) if (dropFiles->fWide)
@@ -1805,7 +1808,6 @@ public:
return false; return false;
} }
double getPlatformScaleFactor() const noexcept override double getPlatformScaleFactor() const noexcept override
{ {
#if JUCE_WIN_PER_MONITOR_DPI_AWARE #if JUCE_WIN_PER_MONITOR_DPI_AWARE
@@ -2222,7 +2224,7 @@ private:
{ {
auto& info = *(ChildWindowClippingInfo*) context; auto& info = *(ChildWindowClippingInfo*) context;
HWND parent = GetParent (hwnd);
auto parent = GetParent (hwnd);
if (parent == info.peer->hwnd) if (parent == info.peer->hwnd)
{ {
@@ -2276,6 +2278,7 @@ private:
// if something in a paint handler calls, e.g. a message box, this can become reentrant and // if something in a paint handler calls, e.g. a message box, this can become reentrant and
// corrupt the image it's using to paint into, so do a check here. // corrupt the image it's using to paint into, so do a check here.
static bool reentrant = false; static bool reentrant = false;
if (! reentrant) if (! reentrant)
{ {
const ScopedValueSetter<bool> setter (reentrant, true, false); const ScopedValueSetter<bool> setter (reentrant, true, false);
@@ -2518,8 +2521,8 @@ private:
} }
static uint32 lastMouseTime = 0; static uint32 lastMouseTime = 0;
static int minTimeBetweenMouses = getMinTimeBetweenMouseMoves();
const uint32 now = Time::getMillisecondCounter();
static auto minTimeBetweenMouses = getMinTimeBetweenMouseMoves();
auto now = Time::getMillisecondCounter();
if (! Desktop::getInstance().getMainMouseSource().isDragging()) if (! Desktop::getInstance().getMainMouseSource().isDragging())
modsToSend = modsToSend.withoutMouseButtons(); modsToSend = modsToSend.withoutMouseButtons();
@@ -2653,6 +2656,7 @@ private:
wheel.isInertial = false; wheel.isInertial = false;
Point<float> localPos; Point<float> localPos;
if (auto* peer = findPeerUnderMouse (localPos)) if (auto* peer = findPeerUnderMouse (localPos))
peer->handleMouseWheel (getPointerType (wParam), localPos, getMouseEventTime(), wheel); peer->handleMouseWheel (getPointerType (wParam), localPos, getMouseEventTime(), wheel);
} }
@@ -2791,6 +2795,7 @@ private:
if (pointerType == MouseInputSource::InputSourceType::touch) if (pointerType == MouseInputSource::InputSourceType::touch)
{ {
POINTER_TOUCH_INFO touchInfo; POINTER_TOUCH_INFO touchInfo;
if (! getPointerTouchInfo (GET_POINTERID_WPARAM (wParam), &touchInfo)) if (! getPointerTouchInfo (GET_POINTERID_WPARAM (wParam), &touchInfo))
return false; return false;
@@ -2806,6 +2811,7 @@ private:
else if (pointerType == MouseInputSource::InputSourceType::pen) else if (pointerType == MouseInputSource::InputSourceType::pen)
{ {
POINTER_PEN_INFO penInfo; POINTER_PEN_INFO penInfo;
if (! getPointerPenInfo (GET_POINTERID_WPARAM (wParam), &penInfo)) if (! getPointerPenInfo (GET_POINTERID_WPARAM (wParam), &penInfo))
return false; return false;
@@ -2825,7 +2831,8 @@ private:
TOUCHINPUT emulateTouchEventFromPointer (LPARAM lParam, WPARAM wParam) TOUCHINPUT emulateTouchEventFromPointer (LPARAM lParam, WPARAM wParam)
{ {
Point<int> p (GET_X_LPARAM (lParam), GET_Y_LPARAM (lParam));
Point<int> p (GET_X_LPARAM (lParam),
GET_Y_LPARAM (lParam));
#if JUCE_WIN_PER_MONITOR_DPI_AWARE #if JUCE_WIN_PER_MONITOR_DPI_AWARE
if (! isPerMonitorDPIAwareThread()) if (! isPerMonitorDPIAwareThread())
@@ -3931,7 +3938,7 @@ private:
break; break;
for (selectionEnd = selectionStart; selectionEnd < attributeSizeBytes; ++selectionEnd) for (selectionEnd = selectionStart; selectionEnd < attributeSizeBytes; ++selectionEnd)
if (attributes [selectionEnd] != ATTR_TARGET_CONVERTED && attributes[selectionEnd] != ATTR_TARGET_NOTCONVERTED)
if (attributes[selectionEnd] != ATTR_TARGET_CONVERTED && attributes[selectionEnd] != ATTR_TARGET_NOTCONVERTED)
break; break;
} }
} }
@@ -3968,7 +3975,7 @@ private:
if (ImmGetCompositionString (hImc, GCS_COMPCLAUSE, clauseData, (DWORD) clauseDataSizeBytes) > 0) if (ImmGetCompositionString (hImc, GCS_COMPCLAUSE, clauseData, (DWORD) clauseDataSizeBytes) > 0)
for (size_t i = 0; i + 1 < numItems; ++i) for (size_t i = 0; i + 1 < numItems; ++i)
result.add (Range<int> ((int) clauseData [i], (int) clauseData [i + 1]) + compositionRange.getStart());
result.add (Range<int> ((int) clauseData[i], (int) clauseData[i + 1]) + compositionRange.getStart());
} }
} }
@@ -4040,8 +4047,8 @@ bool KeyPress::isKeyCurrentlyDown (const int keyCode)
(SHORT) ']', VK_OEM_6 }; (SHORT) ']', VK_OEM_6 };
for (int i = 0; i < numElementsInArray (translatedValues); i += 2) for (int i = 0; i < numElementsInArray (translatedValues); i += 2)
if (k == translatedValues [i])
k = translatedValues [i + 1];
if (k == translatedValues[i])
k = translatedValues[i + 1];
} }
return HWNDComponentPeer::isKeyDown (k); return HWNDComponentPeer::isKeyDown (k);
@@ -4428,7 +4435,7 @@ static const Displays::Display* getCurrentDisplayFromScaleFactor (HWND hwnd)
//============================================================================== //==============================================================================
struct MonitorInfo struct MonitorInfo
{ {
MonitorInfo (bool main, const RECT& rect, double d) noexcept
MonitorInfo (bool main, RECT rect, double d) noexcept
: isMain (main), bounds (rect), dpi (d) {} : isMain (main), bounds (rect), dpi (d) {}
bool isMain; bool isMain;
@@ -4454,7 +4461,6 @@ static BOOL CALLBACK enumMonitorsProc (HMONITOR hm, HDC, LPRECT r, LPARAM userIn
} }
((Array<MonitorInfo>*) userInfo)->add ({ isMain, *r, dpi }); ((Array<MonitorInfo>*) userInfo)->add ({ isMain, *r, dpi });
return TRUE; return TRUE;
} }
@@ -4538,7 +4544,7 @@ void Displays::findDisplays (float masterScale)
static HICON extractFileHICON (const File& file) static HICON extractFileHICON (const File& file)
{ {
WORD iconNum = 0; WORD iconNum = 0;
WCHAR name [MAX_PATH * 2];
WCHAR name[MAX_PATH * 2];
file.getFullPathName().copyToUTF16 (name, sizeof (name)); file.getFullPathName().copyToUTF16 (name, sizeof (name));
return ExtractAssociatedIcon ((HINSTANCE) Process::getCurrentModuleInstanceHandle(), return ExtractAssociatedIcon ((HINSTANCE) Process::getCurrentModuleInstanceHandle(),
@@ -4659,12 +4665,10 @@ void* MouseCursor::createStandardMouseCursor (const MouseCursor::StandardCursorT
jassertfalse; break; jassertfalse; break;
} }
HCURSOR cursorH = LoadCursor (0, cursorName);
if (cursorH == 0)
cursorH = LoadCursor (0, IDC_ARROW);
if (auto cursorH = LoadCursor (0, cursorName))
return cursorH;
return cursorH;
return LoadCursor (0, IDC_ARROW);
} }
//============================================================================== //==============================================================================
@@ -4680,9 +4684,4 @@ void MouseCursor::showInWindow (ComponentPeer*) const
SetCursor (c); SetCursor (c);
} }
void MouseCursor::showInAllWindows() const
{
showInWindow (nullptr);
}
} // namespace juce } // namespace juce

Loading…
Cancel
Save