mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-21 19:40:58 +00:00
Use Xfixes to show and hide cursor on Linux (#1060)
This commit is contained in:
parent
d509b6c129
commit
0d8f7c7a01
6 changed files with 41 additions and 26 deletions
|
@ -28,7 +28,7 @@ jobs:
|
|||
make mac
|
||||
elif [[ "${{ runner.os }}" == 'Linux' ]]; then
|
||||
sudo apt-get update
|
||||
sudo apt install mesa-common-dev
|
||||
sudo apt install mesa-common-dev libxfixes-dev
|
||||
make linux
|
||||
fi
|
||||
|
||||
|
|
2
Makefile
2
Makefile
|
@ -19,4 +19,4 @@ nativemac:
|
|||
g++ -std=c++14 -O2 --shared -g3 -o Build/libBuilderNative.so -fPIC -I Source/Native Source/Native/*.cpp Source/Native/OpenGL/*.cpp Source/Native/OpenGL/gl_load/*.c -ldl
|
||||
|
||||
native:
|
||||
g++ -std=c++14 -O2 --shared -g3 -o Build/libBuilderNative.so -fPIC -I Source/Native Source/Native/*.cpp Source/Native/OpenGL/*.cpp Source/Native/OpenGL/gl_load/*.c -lX11 -ldl
|
||||
g++ -std=c++14 -O2 --shared -g3 -o Build/libBuilderNative.so -fPIC -I Source/Native Source/Native/*.cpp Source/Native/OpenGL/*.cpp Source/Native/OpenGL/gl_load/*.c -DUDB_LINUX=1 -lX11 -lXfixes -ldl
|
||||
|
|
|
@ -55,6 +55,10 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
mouse = null;
|
||||
}
|
||||
|
||||
#if MONO_WINFORMS
|
||||
MouseInput_ShowCursor(false);
|
||||
#endif
|
||||
|
||||
// We have no destructor
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
@ -67,6 +71,10 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
mouse.Dispose();
|
||||
mouse = null;
|
||||
}
|
||||
|
||||
#if MONO_WINFORMS
|
||||
MouseInput_ShowCursor(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -113,6 +121,11 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#if MONO_WINFORMS
|
||||
[DllImport("BuilderNative.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern void MouseInput_ShowCursor(bool show);
|
||||
#endif
|
||||
}
|
||||
|
||||
public struct MouseState
|
||||
|
|
|
@ -1264,24 +1264,6 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
Cursor.Position = display.PointToScreen(new Point(display.ClientSize.Width / 2, display.ClientSize.Height / 2)); //mxd
|
||||
Cursor.Clip = display.RectangleToScreen(display.ClientRectangle);
|
||||
Cursor.Hide();
|
||||
|
||||
#if MONO_WINFORMS
|
||||
// A beautiful transparent cursor, just for you mono!
|
||||
string emptycursor =
|
||||
"AAACAAEAICACAAAAAAAwAQAAFgAAACgAAAAgAAAAQAAAAAEAAQAAAAAAgAAAAAAAAAAAAAAAAgAA" +
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////////////" +
|
||||
"////////////////////////////////////////////////////////////////////////////" +
|
||||
"//////////////////////////////////////////////////////8=";
|
||||
using (var stream = new MemoryStream(System.Convert.FromBase64String(emptycursor)))
|
||||
{
|
||||
var cursor = new Cursor(stream);
|
||||
Cursor.Current = cursor;
|
||||
display.Cursor = cursor;
|
||||
}
|
||||
Application.DoEvents();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1298,11 +1280,6 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
// Release and show the mouse
|
||||
Cursor.Clip = Rectangle.Empty;
|
||||
Cursor.Position = display.PointToScreen(new Point(display.ClientSize.Width / 2, display.ClientSize.Height / 2));
|
||||
#if MONO_WINFORMS
|
||||
Cursor.Current = Cursors.Default;
|
||||
display.Cursor = Cursors.Default;
|
||||
Application.DoEvents();
|
||||
#endif
|
||||
Cursor.Show();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ extern "C"
|
|||
|
||||
RawMouse* RawMouse_New(void* hwnd)
|
||||
{
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32)
|
||||
return new RawMouse(hwnd);
|
||||
#else
|
||||
return nullptr;
|
||||
|
@ -194,4 +194,28 @@ float RawMouse_GetY(RawMouse* mouse)
|
|||
return mouse->GetY();
|
||||
}
|
||||
|
||||
#ifdef UDB_LINUX
|
||||
#include <X11/extensions/Xfixes.h>
|
||||
|
||||
static Display *display = NULL;
|
||||
#endif
|
||||
|
||||
void MouseInput_ShowCursor(bool show)
|
||||
{
|
||||
#ifdef UDB_LINUX
|
||||
if (display == NULL)
|
||||
{
|
||||
display = XOpenDisplay(NULL);
|
||||
if (display == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
if (show)
|
||||
XFixesShowCursor(display, DefaultRootWindow(display));
|
||||
else
|
||||
XFixesHideCursor(display, DefaultRootWindow(display));
|
||||
XSync(display, True);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ EXPORTS
|
|||
RawMouse_Delete
|
||||
RawMouse_GetX
|
||||
RawMouse_GetY
|
||||
MouseInput_ShowCursor
|
||||
Matrix_Null
|
||||
Matrix_Identity
|
||||
Matrix_Translation
|
||||
|
|
Loading…
Reference in a new issue