|
|
@@ -45,6 +45,8 @@ namespace Avalonia.X11
|
|
|
private IntPtr _handle;
|
|
|
private IntPtr _xic;
|
|
|
private IntPtr _renderHandle;
|
|
|
+ private IntPtr _xSyncCounter;
|
|
|
+ private XSyncValue _xSyncValue;
|
|
|
private bool _mapped;
|
|
|
private bool _wasMappedAtLeastOnce = false;
|
|
|
private double? _scalingOverride;
|
|
|
@@ -190,6 +192,16 @@ namespace Avalonia.X11
|
|
|
NativeMenuExporter = DBusMenuExporter.TryCreateTopLevelNativeMenu(_handle);
|
|
|
NativeControlHost = new X11NativeControlHost(_platform, this);
|
|
|
InitializeIme();
|
|
|
+
|
|
|
+ XChangeProperty(_x11.Display, _handle, _x11.Atoms.WM_PROTOCOLS, _x11.Atoms.XA_ATOM, 32,
|
|
|
+ PropertyMode.Replace, new[] { _x11.Atoms.WM_DELETE_WINDOW, _x11.Atoms._NET_WM_SYNC_REQUEST }, 2);
|
|
|
+
|
|
|
+ if (_x11.HasXSync)
|
|
|
+ {
|
|
|
+ _xSyncCounter = XSyncCreateCounter(_x11.Display, _xSyncValue);
|
|
|
+ XChangeProperty(_x11.Display, _handle, _x11.Atoms._NET_WM_SYNC_REQUEST_COUNTER,
|
|
|
+ _x11.Atoms.XA_CARDINAL, 32, PropertyMode.Replace, ref _xSyncCounter, 1);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
class SurfaceInfo : EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo
|
|
|
@@ -383,15 +395,7 @@ namespace Avalonia.X11
|
|
|
(ev.type == XEventName.VisibilityNotify &&
|
|
|
ev.VisibilityEvent.state < 2))
|
|
|
{
|
|
|
- if (!_triggeredExpose)
|
|
|
- {
|
|
|
- _triggeredExpose = true;
|
|
|
- Dispatcher.UIThread.Post(() =>
|
|
|
- {
|
|
|
- _triggeredExpose = false;
|
|
|
- DoPaint();
|
|
|
- }, DispatcherPriority.Render);
|
|
|
- }
|
|
|
+ EnqueuePaint();
|
|
|
}
|
|
|
else if (ev.type == XEventName.FocusIn)
|
|
|
{
|
|
|
@@ -503,6 +507,7 @@ namespace Avalonia.X11
|
|
|
if (_useRenderWindow)
|
|
|
XConfigureResizeWindow(_x11.Display, _renderHandle, ev.ConfigureEvent.width,
|
|
|
ev.ConfigureEvent.height);
|
|
|
+ EnqueuePaint();
|
|
|
}
|
|
|
else if (ev.type == XEventName.DestroyNotify
|
|
|
&& ev.DestroyWindowEvent.window == _handle)
|
|
|
@@ -518,7 +523,11 @@ namespace Avalonia.X11
|
|
|
if (Closing?.Invoke() != true)
|
|
|
Dispose();
|
|
|
}
|
|
|
-
|
|
|
+ else if (ev.ClientMessageEvent.ptr1 == _x11.Atoms._NET_WM_SYNC_REQUEST)
|
|
|
+ {
|
|
|
+ _xSyncValue.Lo = new UIntPtr(ev.ClientMessageEvent.ptr3.ToPointer()).ToUInt32();
|
|
|
+ _xSyncValue.Hi = ev.ClientMessageEvent.ptr4.ToInt32();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else if (ev.type == XEventName.KeyPress || ev.type == XEventName.KeyRelease)
|
|
|
@@ -730,9 +739,24 @@ namespace Avalonia.X11
|
|
|
ScheduleInput(mev, ref ev);
|
|
|
}
|
|
|
|
|
|
+ void EnqueuePaint()
|
|
|
+ {
|
|
|
+ if (!_triggeredExpose)
|
|
|
+ {
|
|
|
+ _triggeredExpose = true;
|
|
|
+ Dispatcher.UIThread.Post(() =>
|
|
|
+ {
|
|
|
+ _triggeredExpose = false;
|
|
|
+ DoPaint();
|
|
|
+ }, DispatcherPriority.Render);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
void DoPaint()
|
|
|
{
|
|
|
Paint?.Invoke(new Rect());
|
|
|
+ if (_xSyncCounter != IntPtr.Zero)
|
|
|
+ XSyncSetCounter(_x11.Display, _xSyncCounter, _xSyncValue);
|
|
|
}
|
|
|
|
|
|
public void Invalidate(Rect rect)
|