git subrepo clone --branch=sono6good https://github.com/essej/JUCE.git deps/juce
subrepo: subdir: "deps/juce" merged: "b13f9084e" upstream: origin: "https://github.com/essej/JUCE.git" branch: "sono6good" commit: "b13f9084e" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596"
This commit is contained in:
594
deps/juce/modules/juce_gui_basics/native/x11/juce_linux_X11_DragAndDrop.cpp
vendored
Normal file
594
deps/juce/modules/juce_gui_basics/native/x11/juce_linux_X11_DragAndDrop.cpp
vendored
Normal file
@@ -0,0 +1,594 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2020 - Raw Material Software Limited
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
By using JUCE, you agree to the terms of both the JUCE 6 End-User License
|
||||
Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
|
||||
|
||||
End User License Agreement: www.juce.com/juce-6-licence
|
||||
Privacy Policy: www.juce.com/juce-privacy-policy
|
||||
|
||||
Or: You may also use this code under the terms of the GPL v3 (see
|
||||
www.gnu.org/licenses).
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
extern void* createDraggingHandCursor();
|
||||
extern ComponentPeer* getPeerFor (::Window);
|
||||
|
||||
//==============================================================================
|
||||
class X11DragState
|
||||
{
|
||||
public:
|
||||
X11DragState() = default;
|
||||
|
||||
//==============================================================================
|
||||
bool isDragging() const noexcept
|
||||
{
|
||||
return dragging;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void handleExternalSelectionClear()
|
||||
{
|
||||
if (dragging)
|
||||
externalResetDragAndDrop();
|
||||
}
|
||||
|
||||
void handleExternalSelectionRequest (const XEvent& evt)
|
||||
{
|
||||
auto targetType = evt.xselectionrequest.target;
|
||||
|
||||
XEvent s;
|
||||
s.xselection.type = SelectionNotify;
|
||||
s.xselection.requestor = evt.xselectionrequest.requestor;
|
||||
s.xselection.selection = evt.xselectionrequest.selection;
|
||||
s.xselection.target = targetType;
|
||||
s.xselection.property = None;
|
||||
s.xselection.time = evt.xselectionrequest.time;
|
||||
|
||||
auto* display = getDisplay();
|
||||
|
||||
if (allowedTypes.contains (targetType))
|
||||
{
|
||||
s.xselection.property = evt.xselectionrequest.property;
|
||||
|
||||
X11Symbols::getInstance()->xChangeProperty (display, evt.xselectionrequest.requestor, evt.xselectionrequest.property,
|
||||
targetType, 8, PropModeReplace,
|
||||
reinterpret_cast<const unsigned char*> (textOrFiles.toRawUTF8()),
|
||||
(int) textOrFiles.getNumBytesAsUTF8());
|
||||
}
|
||||
|
||||
X11Symbols::getInstance()->xSendEvent (display, evt.xselectionrequest.requestor, True, 0, &s);
|
||||
}
|
||||
|
||||
void handleExternalDragAndDropStatus (const XClientMessageEvent& clientMsg)
|
||||
{
|
||||
if (expectingStatus)
|
||||
{
|
||||
expectingStatus = false;
|
||||
canDrop = false;
|
||||
silentRect = {};
|
||||
|
||||
const auto& atoms = getAtoms();
|
||||
|
||||
if ((clientMsg.data.l[1] & 1) != 0
|
||||
&& ((Atom) clientMsg.data.l[4] == atoms.XdndActionCopy
|
||||
|| (Atom) clientMsg.data.l[4] == atoms.XdndActionPrivate))
|
||||
{
|
||||
if ((clientMsg.data.l[1] & 2) == 0) // target requests silent rectangle
|
||||
silentRect.setBounds ((int) clientMsg.data.l[2] >> 16, (int) clientMsg.data.l[2] & 0xffff,
|
||||
(int) clientMsg.data.l[3] >> 16, (int) clientMsg.data.l[3] & 0xffff);
|
||||
|
||||
canDrop = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void handleExternalDragButtonReleaseEvent()
|
||||
{
|
||||
if (dragging)
|
||||
X11Symbols::getInstance()->xUngrabPointer (getDisplay(), CurrentTime);
|
||||
|
||||
if (canDrop)
|
||||
{
|
||||
sendExternalDragAndDropDrop();
|
||||
}
|
||||
else
|
||||
{
|
||||
sendExternalDragAndDropLeave();
|
||||
externalResetDragAndDrop();
|
||||
}
|
||||
}
|
||||
|
||||
void handleExternalDragMotionNotify()
|
||||
{
|
||||
auto* display = getDisplay();
|
||||
|
||||
auto newTargetWindow = externalFindDragTargetWindow (X11Symbols::getInstance()
|
||||
->xRootWindow (display,
|
||||
X11Symbols::getInstance()->xDefaultScreen (display)));
|
||||
|
||||
if (targetWindow != newTargetWindow)
|
||||
{
|
||||
if (targetWindow != None)
|
||||
sendExternalDragAndDropLeave();
|
||||
|
||||
canDrop = false;
|
||||
silentRect = {};
|
||||
|
||||
if (newTargetWindow == None)
|
||||
return;
|
||||
|
||||
xdndVersion = getDnDVersionForWindow (newTargetWindow);
|
||||
|
||||
if (xdndVersion == -1)
|
||||
return;
|
||||
|
||||
targetWindow = newTargetWindow;
|
||||
sendExternalDragAndDropEnter();
|
||||
}
|
||||
|
||||
if (! expectingStatus)
|
||||
sendExternalDragAndDropPosition();
|
||||
}
|
||||
|
||||
void handleDragAndDropPosition (const XClientMessageEvent& clientMsg, ComponentPeer* peer)
|
||||
{
|
||||
if (dragAndDropSourceWindow == 0)
|
||||
return;
|
||||
|
||||
dragAndDropSourceWindow = (::Window) clientMsg.data.l[0];
|
||||
|
||||
if (windowH == 0)
|
||||
windowH = (::Window) peer->getNativeHandle();
|
||||
|
||||
auto dropPos = Desktop::getInstance().getDisplays().physicalToLogical (Point<int> ((int) clientMsg.data.l[2] >> 16,
|
||||
(int) clientMsg.data.l[2] & 0xffff));
|
||||
dropPos -= peer->getBounds().getPosition();
|
||||
|
||||
const auto& atoms = getAtoms();
|
||||
|
||||
auto targetAction = atoms.XdndActionCopy;
|
||||
|
||||
for (int i = numElementsInArray (atoms.allowedActions); --i >= 0;)
|
||||
{
|
||||
if ((Atom) clientMsg.data.l[4] == atoms.allowedActions[i])
|
||||
{
|
||||
targetAction = atoms.allowedActions[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sendDragAndDropStatus (true, targetAction);
|
||||
|
||||
if (dragInfo.position != dropPos)
|
||||
{
|
||||
dragInfo.position = dropPos;
|
||||
|
||||
if (dragInfo.isEmpty())
|
||||
updateDraggedFileList (clientMsg, (::Window) peer->getNativeHandle());
|
||||
|
||||
if (! dragInfo.isEmpty())
|
||||
peer->handleDragMove (dragInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void handleDragAndDropDrop (const XClientMessageEvent& clientMsg, ComponentPeer* peer)
|
||||
{
|
||||
if (dragInfo.isEmpty())
|
||||
{
|
||||
// no data, transaction finished in handleDragAndDropSelection()
|
||||
finishAfterDropDataReceived = true;
|
||||
updateDraggedFileList (clientMsg, (::Window) peer->getNativeHandle());
|
||||
}
|
||||
else
|
||||
{
|
||||
handleDragAndDropDataReceived(); // data was already received
|
||||
}
|
||||
}
|
||||
|
||||
void handleDragAndDropEnter (const XClientMessageEvent& clientMsg, ComponentPeer* peer)
|
||||
{
|
||||
dragInfo.clear();
|
||||
srcMimeTypeAtomList.clear();
|
||||
|
||||
dragAndDropCurrentMimeType = 0;
|
||||
auto dndCurrentVersion = (static_cast<unsigned long> (clientMsg.data.l[1]) & 0xff000000) >> 24;
|
||||
|
||||
if (dndCurrentVersion < 3 || dndCurrentVersion > XWindowSystemUtilities::Atoms::DndVersion)
|
||||
{
|
||||
dragAndDropSourceWindow = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& atoms = getAtoms();
|
||||
|
||||
dragAndDropSourceWindow = (::Window) clientMsg.data.l[0];
|
||||
|
||||
if ((clientMsg.data.l[1] & 1) != 0)
|
||||
{
|
||||
XWindowSystemUtilities::ScopedXLock xLock;
|
||||
|
||||
XWindowSystemUtilities::GetXProperty prop (getDisplay(),
|
||||
dragAndDropSourceWindow,
|
||||
atoms.XdndTypeList,
|
||||
0,
|
||||
0x8000000L,
|
||||
false,
|
||||
XA_ATOM);
|
||||
|
||||
if (prop.success && prop.actualType == XA_ATOM && prop.actualFormat == 32 && prop.numItems != 0)
|
||||
{
|
||||
auto* types = prop.data;
|
||||
|
||||
for (unsigned long i = 0; i < prop.numItems; ++i)
|
||||
{
|
||||
unsigned long type;
|
||||
memcpy (&type, types, sizeof (unsigned long));
|
||||
|
||||
if (type != None)
|
||||
srcMimeTypeAtomList.add (type);
|
||||
|
||||
types += sizeof (unsigned long);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.isEmpty())
|
||||
{
|
||||
dragAndDropSourceWindow = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < srcMimeTypeAtomList.size() && dragAndDropCurrentMimeType == 0; ++i)
|
||||
for (int j = 0; j < numElementsInArray (atoms.allowedMimeTypes); ++j)
|
||||
if (srcMimeTypeAtomList[i] == atoms.allowedMimeTypes[j])
|
||||
dragAndDropCurrentMimeType = atoms.allowedMimeTypes[j];
|
||||
|
||||
handleDragAndDropPosition (clientMsg, peer);
|
||||
}
|
||||
|
||||
void handleDragAndDropExit()
|
||||
{
|
||||
if (auto* peer = getPeerFor (windowH))
|
||||
peer->handleDragExit (dragInfo);
|
||||
}
|
||||
|
||||
void handleDragAndDropSelection (const XEvent& evt)
|
||||
{
|
||||
dragInfo.clear();
|
||||
|
||||
if (evt.xselection.property != None)
|
||||
{
|
||||
StringArray lines;
|
||||
|
||||
{
|
||||
MemoryBlock dropData;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
XWindowSystemUtilities::GetXProperty prop (getDisplay(),
|
||||
evt.xany.window,
|
||||
evt.xselection.property,
|
||||
(long) (dropData.getSize() / 4),
|
||||
65536,
|
||||
false,
|
||||
AnyPropertyType);
|
||||
|
||||
if (! prop.success)
|
||||
break;
|
||||
|
||||
dropData.append (prop.data, (size_t) (prop.actualFormat / 8) * prop.numItems);
|
||||
|
||||
if (prop.bytesLeft <= 0)
|
||||
break;
|
||||
}
|
||||
|
||||
lines.addLines (dropData.toString());
|
||||
}
|
||||
|
||||
if (XWindowSystemUtilities::Atoms::isMimeTypeFile (getDisplay(), dragAndDropCurrentMimeType))
|
||||
{
|
||||
for (const auto& line : lines)
|
||||
{
|
||||
const auto escaped = line.replace ("+", "%2B").replace ("file://", String(), true);
|
||||
dragInfo.files.add (URL::removeEscapeChars (escaped));
|
||||
}
|
||||
|
||||
dragInfo.files.trim();
|
||||
dragInfo.files.removeEmptyStrings();
|
||||
}
|
||||
else
|
||||
{
|
||||
dragInfo.text = lines.joinIntoString ("\n");
|
||||
}
|
||||
|
||||
if (finishAfterDropDataReceived)
|
||||
handleDragAndDropDataReceived();
|
||||
}
|
||||
}
|
||||
|
||||
void externalResetDragAndDrop()
|
||||
{
|
||||
if (dragging)
|
||||
{
|
||||
XWindowSystemUtilities::ScopedXLock xLock;
|
||||
X11Symbols::getInstance()->xUngrabPointer (getDisplay(), CurrentTime);
|
||||
}
|
||||
|
||||
if (completionCallback != nullptr)
|
||||
completionCallback();
|
||||
}
|
||||
|
||||
bool externalDragInit (::Window window, bool text, const String& str, std::function<void()>&& cb)
|
||||
{
|
||||
windowH = window;
|
||||
isText = text;
|
||||
textOrFiles = str;
|
||||
targetWindow = windowH;
|
||||
completionCallback = std::move (cb);
|
||||
|
||||
auto* display = getDisplay();
|
||||
|
||||
allowedTypes.add (XWindowSystemUtilities::Atoms::getCreating (display, isText ? "text/plain" : "text/uri-list"));
|
||||
|
||||
auto pointerGrabMask = (unsigned int) (Button1MotionMask | ButtonReleaseMask);
|
||||
|
||||
XWindowSystemUtilities::ScopedXLock xLock;
|
||||
|
||||
if (X11Symbols::getInstance()->xGrabPointer (display, windowH, True, pointerGrabMask,
|
||||
GrabModeAsync, GrabModeAsync, None, None, CurrentTime) == GrabSuccess)
|
||||
{
|
||||
const auto& atoms = getAtoms();
|
||||
|
||||
// No other method of changing the pointer seems to work, this call is needed from this very context
|
||||
X11Symbols::getInstance()->xChangeActivePointerGrab (display, pointerGrabMask, (Cursor) createDraggingHandCursor(), CurrentTime);
|
||||
|
||||
X11Symbols::getInstance()->xSetSelectionOwner (display, atoms.XdndSelection, windowH, CurrentTime);
|
||||
|
||||
// save the available types to XdndTypeList
|
||||
X11Symbols::getInstance()->xChangeProperty (display, windowH, atoms.XdndTypeList, XA_ATOM, 32, PropModeReplace,
|
||||
reinterpret_cast<const unsigned char*> (allowedTypes.getRawDataPointer()), allowedTypes.size());
|
||||
|
||||
dragging = true;
|
||||
xdndVersion = getDnDVersionForWindow (targetWindow);
|
||||
|
||||
sendExternalDragAndDropEnter();
|
||||
handleExternalDragMotionNotify();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
const XWindowSystemUtilities::Atoms& getAtoms() const noexcept { return XWindowSystem::getInstance()->getAtoms(); }
|
||||
::Display* getDisplay() const noexcept { return XWindowSystem::getInstance()->getDisplay(); }
|
||||
|
||||
//==============================================================================
|
||||
void sendDragAndDropMessage (XClientMessageEvent& msg)
|
||||
{
|
||||
auto* display = getDisplay();
|
||||
|
||||
msg.type = ClientMessage;
|
||||
msg.display = display;
|
||||
msg.window = dragAndDropSourceWindow;
|
||||
msg.format = 32;
|
||||
msg.data.l[0] = (long) windowH;
|
||||
|
||||
XWindowSystemUtilities::ScopedXLock xLock;
|
||||
X11Symbols::getInstance()->xSendEvent (display, dragAndDropSourceWindow, False, 0, (XEvent*) &msg);
|
||||
}
|
||||
|
||||
bool sendExternalDragAndDropMessage (XClientMessageEvent& msg)
|
||||
{
|
||||
auto* display = getDisplay();
|
||||
|
||||
msg.type = ClientMessage;
|
||||
msg.display = display;
|
||||
msg.window = targetWindow;
|
||||
msg.format = 32;
|
||||
msg.data.l[0] = (long) windowH;
|
||||
|
||||
XWindowSystemUtilities::ScopedXLock xLock;
|
||||
return X11Symbols::getInstance()->xSendEvent (display, targetWindow, False, 0, (XEvent*) &msg) != 0;
|
||||
}
|
||||
|
||||
void sendExternalDragAndDropDrop()
|
||||
{
|
||||
XClientMessageEvent msg;
|
||||
zerostruct (msg);
|
||||
|
||||
msg.message_type = getAtoms().XdndDrop;
|
||||
msg.data.l[2] = CurrentTime;
|
||||
|
||||
sendExternalDragAndDropMessage (msg);
|
||||
}
|
||||
|
||||
void sendExternalDragAndDropEnter()
|
||||
{
|
||||
XClientMessageEvent msg;
|
||||
zerostruct (msg);
|
||||
|
||||
msg.message_type = getAtoms().XdndEnter;
|
||||
msg.data.l[1] = (xdndVersion << 24);
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
msg.data.l[i + 2] = (long) allowedTypes[i];
|
||||
|
||||
sendExternalDragAndDropMessage (msg);
|
||||
}
|
||||
|
||||
void sendExternalDragAndDropPosition()
|
||||
{
|
||||
XClientMessageEvent msg;
|
||||
zerostruct (msg);
|
||||
|
||||
const auto& atoms = getAtoms();
|
||||
|
||||
msg.message_type = atoms.XdndPosition;
|
||||
|
||||
auto mousePos = Desktop::getInstance().getMousePosition();
|
||||
|
||||
if (silentRect.contains (mousePos)) // we've been asked to keep silent
|
||||
return;
|
||||
|
||||
mousePos = Desktop::getInstance().getDisplays().logicalToPhysical (mousePos);
|
||||
|
||||
msg.data.l[1] = 0;
|
||||
msg.data.l[2] = (mousePos.x << 16) | mousePos.y;
|
||||
msg.data.l[3] = CurrentTime;
|
||||
msg.data.l[4] = (long) atoms.XdndActionCopy; // this is all JUCE currently supports
|
||||
|
||||
expectingStatus = sendExternalDragAndDropMessage (msg);
|
||||
}
|
||||
|
||||
void sendDragAndDropStatus (bool acceptDrop, Atom dropAction)
|
||||
{
|
||||
XClientMessageEvent msg;
|
||||
zerostruct (msg);
|
||||
|
||||
msg.message_type = getAtoms().XdndStatus;
|
||||
msg.data.l[1] = (acceptDrop ? 1 : 0) | 2; // 2 indicates that we want to receive position messages
|
||||
msg.data.l[4] = (long) dropAction;
|
||||
|
||||
sendDragAndDropMessage (msg);
|
||||
}
|
||||
|
||||
void sendExternalDragAndDropLeave()
|
||||
{
|
||||
XClientMessageEvent msg;
|
||||
zerostruct (msg);
|
||||
|
||||
msg.message_type = getAtoms().XdndLeave;
|
||||
sendExternalDragAndDropMessage (msg);
|
||||
}
|
||||
|
||||
void sendDragAndDropFinish()
|
||||
{
|
||||
XClientMessageEvent msg;
|
||||
zerostruct (msg);
|
||||
|
||||
msg.message_type = getAtoms().XdndFinished;
|
||||
sendDragAndDropMessage (msg);
|
||||
}
|
||||
|
||||
void updateDraggedFileList (const XClientMessageEvent& clientMsg, ::Window requestor)
|
||||
{
|
||||
jassert (dragInfo.isEmpty());
|
||||
|
||||
if (dragAndDropSourceWindow != None && dragAndDropCurrentMimeType != None)
|
||||
{
|
||||
auto* display = getDisplay();
|
||||
|
||||
XWindowSystemUtilities::ScopedXLock xLock;
|
||||
X11Symbols::getInstance()->xConvertSelection (display, getAtoms().XdndSelection, dragAndDropCurrentMimeType,
|
||||
XWindowSystemUtilities::Atoms::getCreating (display, "JXSelectionWindowProperty"),
|
||||
requestor, (::Time) clientMsg.data.l[2]);
|
||||
}
|
||||
}
|
||||
|
||||
bool isWindowDnDAware (::Window w) const
|
||||
{
|
||||
int numProperties = 0;
|
||||
auto* properties = X11Symbols::getInstance()->xListProperties (getDisplay(), w, &numProperties);
|
||||
|
||||
bool dndAwarePropFound = false;
|
||||
|
||||
for (int i = 0; i < numProperties; ++i)
|
||||
if (properties[i] == getAtoms().XdndAware)
|
||||
dndAwarePropFound = true;
|
||||
|
||||
if (properties != nullptr)
|
||||
X11Symbols::getInstance()->xFree (properties);
|
||||
|
||||
return dndAwarePropFound;
|
||||
}
|
||||
|
||||
int getDnDVersionForWindow (::Window target)
|
||||
{
|
||||
XWindowSystemUtilities::GetXProperty prop (getDisplay(),
|
||||
target,
|
||||
getAtoms().XdndAware,
|
||||
0,
|
||||
2,
|
||||
false,
|
||||
AnyPropertyType);
|
||||
|
||||
if (prop.success && prop.data != None && prop.actualFormat == 32 && prop.numItems == 1)
|
||||
return jmin ((int) prop.data[0], (int) XWindowSystemUtilities::Atoms::DndVersion);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
::Window externalFindDragTargetWindow (::Window target)
|
||||
{
|
||||
if (target == None)
|
||||
return None;
|
||||
|
||||
if (isWindowDnDAware (target))
|
||||
return target;
|
||||
|
||||
::Window child, phonyWin;
|
||||
int phony;
|
||||
unsigned int uphony;
|
||||
|
||||
X11Symbols::getInstance()->xQueryPointer (getDisplay(), target, &phonyWin, &child, &phony, &phony, &phony, &phony, &uphony);
|
||||
|
||||
return externalFindDragTargetWindow (child);
|
||||
}
|
||||
|
||||
void handleDragAndDropDataReceived()
|
||||
{
|
||||
ComponentPeer::DragInfo dragInfoCopy (dragInfo);
|
||||
|
||||
sendDragAndDropFinish();
|
||||
|
||||
if (! dragInfoCopy.isEmpty())
|
||||
if (auto* peer = getPeerFor (windowH))
|
||||
peer->handleDragDrop (dragInfoCopy);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
::Window windowH = 0, targetWindow = 0, dragAndDropSourceWindow = 0;
|
||||
|
||||
int xdndVersion = -1;
|
||||
bool isText = false, dragging = false, expectingStatus = false, canDrop = false, finishAfterDropDataReceived = false;
|
||||
|
||||
Atom dragAndDropCurrentMimeType;
|
||||
Array<Atom> allowedTypes, srcMimeTypeAtomList;
|
||||
|
||||
ComponentPeer::DragInfo dragInfo;
|
||||
Rectangle<int> silentRect;
|
||||
String textOrFiles;
|
||||
|
||||
std::function<void()> completionCallback = nullptr;
|
||||
|
||||
//==============================================================================
|
||||
JUCE_LEAK_DETECTOR (X11DragState)
|
||||
};
|
||||
|
||||
} // namespace juce
|
240
deps/juce/modules/juce_gui_basics/native/x11/juce_linux_X11_Symbols.cpp
vendored
Normal file
240
deps/juce/modules/juce_gui_basics/native/x11/juce_linux_X11_Symbols.cpp
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2020 - Raw Material Software Limited
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
By using JUCE, you agree to the terms of both the JUCE 6 End-User License
|
||||
Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
|
||||
|
||||
End User License Agreement: www.juce.com/juce-6-licence
|
||||
Privacy Policy: www.juce.com/juce-privacy-policy
|
||||
|
||||
Or: You may also use this code under the terms of the GPL v3 (see
|
||||
www.gnu.org/licenses).
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
namespace X11SymbolHelpers
|
||||
{
|
||||
|
||||
template <typename FuncPtr>
|
||||
struct SymbolBinding
|
||||
{
|
||||
FuncPtr& func;
|
||||
const char* name;
|
||||
};
|
||||
|
||||
template <typename FuncPtr>
|
||||
SymbolBinding<FuncPtr> makeSymbolBinding (FuncPtr& func, const char* name)
|
||||
{
|
||||
return { func, name };
|
||||
}
|
||||
|
||||
template <typename FuncPtr>
|
||||
bool loadSymbols (DynamicLibrary& lib, SymbolBinding<FuncPtr> binding)
|
||||
{
|
||||
if (auto* func = lib.getFunction (binding.name))
|
||||
{
|
||||
binding.func = reinterpret_cast<FuncPtr> (func);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename FuncPtr, typename... Args>
|
||||
bool loadSymbols (DynamicLibrary& lib1, DynamicLibrary& lib2, SymbolBinding<FuncPtr> binding)
|
||||
{
|
||||
return loadSymbols (lib1, binding) || loadSymbols (lib2, binding);
|
||||
}
|
||||
|
||||
template <typename FuncPtr, typename... Args>
|
||||
bool loadSymbols (DynamicLibrary& lib, SymbolBinding<FuncPtr> binding, Args... args)
|
||||
{
|
||||
return loadSymbols (lib, binding) && loadSymbols (lib, args...);
|
||||
}
|
||||
|
||||
template <typename FuncPtr, typename... Args>
|
||||
bool loadSymbols (DynamicLibrary& lib1, DynamicLibrary& lib2, SymbolBinding<FuncPtr> binding, Args... args)
|
||||
{
|
||||
return loadSymbols (lib1, lib2, binding) && loadSymbols (lib1, lib2, args...);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool X11Symbols::loadAllSymbols()
|
||||
{
|
||||
using namespace X11SymbolHelpers;
|
||||
|
||||
if (! loadSymbols (xLib, xextLib,
|
||||
makeSymbolBinding (xAllocClassHint, "XAllocClassHint"),
|
||||
makeSymbolBinding (xAllocSizeHints, "XAllocSizeHints"),
|
||||
makeSymbolBinding (xAllocWMHints, "XAllocWMHints"),
|
||||
makeSymbolBinding (xBitmapBitOrder, "XBitmapBitOrder"),
|
||||
makeSymbolBinding (xBitmapUnit, "XBitmapUnit"),
|
||||
makeSymbolBinding (xChangeActivePointerGrab, "XChangeActivePointerGrab"),
|
||||
makeSymbolBinding (xChangeProperty, "XChangeProperty"),
|
||||
makeSymbolBinding (xCheckTypedWindowEvent, "XCheckTypedWindowEvent"),
|
||||
makeSymbolBinding (xCheckWindowEvent, "XCheckWindowEvent"),
|
||||
makeSymbolBinding (xClearArea, "XClearArea"),
|
||||
makeSymbolBinding (xCloseDisplay, "XCloseDisplay"),
|
||||
makeSymbolBinding (xConnectionNumber, "XConnectionNumber"),
|
||||
makeSymbolBinding (xConvertSelection, "XConvertSelection"),
|
||||
makeSymbolBinding (xCreateColormap, "XCreateColormap"),
|
||||
makeSymbolBinding (xCreateFontCursor, "XCreateFontCursor"),
|
||||
makeSymbolBinding (xCreateGC, "XCreateGC"),
|
||||
makeSymbolBinding (xCreateImage, "XCreateImage"),
|
||||
makeSymbolBinding (xCreatePixmap, "XCreatePixmap"),
|
||||
makeSymbolBinding (xCreatePixmapCursor, "XCreatePixmapCursor"),
|
||||
makeSymbolBinding (xCreatePixmapFromBitmapData, "XCreatePixmapFromBitmapData"),
|
||||
makeSymbolBinding (xCreateWindow, "XCreateWindow"),
|
||||
makeSymbolBinding (xDefaultRootWindow, "XDefaultRootWindow"),
|
||||
makeSymbolBinding (xDefaultScreen, "XDefaultScreen"),
|
||||
makeSymbolBinding (xDefaultScreenOfDisplay, "XDefaultScreenOfDisplay"),
|
||||
makeSymbolBinding (xDefaultVisual, "XDefaultVisual"),
|
||||
makeSymbolBinding (xDefineCursor, "XDefineCursor"),
|
||||
makeSymbolBinding (xDeleteContext, "XDeleteContext"),
|
||||
makeSymbolBinding (xDeleteProperty, "XDeleteProperty"),
|
||||
makeSymbolBinding (xDestroyImage, "XDestroyImage"),
|
||||
makeSymbolBinding (xDestroyWindow, "XDestroyWindow"),
|
||||
makeSymbolBinding (xDisplayHeight, "XDisplayHeight"),
|
||||
makeSymbolBinding (xDisplayHeightMM, "XDisplayHeightMM"),
|
||||
makeSymbolBinding (xDisplayWidth, "XDisplayWidth"),
|
||||
makeSymbolBinding (xDisplayWidthMM, "XDisplayWidthMM"),
|
||||
makeSymbolBinding (xEventsQueued, "XEventsQueued"),
|
||||
makeSymbolBinding (xFindContext, "XFindContext"),
|
||||
makeSymbolBinding (xFlush, "XFlush"),
|
||||
makeSymbolBinding (xFree, "XFree"),
|
||||
makeSymbolBinding (xFreeCursor, "XFreeCursor"),
|
||||
makeSymbolBinding (xFreeColormap, "XFreeColormap"),
|
||||
makeSymbolBinding (xFreeGC, "XFreeGC"),
|
||||
makeSymbolBinding (xFreeModifiermap, "XFreeModifiermap"),
|
||||
makeSymbolBinding (xFreePixmap, "XFreePixmap"),
|
||||
makeSymbolBinding (xGetAtomName, "XGetAtomName"),
|
||||
makeSymbolBinding (xGetErrorDatabaseText, "XGetErrorDatabaseText"),
|
||||
makeSymbolBinding (xGetErrorText, "XGetErrorText"),
|
||||
makeSymbolBinding (xGetGeometry, "XGetGeometry"),
|
||||
makeSymbolBinding (xGetImage, "XGetImage"),
|
||||
makeSymbolBinding (xGetInputFocus, "XGetInputFocus"),
|
||||
makeSymbolBinding (xGetModifierMapping, "XGetModifierMapping"),
|
||||
makeSymbolBinding (xGetPointerMapping, "XGetPointerMapping"),
|
||||
makeSymbolBinding (xGetSelectionOwner, "XGetSelectionOwner"),
|
||||
makeSymbolBinding (xGetVisualInfo, "XGetVisualInfo"),
|
||||
makeSymbolBinding (xGetWMHints, "XGetWMHints"),
|
||||
makeSymbolBinding (xGetWindowAttributes, "XGetWindowAttributes"),
|
||||
makeSymbolBinding (xGetWindowProperty, "XGetWindowProperty"),
|
||||
makeSymbolBinding (xGrabPointer, "XGrabPointer"),
|
||||
makeSymbolBinding (xGrabServer, "XGrabServer"),
|
||||
makeSymbolBinding (xImageByteOrder, "XImageByteOrder"),
|
||||
makeSymbolBinding (xInitImage, "XInitImage"),
|
||||
makeSymbolBinding (xInitThreads, "XInitThreads"),
|
||||
makeSymbolBinding (xInstallColormap, "XInstallColormap"),
|
||||
makeSymbolBinding (xInternAtom, "XInternAtom"),
|
||||
makeSymbolBinding (xkbKeycodeToKeysym, "XkbKeycodeToKeysym"),
|
||||
makeSymbolBinding (xKeysymToKeycode, "XKeysymToKeycode"),
|
||||
makeSymbolBinding (xListProperties, "XListProperties"),
|
||||
makeSymbolBinding (xLockDisplay, "XLockDisplay"),
|
||||
makeSymbolBinding (xLookupString, "XLookupString"),
|
||||
makeSymbolBinding (xMapRaised, "XMapRaised"),
|
||||
makeSymbolBinding (xMapWindow, "XMapWindow"),
|
||||
makeSymbolBinding (xMoveResizeWindow, "XMoveResizeWindow"),
|
||||
makeSymbolBinding (xNextEvent, "XNextEvent"),
|
||||
makeSymbolBinding (xOpenDisplay, "XOpenDisplay"),
|
||||
makeSymbolBinding (xPeekEvent, "XPeekEvent"),
|
||||
makeSymbolBinding (xPending, "XPending"),
|
||||
makeSymbolBinding (xPutImage, "XPutImage"),
|
||||
makeSymbolBinding (xPutPixel, "XPutPixel"),
|
||||
makeSymbolBinding (xQueryBestCursor, "XQueryBestCursor"),
|
||||
makeSymbolBinding (xQueryExtension, "XQueryExtension"),
|
||||
makeSymbolBinding (xQueryPointer, "XQueryPointer"),
|
||||
makeSymbolBinding (xQueryTree, "XQueryTree"),
|
||||
makeSymbolBinding (xRefreshKeyboardMapping, "XRefreshKeyboardMapping"),
|
||||
makeSymbolBinding (xReparentWindow, "XReparentWindow"),
|
||||
makeSymbolBinding (xResizeWindow, "XResizeWindow"),
|
||||
makeSymbolBinding (xRestackWindows, "XRestackWindows"),
|
||||
makeSymbolBinding (xRootWindow, "XRootWindow"),
|
||||
makeSymbolBinding (xSaveContext, "XSaveContext"),
|
||||
makeSymbolBinding (xScreenCount, "XScreenCount"),
|
||||
makeSymbolBinding (xScreenNumberOfScreen, "XScreenNumberOfScreen"),
|
||||
makeSymbolBinding (xSelectInput, "XSelectInput"),
|
||||
makeSymbolBinding (xSendEvent, "XSendEvent"),
|
||||
makeSymbolBinding (xSetClassHint, "XSetClassHint"),
|
||||
makeSymbolBinding (xSetErrorHandler, "XSetErrorHandler"),
|
||||
makeSymbolBinding (xSetIOErrorHandler, "XSetIOErrorHandler"),
|
||||
makeSymbolBinding (xSetInputFocus, "XSetInputFocus"),
|
||||
makeSymbolBinding (xSetSelectionOwner, "XSetSelectionOwner"),
|
||||
makeSymbolBinding (xSetWMHints, "XSetWMHints"),
|
||||
makeSymbolBinding (xSetWMIconName, "XSetWMIconName"),
|
||||
makeSymbolBinding (xSetWMName, "XSetWMName"),
|
||||
makeSymbolBinding (xSetWMNormalHints, "XSetWMNormalHints"),
|
||||
makeSymbolBinding (xStringListToTextProperty, "XStringListToTextProperty"),
|
||||
makeSymbolBinding (xSync, "XSync"),
|
||||
makeSymbolBinding (xSynchronize, "XSynchronize"),
|
||||
makeSymbolBinding (xTranslateCoordinates, "XTranslateCoordinates"),
|
||||
makeSymbolBinding (xrmUniqueQuark, "XrmUniqueQuark"),
|
||||
makeSymbolBinding (xUngrabPointer, "XUngrabPointer"),
|
||||
makeSymbolBinding (xUngrabServer, "XUngrabServer"),
|
||||
makeSymbolBinding (xUnlockDisplay, "XUnlockDisplay"),
|
||||
makeSymbolBinding (xUnmapWindow, "XUnmapWindow"),
|
||||
makeSymbolBinding (xutf8TextListToTextProperty, "Xutf8TextListToTextProperty"),
|
||||
makeSymbolBinding (xWarpPointer, "XWarpPointer")))
|
||||
return false;
|
||||
|
||||
#if JUCE_USE_XCURSOR
|
||||
loadSymbols (xcursorLib,
|
||||
makeSymbolBinding (xcursorImageCreate, "XcursorImageCreate"),
|
||||
makeSymbolBinding (xcursorImageLoadCursor, "XcursorImageLoadCursor"),
|
||||
makeSymbolBinding (xcursorImageDestroy, "XcursorImageDestroy"));
|
||||
#endif
|
||||
#if JUCE_USE_XINERAMA
|
||||
loadSymbols (xineramaLib,
|
||||
makeSymbolBinding (xineramaIsActive, "XineramaIsActive"),
|
||||
makeSymbolBinding (xineramaQueryScreens, "XineramaQueryScreens"));
|
||||
#endif
|
||||
#if JUCE_USE_XRENDER
|
||||
loadSymbols (xrenderLib,
|
||||
makeSymbolBinding (xRenderQueryVersion, "XRenderQueryVersion"),
|
||||
makeSymbolBinding (xRenderFindStandardFormat, "XRenderFindStandardFormat"),
|
||||
makeSymbolBinding (xRenderFindFormat, "XRenderFindFormat"),
|
||||
makeSymbolBinding (xRenderFindVisualFormat, "XRenderFindVisualFormat"));
|
||||
#endif
|
||||
#if JUCE_USE_XRANDR
|
||||
loadSymbols (xrandrLib,
|
||||
makeSymbolBinding (xRRGetScreenResources, "XRRGetScreenResources"),
|
||||
makeSymbolBinding (xRRFreeScreenResources, "XRRFreeScreenResources"),
|
||||
makeSymbolBinding (xRRGetOutputInfo, "XRRGetOutputInfo"),
|
||||
makeSymbolBinding (xRRFreeOutputInfo, "XRRFreeOutputInfo"),
|
||||
makeSymbolBinding (xRRGetCrtcInfo, "XRRGetCrtcInfo"),
|
||||
makeSymbolBinding (xRRFreeCrtcInfo, "XRRFreeCrtcInfo"),
|
||||
makeSymbolBinding (xRRGetOutputPrimary, "XRRGetOutputPrimary"));
|
||||
#endif
|
||||
#if JUCE_USE_XSHM
|
||||
loadSymbols (xLib, xextLib,
|
||||
makeSymbolBinding (xShmAttach, "XShmAttach"),
|
||||
makeSymbolBinding (xShmCreateImage, "XShmCreateImage"),
|
||||
makeSymbolBinding (xShmDetach, "XShmDetach"),
|
||||
makeSymbolBinding (xShmGetEventBase, "XShmGetEventBase"),
|
||||
makeSymbolBinding (xShmPutImage, "XShmPutImage"),
|
||||
makeSymbolBinding (xShmQueryVersion, "XShmQueryVersion"));
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
JUCE_IMPLEMENT_SINGLETON (X11Symbols)
|
||||
|
||||
}
|
620
deps/juce/modules/juce_gui_basics/native/x11/juce_linux_X11_Symbols.h
vendored
Normal file
620
deps/juce/modules/juce_gui_basics/native/x11/juce_linux_X11_Symbols.h
vendored
Normal file
@@ -0,0 +1,620 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2020 - Raw Material Software Limited
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
By using JUCE, you agree to the terms of both the JUCE 6 End-User License
|
||||
Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
|
||||
|
||||
End User License Agreement: www.juce.com/juce-6-licence
|
||||
Privacy Policy: www.juce.com/juce-privacy-policy
|
||||
|
||||
Or: You may also use this code under the terms of the GPL v3 (see
|
||||
www.gnu.org/licenses).
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
//==============================================================================
|
||||
namespace ReturnHelpers
|
||||
{
|
||||
template <typename Type>
|
||||
Type returnDefaultConstructedAnyType() { return {}; }
|
||||
|
||||
template <>
|
||||
inline void returnDefaultConstructedAnyType<void>() {}
|
||||
}
|
||||
|
||||
#define JUCE_GENERATE_FUNCTION_WITH_DEFAULT(functionName, objectName, args, returnType) \
|
||||
using functionName = returnType (*) args; \
|
||||
functionName objectName = [] args -> returnType { return ReturnHelpers::returnDefaultConstructedAnyType<returnType>(); };
|
||||
|
||||
|
||||
//==============================================================================
|
||||
class JUCE_API X11Symbols
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
bool loadAllSymbols();
|
||||
|
||||
//==============================================================================
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XAllocClassHint, xAllocClassHint,
|
||||
(),
|
||||
XClassHint*)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XAllocSizeHints, xAllocSizeHints,
|
||||
(),
|
||||
XSizeHints*)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XAllocWMHints, xAllocWMHints,
|
||||
(),
|
||||
XWMHints*)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XBitmapBitOrder, xBitmapBitOrder,
|
||||
(::Display*),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XBitmapUnit, xBitmapUnit,
|
||||
(::Display*),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XChangeActivePointerGrab, xChangeActivePointerGrab,
|
||||
(::Display*, unsigned int, Cursor, ::Time),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XChangeProperty, xChangeProperty,
|
||||
(::Display*, ::Window, Atom, Atom, int, int, const unsigned char*, int),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XCheckTypedWindowEvent, xCheckTypedWindowEvent,
|
||||
(::Display*, ::Window, int, XEvent*),
|
||||
Bool)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XCheckWindowEvent, xCheckWindowEvent,
|
||||
(::Display*, ::Window, long, XEvent*),
|
||||
Bool)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XClearArea, xClearArea,
|
||||
(::Display*, ::Window, int, int, unsigned int, unsigned int, Bool),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XCloseDisplay, xCloseDisplay,
|
||||
(::Display*),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XConnectionNumber, xConnectionNumber,
|
||||
(::Display*),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XConvertSelection, xConvertSelection,
|
||||
(::Display*, Atom, Atom, Atom, ::Window, ::Time),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XCreateColormap, xCreateColormap,
|
||||
(::Display*, ::Window, Visual*, int),
|
||||
Colormap)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XCreateFontCursor, xCreateFontCursor,
|
||||
(::Display*, unsigned int),
|
||||
Cursor)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XCreateGC, xCreateGC,
|
||||
(::Display*, ::Drawable, unsigned long, XGCValues*),
|
||||
GC)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XCreateImage, xCreateImage,
|
||||
(::Display*, Visual*, unsigned int, int, int, const char*, unsigned int, unsigned int, int, int),
|
||||
XImage*)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XCreatePixmap, xCreatePixmap,
|
||||
(::Display*, ::Drawable, unsigned int, unsigned int, unsigned int),
|
||||
Pixmap)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XCreatePixmapCursor, xCreatePixmapCursor,
|
||||
(::Display*, Pixmap, Pixmap, XColor*, XColor*, unsigned int, unsigned int),
|
||||
Cursor)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XCreatePixmapFromBitmapData, xCreatePixmapFromBitmapData,
|
||||
(::Display*, ::Drawable, const char*, unsigned int, unsigned int, unsigned long, unsigned long, unsigned int),
|
||||
Pixmap)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XCreateWindow, xCreateWindow,
|
||||
(::Display*, ::Window, int, int, unsigned int, unsigned int, unsigned int, int, unsigned int, Visual*, unsigned long, XSetWindowAttributes*),
|
||||
::Window)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XDefaultRootWindow, xDefaultRootWindow,
|
||||
(::Display*),
|
||||
::Window)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XDefaultScreen, xDefaultScreen,
|
||||
(::Display*),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XDefaultScreenOfDisplay, xDefaultScreenOfDisplay,
|
||||
(::Display*),
|
||||
Screen*)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XDefaultVisual, xDefaultVisual,
|
||||
(::Display*, int),
|
||||
Visual*)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XDefineCursor, xDefineCursor,
|
||||
(::Display*, ::Window, Cursor),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XDeleteContext, xDeleteContext,
|
||||
(::Display*, XID, XContext),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XDeleteProperty, xDeleteProperty,
|
||||
(::Display*, Window, Atom),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XDestroyImage, xDestroyImage,
|
||||
(XImage*),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XDestroyWindow, xDestroyWindow,
|
||||
(::Display*, ::Window),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XDisplayHeight, xDisplayHeight,
|
||||
(::Display*, int),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XDisplayHeightMM, xDisplayHeightMM,
|
||||
(::Display*, int),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XDisplayWidth, xDisplayWidth,
|
||||
(::Display*, int),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XDisplayWidthMM, xDisplayWidthMM,
|
||||
(::Display*, int),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XEventsQueued, xEventsQueued,
|
||||
(::Display*, int),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XFindContext, xFindContext,
|
||||
(::Display*, XID, XContext, XPointer*),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XFlush, xFlush,
|
||||
(::Display*),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XFree, xFree,
|
||||
(void*),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XFreeCursor, xFreeCursor,
|
||||
(::Display*, Cursor),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XFreeColormap ,xFreeColormap,
|
||||
(::Display*, Colormap),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XFreeGC, xFreeGC,
|
||||
(::Display*, GC),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XFreeModifiermap, xFreeModifiermap,
|
||||
(XModifierKeymap*),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XFreePixmap, xFreePixmap,
|
||||
(::Display*, Pixmap),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XGetAtomName, xGetAtomName,
|
||||
(::Display*, Atom),
|
||||
char*)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XGetErrorDatabaseText, xGetErrorDatabaseText,
|
||||
(::Display*, const char*, const char*, const char*, const char*, int),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XGetErrorText, xGetErrorText,
|
||||
(::Display*, int, const char*, int),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XGetGeometry, xGetGeometry,
|
||||
(::Display*, ::Drawable, ::Window*, int*, int*, unsigned int*, unsigned int*, unsigned int*, unsigned int*),
|
||||
Status)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XGetImage, xGetImage,
|
||||
(::Display*, ::Drawable, int, int, unsigned int, unsigned int, unsigned long, int),
|
||||
XImage*)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XGetInputFocus, xGetInputFocus,
|
||||
(::Display*, ::Window*, int*),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XGetModifierMapping, xGetModifierMapping,
|
||||
(::Display*),
|
||||
XModifierKeymap*)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XGetPointerMapping, xGetPointerMapping,
|
||||
(::Display*, unsigned char[], int),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XGetSelectionOwner, xGetSelectionOwner,
|
||||
(::Display*, Atom),
|
||||
::Window)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XGetVisualInfo, xGetVisualInfo,
|
||||
(::Display*, long, XVisualInfo*, int*),
|
||||
XVisualInfo*)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XGetWMHints, xGetWMHints,
|
||||
(::Display*, ::Window),
|
||||
XWMHints*)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XGetWindowAttributes, xGetWindowAttributes,
|
||||
(::Display*, ::Window, XWindowAttributes*),
|
||||
Status)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XGetWindowProperty, xGetWindowProperty,
|
||||
(::Display*, ::Window, Atom, long, long, Bool, Atom, Atom*, int*, unsigned long*, unsigned long*, unsigned char**),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XGrabPointer, xGrabPointer,
|
||||
(::Display*, ::Window, Bool, unsigned int, int, int, ::Window, Cursor, ::Time),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XGrabServer, xGrabServer,
|
||||
(::Display*),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XImageByteOrder, xImageByteOrder,
|
||||
(::Display*),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XInitImage, xInitImage,
|
||||
(XImage*),
|
||||
Status)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XInitThreads, xInitThreads,
|
||||
(),
|
||||
Status)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XInstallColormap, xInstallColormap,
|
||||
(::Display*, Colormap),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XInternAtom, xInternAtom,
|
||||
(::Display*, const char*, Bool),
|
||||
Atom)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XkbKeycodeToKeysym, xkbKeycodeToKeysym,
|
||||
(::Display*, KeyCode, unsigned int, unsigned int),
|
||||
KeySym)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XKeysymToKeycode, xKeysymToKeycode,
|
||||
(::Display*, KeySym),
|
||||
KeyCode)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XListProperties, xListProperties,
|
||||
(::Display*, Window, int*),
|
||||
Atom*)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XLockDisplay, xLockDisplay,
|
||||
(::Display*),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XLookupString, xLookupString,
|
||||
(XKeyEvent*, const char*, int, KeySym*, XComposeStatus*),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XMapRaised, xMapRaised,
|
||||
(::Display*, ::Window),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XMapWindow, xMapWindow,
|
||||
(::Display*, ::Window),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XMoveResizeWindow, xMoveResizeWindow,
|
||||
(::Display*, ::Window, int, int, unsigned int, unsigned int),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XNextEvent, xNextEvent,
|
||||
(::Display*, XEvent*),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XOpenDisplay, xOpenDisplay,
|
||||
(const char*),
|
||||
::Display*)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XPeekEvent, xPeekEvent,
|
||||
(::Display*, XEvent*),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XPending, xPending,
|
||||
(::Display*),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XPutImage, xPutImage,
|
||||
(::Display*, ::Drawable, GC, XImage*, int, int, int, int, unsigned int, unsigned int),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XPutPixel, xPutPixel,
|
||||
(XImage*, int, int, unsigned long),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XQueryBestCursor, xQueryBestCursor,
|
||||
(::Display*, ::Drawable, unsigned int, unsigned int, unsigned int*, unsigned int*),
|
||||
Status)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XQueryExtension, xQueryExtension,
|
||||
(::Display*, const char*, int*, int*, int*),
|
||||
Bool)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XQueryPointer, xQueryPointer,
|
||||
(::Display*, ::Window, ::Window*, ::Window*, int*, int*, int*, int*, unsigned int*),
|
||||
Bool)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XQueryTree, xQueryTree,
|
||||
(::Display*, ::Window, ::Window*, ::Window*, ::Window**, unsigned int*),
|
||||
Status)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XRefreshKeyboardMapping, xRefreshKeyboardMapping,
|
||||
(XMappingEvent*),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XReparentWindow, xReparentWindow,
|
||||
(::Display*, ::Window, ::Window, int, int),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XResizeWindow, xResizeWindow,
|
||||
(::Display*, Window, unsigned int, unsigned int),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XRestackWindows, xRestackWindows,
|
||||
(::Display*, ::Window[], int),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XRootWindow, xRootWindow,
|
||||
(::Display*, int),
|
||||
::Window)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XSaveContext, xSaveContext,
|
||||
(::Display*, XID, XContext, XPointer),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XScreenCount, xScreenCount,
|
||||
(::Display*),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XScreenNumberOfScreen, xScreenNumberOfScreen,
|
||||
(Screen*),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XSelectInput, xSelectInput,
|
||||
(::Display*, ::Window, long),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XSendEvent, xSendEvent,
|
||||
(::Display*, ::Window, Bool, long, XEvent*),
|
||||
Status)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XSetClassHint, xSetClassHint,
|
||||
(::Display*, ::Window, XClassHint*),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XSetErrorHandler, xSetErrorHandler,
|
||||
(XErrorHandler),
|
||||
XErrorHandler)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XSetIOErrorHandler, xSetIOErrorHandler,
|
||||
(XIOErrorHandler),
|
||||
XIOErrorHandler)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XSetInputFocus, xSetInputFocus,
|
||||
(::Display*, ::Window, int, ::Time),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XSetSelectionOwner, xSetSelectionOwner,
|
||||
(::Display*, Atom, ::Window, ::Time),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XSetWMHints, xSetWMHints,
|
||||
(::Display*, ::Window, XWMHints*),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XSetWMIconName, xSetWMIconName,
|
||||
(::Display*, ::Window, XTextProperty*),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XSetWMName, xSetWMName,
|
||||
(::Display*, ::Window, XTextProperty*),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XSetWMNormalHints, xSetWMNormalHints,
|
||||
(::Display*, ::Window, XSizeHints*),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XStringListToTextProperty, xStringListToTextProperty,
|
||||
(char**, int, XTextProperty*),
|
||||
Status)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (Xutf8TextListToTextProperty, xutf8TextListToTextProperty,
|
||||
(::Display*, char**, int, XICCEncodingStyle, XTextProperty*),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XSync, xSync,
|
||||
(::Display*, Bool),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XSynchronize, xSynchronize,
|
||||
(::Display*, Bool),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XTranslateCoordinates, xTranslateCoordinates,
|
||||
(::Display*, ::Window, ::Window, int, int, int*, int*, ::Window*),
|
||||
Bool)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XrmUniqueQuark, xrmUniqueQuark,
|
||||
(),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XUngrabPointer, xUngrabPointer,
|
||||
(::Display*, ::Time),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XUngrabServer, xUngrabServer,
|
||||
(::Display*),
|
||||
int)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XUnlockDisplay, xUnlockDisplay,
|
||||
(::Display*),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XUnmapWindow, xUnmapWindow,
|
||||
(::Display*, ::Window),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XWarpPointer, xWarpPointer,
|
||||
(::Display*, ::Window, ::Window, int, int, unsigned int, unsigned int, int, int),
|
||||
void)
|
||||
#if JUCE_USE_XCURSOR
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XcursorImageCreate, xcursorImageCreate,
|
||||
(int, int),
|
||||
XcursorImage*)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XcursorImageLoadCursor, xcursorImageLoadCursor,
|
||||
(::Display*, XcursorImage*),
|
||||
Cursor)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XcursorImageDestroy, xcursorImageDestroy,
|
||||
(XcursorImage*),
|
||||
void)
|
||||
#endif
|
||||
#if JUCE_USE_XINERAMA
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XineramaIsActive, xineramaIsActive,
|
||||
(::Display*),
|
||||
Bool)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XineramaQueryScreens, xineramaQueryScreens,
|
||||
(::Display*, int*),
|
||||
XineramaScreenInfo*)
|
||||
#endif
|
||||
#if JUCE_USE_XRENDER
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XRenderQueryVersion, xRenderQueryVersion,
|
||||
(::Display*, int*, int*),
|
||||
Status)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XRenderFindStandardFormat, xRenderFindStandardFormat,
|
||||
(Display*, int),
|
||||
XRenderPictFormat*)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XRenderFindFormat, xRenderFindFormat,
|
||||
(Display*, unsigned long, XRenderPictFormat*, int),
|
||||
XRenderPictFormat*)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XRenderFindVisualFormat, xRenderFindVisualFormat,
|
||||
(Display*, Visual*),
|
||||
XRenderPictFormat*)
|
||||
#endif
|
||||
#if JUCE_USE_XRANDR
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XRRGetScreenResources, xRRGetScreenResources,
|
||||
(::Display*, Window),
|
||||
XRRScreenResources*)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XRRFreeScreenResources, xRRFreeScreenResources,
|
||||
(XRRScreenResources*),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XRRGetOutputInfo, xRRGetOutputInfo,
|
||||
(::Display*, XRRScreenResources*, RROutput),
|
||||
XRROutputInfo*)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XRRFreeOutputInfo, xRRFreeOutputInfo,
|
||||
(XRROutputInfo*),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XRRGetCrtcInfo, xRRGetCrtcInfo,
|
||||
(::Display*, XRRScreenResources*, RRCrtc),
|
||||
XRRCrtcInfo*)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XRRFreeCrtcInfo, xRRFreeCrtcInfo,
|
||||
(XRRCrtcInfo*),
|
||||
void)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XRRGetOutputPrimary, xRRGetOutputPrimary,
|
||||
(::Display*, ::Window),
|
||||
RROutput)
|
||||
#endif
|
||||
#if JUCE_USE_XSHM
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XShmAttach, xShmAttach,
|
||||
(::Display*, XShmSegmentInfo*),
|
||||
Bool)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XShmCreateImage, xShmCreateImage,
|
||||
(::Display*, Visual*, unsigned int, int, const char*, XShmSegmentInfo*, unsigned int, unsigned int),
|
||||
XImage*)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XShmDetach, xShmDetach,
|
||||
(::Display*, XShmSegmentInfo*),
|
||||
Bool)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XShmGetEventBase, xShmGetEventBase,
|
||||
(::Display*),
|
||||
Status)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XShmPutImage, xShmPutImage,
|
||||
(::Display*, ::Drawable, GC, XImage*, int, int, int, int, unsigned int, unsigned int, bool),
|
||||
Bool)
|
||||
|
||||
JUCE_GENERATE_FUNCTION_WITH_DEFAULT (XShmQueryVersion, xShmQueryVersion,
|
||||
(::Display*, int*, int*, Bool*),
|
||||
Bool)
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_SINGLETON (X11Symbols, false)
|
||||
|
||||
private:
|
||||
X11Symbols() = default;
|
||||
|
||||
~X11Symbols()
|
||||
{
|
||||
clearSingletonInstance();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
DynamicLibrary xLib { "libX11.so.6" }, xextLib { "libXext.so.6" };
|
||||
|
||||
#if JUCE_USE_XCURSOR
|
||||
DynamicLibrary xcursorLib { "libXcursor.so.1" };
|
||||
#endif
|
||||
#if JUCE_USE_XINERAMA
|
||||
DynamicLibrary xineramaLib { "libXinerama.so.1" };
|
||||
#endif
|
||||
#if JUCE_USE_XRENDER
|
||||
DynamicLibrary xrenderLib { "libXrender.so.1" };
|
||||
#endif
|
||||
#if JUCE_USE_XRANDR
|
||||
DynamicLibrary xrandrLib { "libXrandr.so.2" };
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (X11Symbols)
|
||||
};
|
||||
|
||||
}
|
3837
deps/juce/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.cpp
vendored
Normal file
3837
deps/juce/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
346
deps/juce/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.h
vendored
Normal file
346
deps/juce/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.h
vendored
Normal file
@@ -0,0 +1,346 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2020 - Raw Material Software Limited
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
By using JUCE, you agree to the terms of both the JUCE 6 End-User License
|
||||
Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
|
||||
|
||||
End User License Agreement: www.juce.com/juce-6-licence
|
||||
Privacy Policy: www.juce.com/juce-privacy-policy
|
||||
|
||||
Or: You may also use this code under the terms of the GPL v3 (see
|
||||
www.gnu.org/licenses).
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
//==============================================================================
|
||||
namespace XWindowSystemUtilities
|
||||
{
|
||||
//==============================================================================
|
||||
/** A handy struct that uses XLockDisplay and XUnlockDisplay to lock the X server
|
||||
using RAII.
|
||||
|
||||
@tags{GUI}
|
||||
*/
|
||||
struct ScopedXLock
|
||||
{
|
||||
ScopedXLock();
|
||||
~ScopedXLock();
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
/** Gets a specified window property and stores its associated data, freeing it
|
||||
on deletion.
|
||||
|
||||
@tags{GUI}
|
||||
*/
|
||||
struct GetXProperty
|
||||
{
|
||||
GetXProperty (::Display* display, ::Window windowH, Atom property,
|
||||
long offset, long length, bool shouldDelete, Atom requestedType);
|
||||
~GetXProperty();
|
||||
|
||||
bool success = false;
|
||||
unsigned char* data = nullptr;
|
||||
unsigned long numItems = 0, bytesLeft = 0;
|
||||
Atom actualType;
|
||||
int actualFormat = -1;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
/** Initialises and stores some atoms for the display.
|
||||
|
||||
@tags{GUI}
|
||||
*/
|
||||
struct Atoms
|
||||
{
|
||||
enum ProtocolItems
|
||||
{
|
||||
TAKE_FOCUS = 0,
|
||||
DELETE_WINDOW = 1,
|
||||
PING = 2
|
||||
};
|
||||
|
||||
Atoms() = default;
|
||||
explicit Atoms (::Display*);
|
||||
|
||||
static Atom getIfExists (::Display*, const char* name);
|
||||
static Atom getCreating (::Display*, const char* name);
|
||||
|
||||
static String getName (::Display*, Atom);
|
||||
static bool isMimeTypeFile (::Display*, Atom);
|
||||
|
||||
static constexpr unsigned long DndVersion = 3;
|
||||
|
||||
Atom protocols, protocolList[3], changeState, state, userTime, activeWin, pid, windowType, windowState, windowStateHidden,
|
||||
XdndAware, XdndEnter, XdndLeave, XdndPosition, XdndStatus, XdndDrop, XdndFinished, XdndSelection,
|
||||
XdndTypeList, XdndActionList, XdndActionDescription, XdndActionCopy, XdndActionPrivate,
|
||||
XembedMsgType, XembedInfo, allowedActions[5], allowedMimeTypes[4], utf8String, clipboard, targets;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
/** Represents a setting according to the XSETTINGS specification.
|
||||
|
||||
@tags{GUI}
|
||||
*/
|
||||
struct XSetting
|
||||
{
|
||||
enum class Type
|
||||
{
|
||||
integer,
|
||||
string,
|
||||
colour,
|
||||
invalid
|
||||
};
|
||||
|
||||
XSetting() = default;
|
||||
|
||||
XSetting (const String& n, int v) : name (n), type (Type::integer), integerValue (v) {}
|
||||
XSetting (const String& n, const String& v) : name (n), type (Type::string), stringValue (v) {}
|
||||
XSetting (const String& n, const Colour& v) : name (n), type (Type::colour), colourValue (v) {}
|
||||
|
||||
bool isValid() const noexcept { return type != Type::invalid; }
|
||||
|
||||
String name;
|
||||
Type type = Type::invalid;
|
||||
|
||||
int integerValue = -1;
|
||||
String stringValue;
|
||||
Colour colourValue;
|
||||
};
|
||||
|
||||
/** Parses and stores the X11 settings for a display according to the XSETTINGS
|
||||
specification.
|
||||
|
||||
@tags{GUI}
|
||||
*/
|
||||
class XSettings
|
||||
{
|
||||
public:
|
||||
explicit XSettings (::Display*);
|
||||
|
||||
//==============================================================================
|
||||
void update();
|
||||
::Window getSettingsWindow() const noexcept { return settingsWindow; }
|
||||
|
||||
XSetting getSetting (const String& settingName) const;
|
||||
|
||||
//==============================================================================
|
||||
struct Listener
|
||||
{
|
||||
virtual ~Listener() = default;
|
||||
virtual void settingChanged (const XSetting& settingThatHasChanged) = 0;
|
||||
};
|
||||
|
||||
void addListener (Listener* listenerToAdd) { listeners.add (listenerToAdd); }
|
||||
void removeListener (Listener* listenerToRemove) { listeners.remove (listenerToRemove); }
|
||||
|
||||
private:
|
||||
::Display* display = nullptr;
|
||||
::Window settingsWindow = None;
|
||||
Atom settingsAtom;
|
||||
|
||||
int lastUpdateSerial = -1;
|
||||
|
||||
std::unordered_map<String, XSetting> settings;
|
||||
ListenerList<Listener> listeners;
|
||||
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (XSettings)
|
||||
};
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
class LinuxComponentPeer;
|
||||
|
||||
class XWindowSystem : public DeletedAtShutdown
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
::Window createWindow (::Window parentWindow, LinuxComponentPeer*) const;
|
||||
void destroyWindow (::Window);
|
||||
|
||||
void setTitle (::Window, const String&) const;
|
||||
void setIcon (::Window , const Image&) const;
|
||||
void setVisible (::Window, bool shouldBeVisible) const;
|
||||
void setBounds (::Window, Rectangle<int>, bool fullScreen) const;
|
||||
|
||||
BorderSize<int> getBorderSize (::Window) const;
|
||||
Rectangle<int> getWindowBounds (::Window, ::Window parentWindow);
|
||||
Point<int> getPhysicalParentScreenPosition() const;
|
||||
|
||||
bool contains (::Window, Point<int> localPos) const;
|
||||
|
||||
void setMinimised (::Window, bool shouldBeMinimised) const;
|
||||
bool isMinimised (::Window) const;
|
||||
|
||||
void setMaximised (::Window, bool shouldBeMinimised) const;
|
||||
|
||||
void toFront (::Window, bool makeActive) const;
|
||||
void toBehind (::Window, ::Window otherWindow) const;
|
||||
|
||||
bool isFocused (::Window) const;
|
||||
bool grabFocus (::Window) const;
|
||||
|
||||
bool canUseSemiTransparentWindows() const;
|
||||
bool canUseARGBImages() const;
|
||||
bool isDarkModeActive() const;
|
||||
|
||||
int getNumPaintsPendingForWindow (::Window);
|
||||
void processPendingPaintsForWindow (::Window);
|
||||
void addPendingPaintForWindow (::Window);
|
||||
void removePendingPaintForWindow (::Window);
|
||||
|
||||
Image createImage (bool isSemiTransparentWindow, int width, int height, bool argb) const;
|
||||
void blitToWindow (::Window, Image, Rectangle<int> destinationRect, Rectangle<int> totalRect) const;
|
||||
|
||||
void setScreenSaverEnabled (bool enabled) const;
|
||||
|
||||
Point<float> getCurrentMousePosition() const;
|
||||
void setMousePosition (Point<float> pos) const;
|
||||
|
||||
void* createCustomMouseCursorInfo (const Image&, Point<int> hotspot) const;
|
||||
void deleteMouseCursor (void* cursorHandle) const;
|
||||
void* createStandardMouseCursor (MouseCursor::StandardCursorType) const;
|
||||
void showCursor (::Window, void* cursorHandle) const;
|
||||
|
||||
bool isKeyCurrentlyDown (int keyCode) const;
|
||||
ModifierKeys getNativeRealtimeModifiers() const;
|
||||
|
||||
Array<Displays::Display> findDisplays (float masterScale) const;
|
||||
|
||||
::Window createKeyProxy (::Window) const;
|
||||
void deleteKeyProxy (::Window) const;
|
||||
|
||||
bool externalDragFileInit (LinuxComponentPeer*, const StringArray& files, bool canMove, std::function<void()>&& callback) const;
|
||||
bool externalDragTextInit (LinuxComponentPeer*, const String& text, std::function<void()>&& callback) const;
|
||||
|
||||
void copyTextToClipboard (const String&);
|
||||
String getTextFromClipboard() const;
|
||||
String getLocalClipboardContent() const noexcept { return localClipboardContent; }
|
||||
|
||||
::Display* getDisplay() const noexcept { return display; }
|
||||
const XWindowSystemUtilities::Atoms& getAtoms() const noexcept { return atoms; }
|
||||
XWindowSystemUtilities::XSettings* getXSettings() const noexcept { return xSettings.get(); }
|
||||
|
||||
bool isX11Available() const noexcept { return xIsAvailable; }
|
||||
|
||||
static String getWindowScalingFactorSettingName() { return "Gdk/WindowScalingFactor"; }
|
||||
static String getThemeNameSettingName() { return "Net/ThemeName"; }
|
||||
|
||||
//==============================================================================
|
||||
void handleWindowMessage (LinuxComponentPeer*, XEvent&) const;
|
||||
bool isParentWindowOf (::Window, ::Window possibleChild) const;
|
||||
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_SINGLETON (XWindowSystem, false)
|
||||
|
||||
private:
|
||||
XWindowSystem();
|
||||
~XWindowSystem();
|
||||
|
||||
//==============================================================================
|
||||
struct VisualAndDepth
|
||||
{
|
||||
Visual* visual;
|
||||
int depth;
|
||||
};
|
||||
|
||||
struct DisplayVisuals
|
||||
{
|
||||
explicit DisplayVisuals (::Display*);
|
||||
|
||||
VisualAndDepth getBestVisualForWindow (bool) const;
|
||||
bool isValid() const noexcept;
|
||||
|
||||
Visual* visual16Bit = nullptr;
|
||||
Visual* visual24Bit = nullptr;
|
||||
Visual* visual32Bit = nullptr;
|
||||
};
|
||||
|
||||
bool initialiseXDisplay();
|
||||
void destroyXDisplay();
|
||||
|
||||
//==============================================================================
|
||||
::Window getFocusWindow (::Window) const;
|
||||
|
||||
bool isFrontWindow (::Window) const;
|
||||
|
||||
//==============================================================================
|
||||
void xchangeProperty (::Window, Atom, Atom, int, const void*, int) const;
|
||||
|
||||
void removeWindowDecorations (::Window) const;
|
||||
void addWindowButtons (::Window, int) const;
|
||||
void setWindowType (::Window, int) const;
|
||||
|
||||
void initialisePointerMap();
|
||||
void deleteIconPixmaps (::Window) const;
|
||||
void updateModifierMappings() const;
|
||||
|
||||
long getUserTime (::Window) const;
|
||||
|
||||
void initialiseXSettings();
|
||||
|
||||
//==============================================================================
|
||||
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*, XClientMessageEvent&, XEvent&) const;
|
||||
void handleXEmbedMessage (LinuxComponentPeer*, XClientMessageEvent&) const;
|
||||
|
||||
void dismissBlockingModals (LinuxComponentPeer*) const;
|
||||
void dismissBlockingModals (LinuxComponentPeer*, const XConfigureEvent&) const;
|
||||
|
||||
::Window findTopLevelWindowOf (::Window) const;
|
||||
|
||||
static void windowMessageReceive (XEvent&);
|
||||
|
||||
//==============================================================================
|
||||
bool xIsAvailable = false;
|
||||
|
||||
XWindowSystemUtilities::Atoms atoms;
|
||||
::Display* display = nullptr;
|
||||
std::unique_ptr<DisplayVisuals> displayVisuals;
|
||||
std::unique_ptr<XWindowSystemUtilities::XSettings> xSettings;
|
||||
|
||||
#if JUCE_USE_XSHM
|
||||
std::map<::Window, int> shmPaintsPendingMap;
|
||||
#endif
|
||||
|
||||
int shmCompletionEvent = 0;
|
||||
int pointerMap[5] = {};
|
||||
String localClipboardContent;
|
||||
|
||||
Point<int> parentScreenPosition;
|
||||
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (XWindowSystem)
|
||||
};
|
||||
|
||||
} // namespace juce
|
Reference in New Issue
Block a user