Merge branch 'nothingTVatYT-fix-linuxwindow'
This commit is contained in:
@@ -94,6 +94,7 @@ X11::XcursorImage* CursorsImg[(int32)CursorType::MAX];
|
||||
Dictionary<StringAnsi, X11::KeyCode> KeyNameMap;
|
||||
Array<KeyboardKeys> KeyCodeMap;
|
||||
Delegate<void*> LinuxPlatform::xEventRecieved;
|
||||
Window* MouseTrackingWindow = nullptr;
|
||||
|
||||
// Message boxes configuration
|
||||
#define LINUX_DIALOG_MIN_BUTTON_WIDTH 64
|
||||
@@ -1916,7 +1917,6 @@ bool LinuxPlatform::Init()
|
||||
{
|
||||
if (PlatformBase::Init())
|
||||
return true;
|
||||
|
||||
char fileNameBuffer[1024];
|
||||
|
||||
// Init timing
|
||||
@@ -2398,7 +2398,7 @@ void LinuxPlatform::Tick()
|
||||
// Update input context focus
|
||||
X11::XSetICFocus(IC);
|
||||
window = WindowsManager::GetByNativePtr((void*)event.xfocus.window);
|
||||
if (window)
|
||||
if (window && MouseTrackingWindow == nullptr)
|
||||
{
|
||||
window->OnGotFocus();
|
||||
}
|
||||
@@ -2407,7 +2407,7 @@ void LinuxPlatform::Tick()
|
||||
// Update input context focus
|
||||
X11::XUnsetICFocus(IC);
|
||||
window = WindowsManager::GetByNativePtr((void*)event.xfocus.window);
|
||||
if (window)
|
||||
if (window && MouseTrackingWindow == nullptr)
|
||||
{
|
||||
window->OnLostFocus();
|
||||
}
|
||||
@@ -2514,23 +2514,32 @@ void LinuxPlatform::Tick()
|
||||
break;
|
||||
case ButtonPress:
|
||||
window = WindowsManager::GetByNativePtr((void*)event.xbutton.window);
|
||||
if (window)
|
||||
if (MouseTrackingWindow)
|
||||
MouseTrackingWindow->OnButtonPress(&event.xbutton);
|
||||
else if (window)
|
||||
window->OnButtonPress(&event.xbutton);
|
||||
break;
|
||||
case ButtonRelease:
|
||||
window = WindowsManager::GetByNativePtr((void*)event.xbutton.window);
|
||||
if (window)
|
||||
if (MouseTrackingWindow)
|
||||
MouseTrackingWindow->OnButtonRelease(&event.xbutton);
|
||||
else if (window)
|
||||
window->OnButtonRelease(&event.xbutton);
|
||||
break;
|
||||
case MotionNotify:
|
||||
window = WindowsManager::GetByNativePtr((void*)event.xmotion.window);
|
||||
if (window)
|
||||
if (MouseTrackingWindow)
|
||||
MouseTrackingWindow->OnMotionNotify(&event.xmotion);
|
||||
else if (window)
|
||||
window->OnMotionNotify(&event.xmotion);
|
||||
break;
|
||||
case EnterNotify:
|
||||
// nothing?
|
||||
break;
|
||||
case LeaveNotify:
|
||||
window = WindowsManager::GetByNativePtr((void*)event.xcrossing.window);
|
||||
if (MouseTrackingWindow)
|
||||
MouseTrackingWindow->OnLeaveNotify(&event.xcrossing);
|
||||
if (window)
|
||||
window->OnLeaveNotify(&event.xcrossing);
|
||||
break;
|
||||
|
||||
@@ -40,6 +40,7 @@ extern X11::Atom xAtomWmName;
|
||||
extern Dictionary<StringAnsi, X11::KeyCode> KeyNameMap;
|
||||
extern Array<KeyboardKeys> KeyCodeMap;
|
||||
extern X11::Cursor Cursors[(int32)CursorType::MAX];
|
||||
extern Window* MouseTrackingWindow;
|
||||
|
||||
static constexpr uint32 MouseDoubleClickTime = 500;
|
||||
static constexpr uint32 MaxDoubleClickDistanceSquared = 10;
|
||||
@@ -54,7 +55,7 @@ LinuxWindow::LinuxWindow(const CreateWindowSettings& settings)
|
||||
return;
|
||||
auto screen = XDefaultScreen(display);
|
||||
|
||||
// Cache data
|
||||
// Cache data
|
||||
int32 width = Math::TruncToInt(settings.Size.X);
|
||||
int32 height = Math::TruncToInt(settings.Size.Y);
|
||||
_clientSize = Float2((float)width, (float)height);
|
||||
@@ -111,6 +112,12 @@ LinuxWindow::LinuxWindow(const CreateWindowSettings& settings)
|
||||
windowAttributes.border_pixel = XBlackPixel(display, screen);
|
||||
windowAttributes.event_mask = KeyPressMask | KeyReleaseMask | StructureNotifyMask | ExposureMask;
|
||||
|
||||
if (!settings.IsRegularWindow)
|
||||
{
|
||||
windowAttributes.save_under = true;
|
||||
windowAttributes.override_redirect = true;
|
||||
}
|
||||
|
||||
// TODO: implement all window settings
|
||||
/*
|
||||
bool Fullscreen;
|
||||
@@ -118,11 +125,16 @@ LinuxWindow::LinuxWindow(const CreateWindowSettings& settings)
|
||||
bool AllowMaximize;
|
||||
*/
|
||||
|
||||
unsigned long valueMask = CWBackPixel | CWBorderPixel | CWEventMask | CWColormap;
|
||||
if (!settings.IsRegularWindow)
|
||||
{
|
||||
valueMask |= CWOverrideRedirect | CWSaveUnder;
|
||||
}
|
||||
const X11::Window window = X11::XCreateWindow(
|
||||
display, X11::XRootWindow(display, screen), x, y,
|
||||
width, height, 0, visualInfo->depth, InputOutput,
|
||||
visualInfo->visual,
|
||||
CWBackPixel | CWBorderPixel | CWEventMask | CWColormap, &windowAttributes);
|
||||
valueMask, &windowAttributes);
|
||||
_window = window;
|
||||
LinuxWindow::SetTitle(settings.Title);
|
||||
|
||||
@@ -811,12 +823,13 @@ void LinuxWindow::SetTitle(const StringView& title)
|
||||
|
||||
void LinuxWindow::StartTrackingMouse(bool useMouseScreenOffset)
|
||||
{
|
||||
// TODO: impl this
|
||||
MouseTrackingWindow = this;
|
||||
}
|
||||
|
||||
void LinuxWindow::EndTrackingMouse()
|
||||
{
|
||||
// TODO: impl this
|
||||
if (MouseTrackingWindow == this)
|
||||
MouseTrackingWindow = nullptr;
|
||||
}
|
||||
|
||||
void LinuxWindow::SetCursor(CursorType type)
|
||||
|
||||
Reference in New Issue
Block a user