Skip to content

Commit

Permalink
Update to Avalonia@747c6a62 (Apr 15 2023) (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpobst committed Jul 11, 2023
1 parent f5eb837 commit 7fa6688
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 81 deletions.
12 changes: 5 additions & 7 deletions src/Modern.WindowKit/Avalonia.Mac/WindowImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ internal partial class WindowImpl : WindowBaseImpl, IWindowImpl
//private DoubleClickHelper _doubleClickHelper;
//private readonly ITopLevelNativeMenuExporter _nativeMenuExporter;
//private readonly AvaloniaNativeTextInputMethod _inputMethod;
private bool _canResize = true;

internal WindowImpl(IAvaloniaNativeFactory factory, AvaloniaNativePlatformOptions opts
) : base(factory, opts)
Expand Down Expand Up @@ -75,6 +76,7 @@ void IAvnWindowEvents.GotInputWhenDisabled()

public void CanResize(bool value)
{
_canResize = value;
_native.SetCanResize(value.AsComBool());
}

Expand Down Expand Up @@ -137,14 +139,10 @@ public override void Show(bool activate, bool isDialog)
// {
// if (_doubleClickHelper.IsDoubleClick(e.Timestamp, e.Position))
// {
// // TOGGLE WINDOW STATE.
// if (WindowState == WindowState.Maximized || WindowState == WindowState.FullScreen)
// if (_canResize)
// {
// WindowState = WindowState.Normal;
// }
// else
// {
// WindowState = WindowState.Maximized;
// WindowState = WindowState is WindowState.Maximized or WindowState.FullScreen ?
// WindowState.Normal : WindowState.Maximized;
// }
// }
// else
Expand Down
55 changes: 29 additions & 26 deletions src/Modern.WindowKit/Avalonia.Win32/WindowImpl.AppWndProc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ protected virtual unsafe IntPtr AppWndProc(IntPtr hWnd, uint msg, IntPtr wParam,

case WindowsMessage.WM_DESTROY:
{
// The first and foremost thing to do - notify the TopLevel
Closed?.Invoke();

//if (UiaCoreTypesApi.IsNetComInteropAvailable)
//{
// UiaCoreProviderApi.UiaReturnRawElementProvider(_hwnd, IntPtr.Zero, IntPtr.Zero, null);
Expand All @@ -96,11 +99,22 @@ protected virtual unsafe IntPtr AppWndProc(IntPtr hWnd, uint msg, IntPtr wParam,
// Imm32InputMethod.Current.ClearLanguageAndWindow();
//}

// Cleanup render targets
(_gl as IDisposable)?.Dispose();

//if (_dropTarget != null)
//{
// OleContext.Current?.UnregisterDragDrop(Handle);
// _dropTarget.Dispose();
// _dropTarget = null;
//}

_framebuffer.Dispose();

//Window doesn't exist anymore
_hwnd = IntPtr.Zero;
//Remove root reference to this class, so unmanaged delegate can be collected
s_instances.Remove(this);
Closed?.Invoke();

_mouseDevice.Dispose();
_touchDevice.Dispose();
Expand Down Expand Up @@ -717,36 +731,25 @@ protected virtual unsafe IntPtr AppWndProc(IntPtr hWnd, uint msg, IntPtr wParam,
}
case WindowsMessage.WM_IME_COMPOSITION:
{
//var previousComposition = Imm32InputMethod.Current.Composition;

//var flags = (GCS)ToInt32(lParam);

//var currentComposition = Imm32InputMethod.Current.GetCompositionString(GCS.GCS_COMPSTR);
//if ((flags & GCS.GCS_COMPSTR) != 0)
//{
// var currentComposition = Imm32InputMethod.Current.GetCompositionString(GCS.GCS_COMPSTR);

//Imm32InputMethod.Current.CompositionChanged(currentComposition);
// Imm32InputMethod.Current.CompositionChanged(currentComposition);
//}

//switch (flags)
//if ((flags & GCS.GCS_RESULTSTR) != 0)
//{
// case GCS.GCS_RESULTSTR:
// {
// if(!string.IsNullOrEmpty(previousComposition) && ToInt32(wParam) >= 32)
// {
// Imm32InputMethod.Current.Composition = previousComposition;

// _ignoreWmChar = true;
// }
// break;
// }
// case GCS.GCS_RESULTREADCLAUSE | GCS.GCS_RESULTSTR | GCS.GCS_RESULTCLAUSE:
// {
// // Chinese IME sends WM_CHAR after composition has finished.
// break;
// }
// case GCS.GCS_RESULTREADSTR | GCS.GCS_RESULTREADCLAUSE | GCS.GCS_RESULTSTR | GCS.GCS_RESULTCLAUSE:
// {
// // Japanese IME sends WM_CHAR after composition has finished.
// break;
// }
// var result = Imm32InputMethod.Current.GetCompositionString(GCS.GCS_RESULTSTR);

// if (!string.IsNullOrEmpty(result))
// {
// Imm32InputMethod.Current.Composition = result;

// _ignoreWmChar = true;
// }
//}

break;
Expand Down
18 changes: 6 additions & 12 deletions src/Modern.WindowKit/Avalonia.Win32/WindowImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,12 @@ public WindowImpl()

CreateWindow();
_framebuffer = new FramebufferManager(_hwnd);
UpdateInputMethod(GetKeyboardLayout(0));

if (this is not PopupImpl)
{
UpdateInputMethod(GetKeyboardLayout(0));
}

//if (glPlatform != null)
//{
// if (_isUsingComposition)
Expand Down Expand Up @@ -619,15 +624,6 @@ public void Activate()

public void Dispose()
{
//(_gl as IDisposable)?.Dispose();

//if (_dropTarget != null)
//{
// OleContext.Current?.UnregisterDragDrop(Handle);
// _dropTarget.Dispose();
// _dropTarget = null;
//}

if (_hwnd != IntPtr.Zero)
{
// Detect if we are being closed programmatically - this would mean that WM_CLOSE was not called
Expand All @@ -640,8 +636,6 @@ public void Dispose()
DestroyWindow(_hwnd);
_hwnd = IntPtr.Zero;
}

//_framebuffer.Dispose();
}

public void Invalidate(Rect rect)
Expand Down
5 changes: 2 additions & 3 deletions src/Modern.WindowKit/Avalonia.X11/X11Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ public void Initialize(X11PlatformOptions options)
// useXim = true;
//}

// XIM doesn't work at all otherwise
if (useXim)
setlocale(0, "");
// We have problems with text input otherwise
setlocale(0, "");

XInitThreads();
Display = XOpenDisplay(IntPtr.Zero);
Expand Down
2 changes: 1 addition & 1 deletion src/Modern.WindowKit/Avalonia.X11/X11Window.Ime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private void InitializeIme()
// }
}

private void UpdateImePosition() { } // => _imeControl?.UpdateWindowInfo(Position, RenderScaling);
private void UpdateImePosition() { } // => _imeControl?.UpdateWindowInfo(_position ?? default, RenderScaling);

private void HandleKeyEvent(ref XEvent ev)
{
Expand Down
Loading

0 comments on commit 7fa6688

Please sign in to comment.