I’m back again for a stupid request but it’s really painful defaut behaviour.
Is there a way to set the main monitor index ?
Currently in my dual monitor setup, the monitor with index 1 is not the “main” monitor, but Juce default to popping its dialog on it.
I’ve fixed this everywhere in my code (thus I can’t use centreWithSize / kiosk-mode and co), but as soon as I need to add a dialog, I forget about this again, or I simply can’t change it (like file browser dialog).
As both Linux and Windows returns monitor indexed by a number, I don’t get why Juce doesn’t respect this.
When I list monitors with Xinerama functions, I do get the same index as I’ve specified in my xorg.conf (and the API is clear, it’s an screen number, not an index in a table).
Currently, it’s a painful parse all monitor and find the one with the right resolution (which is, IMHO very hacky and will break for similar resolution monitors) to figure out the monitor index.
Here’s a quick fix for juce_Desktop.cpp
// Line 115
const Rectangle<int> Desktop::getMainMonitorArea (const bool clippedToWorkArea) const throw()
return getDisplayMonitorCoordinates (defaultMonitorIndex, clippedToWorkArea);
void Desktop::setDefaultMonitorIndex(const int index)
defaultMonitorIndex = index;
// Append defaultMonitorIndex to the members and initialize to 0
Ideally, I would prefer Juce to respect the same order as what is said in the configuration file.
I’ts certainly supposed to work correctly, and definitely works on mac + windows… Looking at the linux code, it does sort the screens by the screen_number value that xinerama returns, which I’d have expected to reflect the correct order…? (of course in typical linux style, there’s zero documentation for the XineramaScreenInfo struct, so hard to know what that number really represents)
My monitor 0 is on the right of the monitor 1 (I can’t change this).
I doubt it works on Mac or Windows, or only in the case if the 2nd monitor is on the right of or below the first (not above or on the left).
Anyway, I think using a global monitor index as the main monitor would at least allow to fix this (so the code should read:
Components in general aren’t designed to be aware of monitor positions, and centreWithSize() wasn’t designed for use on the desktop - it expects to be inside a parent component, where the origin is always at (0, 0).
In fact it does all work ok on windows + mac because they always ensure that the main monitor contains the origin, regardless of the monitor positions, which seems very sensible to me.
Your suggestion would break any non-desktop comps, but it could be made a bit smarter, e.g.
[quote=“jules”]Components in general aren’t designed to be aware of monitor positions, and centreWithSize() wasn’t designed for use on the desktop - it expects to be inside a parent component, where the origin is always at (0, 0).
All internal Juce’s dialog (FileChooser, AlertWindow, …) don’t have a parent component set when they call centreWithSize (debugged them, so I’m sure about this, parentComponent_ is null).
They somehow fallback to the main monitor size (through getParentMonitorArea) but ignore its position, just use the size.
Maybe Windows allow negative coordinates for a monitor. I will check. If it’s not the case, I wonder how the main monitor put on the right of the second monitor (with windows’s term, that is the 2 inside the monitor icon in Desktop properties) could be at 0x0.