mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-27 02:20:05 +00:00
Adds proper per-monitor scaling support on linux
This commit is contained in:
parent
a0c30467da
commit
c76876d388
4 changed files with 751 additions and 156 deletions
|
|
@ -105,6 +105,11 @@
|
|||
#include <X11/cursorfont.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if JUCE_USE_XRANDR
|
||||
/* If you're trying to use Xrandr, you'll need to install the "libxrandr-dev" package.. */
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#endif
|
||||
|
||||
#if JUCE_USE_XINERAMA
|
||||
/* If you're trying to use Xinerama, you'll need to install the "libxinerama-dev" package.. */
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
|
|
|
|||
|
|
@ -38,8 +38,20 @@
|
|||
#define JUCE_ENABLE_REPAINT_DEBUGGING 0
|
||||
#endif
|
||||
|
||||
/** JUCE_USE_XRANDR: Enables Xrandr multi-monitor support (Linux only).
|
||||
Unless you specifically want to disable this, it's best to leave this option turned on.
|
||||
Note that your users do not need to have Xrandr installed for your JUCE app to run, as
|
||||
the availability of Xrandr is queried during runtime.
|
||||
*/
|
||||
#ifndef JUCE_USE_XRANDR
|
||||
#define JUCE_USE_XRANDR 1
|
||||
#endif
|
||||
|
||||
/** JUCE_USE_XINERAMA: Enables Xinerama multi-monitor support (Linux only).
|
||||
Unless you specifically want to disable this, it's best to leave this option turned on.
|
||||
This will be used as a fallback if JUCE_USE_XRANDR not set or libxrandr cannot be found.
|
||||
Note that your users do not need to have Xrandr installed for your JUCE app to run, as
|
||||
the availability of Xinerama is queried during runtime.
|
||||
*/
|
||||
#ifndef JUCE_USE_XINERAMA
|
||||
#define JUCE_USE_XINERAMA 1
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -26,16 +26,20 @@
|
|||
extern Display* display;
|
||||
extern XContext windowHandleXContext;
|
||||
|
||||
//==============================================================================
|
||||
// Defined juce_linux_Windowing.cpp
|
||||
Rectangle<int> juce_LinuxScaledToPhysicalBounds(ComponentPeer* peer, const Rectangle<int>& bounds);
|
||||
|
||||
//==============================================================================
|
||||
class OpenGLContext::NativeContext
|
||||
{
|
||||
public:
|
||||
NativeContext (Component& component,
|
||||
NativeContext (Component& comp,
|
||||
const OpenGLPixelFormat& cPixelFormat,
|
||||
void* shareContext,
|
||||
bool /*useMultisampling*/,
|
||||
OpenGLVersion)
|
||||
: renderContext (0), embeddedWindow (0), swapFrames (0), bestVisual (0),
|
||||
: component (comp), renderContext (0), embeddedWindow (0), swapFrames (0), bestVisual (0),
|
||||
contextToShareWith (shareContext)
|
||||
{
|
||||
ScopedXLock xlock;
|
||||
|
|
@ -72,7 +76,9 @@ public:
|
|||
swa.event_mask = ExposureMask | StructureNotifyMask;
|
||||
|
||||
Rectangle<int> glBounds (component.getTopLevelComponent()
|
||||
->getLocalArea (&component, component.getLocalBounds()));
|
||||
->getLocalArea (&component, component.getLocalBounds()));
|
||||
|
||||
glBounds = juce_LinuxScaledToPhysicalBounds (peer, glBounds);
|
||||
|
||||
embeddedWindow = XCreateWindow (display, windowH,
|
||||
glBounds.getX(), glBounds.getY(),
|
||||
|
|
@ -144,11 +150,14 @@ public:
|
|||
{
|
||||
bounds = newBounds;
|
||||
|
||||
const Rectangle<int> physicalBounds =
|
||||
juce_LinuxScaledToPhysicalBounds (component.getPeer(), bounds);
|
||||
|
||||
ScopedXLock xlock;
|
||||
XMoveResizeWindow (display, embeddedWindow,
|
||||
bounds.getX(), bounds.getY(),
|
||||
(unsigned int) jmax (1, bounds.getWidth()),
|
||||
(unsigned int) jmax (1, bounds.getHeight()));
|
||||
physicalBounds.getX(), physicalBounds.getY(),
|
||||
(unsigned int) jmax (1, physicalBounds.getWidth()),
|
||||
(unsigned int) jmax (1, physicalBounds.getHeight()));
|
||||
}
|
||||
|
||||
bool setSwapInterval (int numFramesPerSwap)
|
||||
|
|
@ -177,6 +186,7 @@ public:
|
|||
struct Locker { Locker (NativeContext&) {} };
|
||||
|
||||
private:
|
||||
Component& component;
|
||||
GLXContext renderContext;
|
||||
Window embeddedWindow;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue