Skip to content

Commit 643dac7

Browse files
Updated window moving logic
1 parent 0c67186 commit 643dac7

2 files changed

Lines changed: 41 additions & 9 deletions

File tree

Assets/MATE ENGINE - Scenes/Mate Engine Main.unity

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11139,7 +11139,7 @@ Light:
1113911139
serializedVersion: 11
1114011140
m_Type: 2
1114111141
m_Color: {r: 1, g: 0.26999998, b: 0.96203995, a: 1}
11142-
m_Intensity: 2.4788753e-14
11142+
m_Intensity: 2.3569857e-14
1114311143
m_Range: 0.5
1114411144
m_SpotAngle: 30
1114511145
m_InnerSpotAngle: 21.80208
@@ -43951,7 +43951,7 @@ Light:
4395143951
serializedVersion: 11
4395243952
m_Type: 2
4395343953
m_Color: {r: 0, g: 0.44799995, b: 1, a: 1}
43954-
m_Intensity: 4.9577506e-14
43954+
m_Intensity: 4.7139715e-14
4395543955
m_Range: 1
4395643956
m_SpotAngle: 30
4395743957
m_InnerSpotAngle: 21.80208
@@ -52491,7 +52491,7 @@ Light:
5249152491
serializedVersion: 11
5249252492
m_Type: 2
5249352493
m_Color: {r: 0, g: 0.44799995, b: 1, a: 1}
52494-
m_Intensity: 3.718313e-14
52494+
m_Intensity: 3.5354786e-14
5249552495
m_Range: 1
5249652496
m_SpotAngle: 30
5249752497
m_InnerSpotAngle: 21.80208
@@ -165244,7 +165244,7 @@ MonoBehaviour:
165244165244
groupID: ambi_lights
165245165245
exclusiveTags:
165246165246
- lights
165247-
fadeCurrentValue: 1.23943765e-14
165247+
fadeCurrentValue: 1.1784929e-14
165248165248
fadeTarget: 0
165249165249
isFading: 1
165250165250
hasYSet: 0
@@ -165268,7 +165268,7 @@ MonoBehaviour:
165268165268
groupID: ambi_lights
165269165269
exclusiveTags:
165270165270
- lights
165271-
fadeCurrentValue: 1.23943765e-14
165271+
fadeCurrentValue: 1.1784929e-14
165272165272
fadeTarget: 0
165273165273
isFading: 1
165274165274
hasYSet: 0
@@ -165292,7 +165292,7 @@ MonoBehaviour:
165292165292
groupID: ambi_lights
165293165293
exclusiveTags:
165294165294
- lights
165295-
fadeCurrentValue: 1.23943765e-14
165295+
fadeCurrentValue: 1.1784929e-14
165296165296
fadeTarget: 0
165297165297
isFading: 1
165298165298
hasYSet: 0

Assets/MATE ENGINE - Scripts/APIs/X11Manager.cs

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,35 @@ public void SetWindowPosition(float x, float y)
151151
}
152152

153153
public void SetWindowPosition(Vector2 position)
154+
{
155+
if (_display != IntPtr.Zero && _unityWindow != IntPtr.Zero)
156+
{
157+
IntPtr atom = XInternAtom(_display, "_NET_MOVERESIZE_WINDOW", true);
158+
if (atom == IntPtr.Zero)
159+
{
160+
ShowError("Cannot find atom for _NET_MOVERESIZE_WINDOW!");
161+
return;
162+
}
163+
XClientMessageEvent xClient = new XClientMessageEvent
164+
{
165+
type = ClientMessage,
166+
window = _unityWindow,
167+
message_type = atom,
168+
format = 32,
169+
data = new IntPtr[5]
170+
};
171+
xClient.data[0] = new IntPtr((1 << 12) | (1 << 9) | (1 << 8) | 10);
172+
xClient.data[1] = new((int)position.x);
173+
xClient.data[2] = new((int)position.y);
174+
xClient.data[3] = IntPtr.Zero;
175+
xClient.data[4] = IntPtr.Zero;
176+
177+
XSendEvent(_display, _rootWindow, false, SubstructureRedirectMask | SubstructureNotifyMask, ref xClient);
178+
XFlush(_display);
179+
}
180+
}
181+
182+
public void SetWindowPositionLegacy(Vector2 position)
154183
{
155184
if (_display != IntPtr.Zero && _unityWindow != IntPtr.Zero)
156185
{
@@ -344,7 +373,7 @@ public void SetTopmost(bool topmost = true)
344373

345374
XClientMessageEvent xClient = new XClientMessageEvent
346375
{
347-
type = 33, // ClientMessage
376+
type = ClientMessage,
348377
window = _unityWindow,
349378
message_type = wmNetWmState,
350379
format = 32,
@@ -370,7 +399,7 @@ public void HideFromTaskbar(bool reallyHide = true)
370399

371400
XClientMessageEvent msg = new()
372401
{
373-
type = 33, // ClientMessage
402+
type = ClientMessage,
374403
display = _display,
375404
window = _unityWindow,
376405
message_type = netWmState,
@@ -811,7 +840,10 @@ await Task.Run(() =>
811840
private const long MWM_DECORATIONS_NONE = 0; // No decorations
812841
private const int PropModeReplace = 0;
813842

843+
private const int ClientMessage = 33;
814844
private const long StructureNotifyMask = (1L << 17);
845+
private const long SubstructureRedirectMask = 0x00080000;
846+
private const long SubstructureNotifyMask = 0x00040000;
815847
private const int ConfigureNotify = 22;
816848
private const int DestroyNotify = 17;
817849
private const int ShapeBounding = 0;
@@ -1234,4 +1266,4 @@ private static extern IntPtr XGetImage(IntPtr display, IntPtr drawable, int x, i
12341266

12351267
#endregion
12361268
}
1237-
}
1269+
}

0 commit comments

Comments
 (0)