Merge remote-tracking branch 'origin/master' into 1.7

# Conflicts:
#	Flax.flaxproj
This commit is contained in:
Wojtek Figat
2023-10-09 12:40:47 +02:00
86 changed files with 1406 additions and 686 deletions

View File

@@ -945,7 +945,7 @@ const char* ButtonCodeToKeyName(KeyboardKeys code)
// Row #6
case KeyboardKeys::Control: return "LCTL"; // Left Control
case KeyboardKeys::LeftWindows: return "LWIN";
case KeyboardKeys::LeftMenu: return "LALT";
case KeyboardKeys::Alt: return "LALT";
case KeyboardKeys::Spacebar: return "SPCE";
case KeyboardKeys::RightMenu: return "RALT";
case KeyboardKeys::RightWindows: return "RWIN";
@@ -2700,6 +2700,8 @@ Float2 LinuxPlatform::GetDesktopSize()
if (screenIdx >= count)
return Float2::Zero;
// this function is used as a fallback to place a window at the center of
// a screen so we report only one screen instead of the real desktop
Float2 size((float)xsi[screenIdx].width, (float)xsi[screenIdx].height);
X11::XFree(xsi);
return size;
@@ -2707,14 +2709,72 @@ Float2 LinuxPlatform::GetDesktopSize()
Rectangle LinuxPlatform::GetMonitorBounds(const Float2& screenPos)
{
// TODO: do it in a proper way
return Rectangle(Float2::Zero, GetDesktopSize());
if (!xDisplay)
return Rectangle::Empty;
int event, err;
const bool ok = X11::XineramaQueryExtension(xDisplay, &event, &err);
if (!ok)
return Rectangle::Empty;
int count;
int screenIdx = 0;
X11::XineramaScreenInfo* xsi = X11::XineramaQueryScreens(xDisplay, &count);
if (screenIdx >= count)
return Rectangle::Empty;
// find the screen for this screenPos
for (int i = 0; i < count; i++)
{
if (screenPos.X >= xsi[i].x_org && screenPos.X < xsi[i].x_org+xsi[i].width
&& screenPos.Y >= xsi[i].y_org && screenPos.Y < xsi[i].y_org+xsi[i].height)
{
screenIdx = i;
break;
}
}
Float2 org((float)xsi[screenIdx].x_org, (float)xsi[screenIdx].y_org);
Float2 size((float)xsi[screenIdx].width, (float)xsi[screenIdx].height);
X11::XFree(xsi);
return Rectangle(org, size);
}
Rectangle LinuxPlatform::GetVirtualDesktopBounds()
{
// TODO: do it in a proper way
return Rectangle(Float2::Zero, GetDesktopSize());
if (!xDisplay)
return Rectangle::Empty;
int event, err;
const bool ok = X11::XineramaQueryExtension(xDisplay, &event, &err);
if (!ok)
return Rectangle::Empty;
int count;
X11::XineramaScreenInfo* xsi = X11::XineramaQueryScreens(xDisplay, &count);
if (count <= 0)
return Rectangle::Empty;
// get all screen dimensions and assume the monitors form a rectangle
// as you can arrange monitors to your liking this is not necessarily the case
int minX = INT32_MAX, minY = INT32_MAX;
int maxX = 0, maxY = 0;
for (int i = 0; i < count; i++)
{
int maxScreenX = xsi[i].x_org + xsi[i].width;
int maxScreenY = xsi[i].y_org + xsi[i].height;
if (maxScreenX > maxX)
maxX = maxScreenX;
if (maxScreenY > maxY)
maxY = maxScreenY;
if (minX > xsi[i].x_org)
minX = xsi[i].x_org;
if (minY > xsi[i].y_org)
minY = xsi[i].y_org;
}
Float2 org(static_cast<float>(minX), static_cast<float>(minY));
Float2 size(static_cast<float>(maxX - minX), static_cast<float>(maxY - minY));
X11::XFree(xsi);
return Rectangle(org, size);
}
String LinuxPlatform::GetMainDirectory()

View File

@@ -41,8 +41,10 @@ extern Dictionary<StringAnsi, X11::KeyCode> KeyNameMap;
extern Array<KeyboardKeys> KeyCodeMap;
extern X11::Cursor Cursors[(int32)CursorType::MAX];
static const uint32 MouseDoubleClickTime = 500;
static constexpr uint32 MouseDoubleClickTime = 500;
static constexpr uint32 MaxDoubleClickDistanceSquared = 10;
static X11::Time MouseLastButtonPressTime = 0;
static Float2 OldMouseClickPosition;
LinuxWindow::LinuxWindow(const CreateWindowSettings& settings)
: WindowBase(settings)
@@ -153,7 +155,11 @@ LinuxWindow::LinuxWindow(const CreateWindowSettings& settings)
hints.max_height = (int)settings.MaximumSize.Y;
hints.flags |= USSize;
}
X11::XSetNormalHints(display, window, &hints);
// honor the WM placement except for manual (overriding) placements
if (settings.StartPosition == WindowStartPosition::Manual)
{
X11::XSetNormalHints(display, window, &hints);
}
// Ensures the child window is always on top of the parent window
if (settings.Parent)
@@ -595,15 +601,19 @@ void LinuxWindow::OnButtonPress(void* event)
// Handle double-click
if (buttonEvent->button == Button1)
{
if (buttonEvent->time < (MouseLastButtonPressTime + MouseDoubleClickTime))
if (
buttonEvent->time < (MouseLastButtonPressTime + MouseDoubleClickTime) &&
Float2::DistanceSquared(mousePos, OldMouseClickPosition) < MaxDoubleClickDistanceSquared)
{
Input::Mouse->OnMouseDoubleClick(ClientToScreen(mousePos), mouseButton, this);
MouseLastButtonPressTime = 0;
OldMouseClickPosition = mousePos;
return;
}
else
{
MouseLastButtonPressTime = buttonEvent->time;
OldMouseClickPosition = mousePos;
}
}