Fixed title bar hittest and changing cursor

This commit is contained in:
Simon Lübeß
2024-11-03 19:09:18 +01:00
parent 4a18d3150f
commit 80048951f8
3 changed files with 86 additions and 24 deletions
@@ -31,9 +31,39 @@ class UltralightMainWindow : UltralightWindow
_hoveringNonClientArea = JSValueToBoolean(context, arguments[0]);
_window.[Friend]_hoveredOverTitleBar = _hoveringNonClientArea;
Log.ClientLogger.Info($"_hoveringNonClientArea: {_hoveringNonClientArea}");
}
void HandleHoverMaximizeWindow(JSContextRef context, JSObjectRef thisObject, Span<JSValueRef> arguments, JSValueRef* exception = null)
{
Log.EngineLogger.Info("HandleHoverMaximizeWindow");
if (arguments.Length != 1)
{
Log.EngineLogger.Error("EngineGlue.HandleHoverMaximizeWindow: called with wrong number of arguments.");
return;
}
if (!JSValueIsBoolean(context, arguments[0]))
{
Log.EngineLogger.Error($"EngineGlue.HandleHoverMaximizeWindow: expected boolean, but received {JSValueGetType(context, arguments[0])} instead.");
return;
}
if (JSValueToBoolean(context, arguments[0]))
_window.[Friend]_hoveredTitleBarButton = .Maximize;
else
{
_window.[Friend]_hoveredTitleBarButton = .None;
Log.ClientLogger.Info($"esar ogsdflkg aerwufg");
}
EditorLayer.HoveredTitleBarButton = _window.[Friend]_hoveredTitleBarButton;
Log.ClientLogger.Info($"_hoveredTitleBarButton: {_window.[Friend]_hoveredTitleBarButton}");
}
private void RegisterBeefFunction(JSContextRef context, JSObjectRef object, StringView functionName, JSCallback callback)
{
JSObjectRef func = UltralightHelper.CreateJsFunctionFromDelegate(context, callback);
@@ -68,6 +98,7 @@ class UltralightMainWindow : UltralightWindow
StdAllocator stdAlloc = StdAllocator();
RegisterBeefFunction(context, scriptGlue, "setHoverNonClientArea", new:stdAlloc => HandleHoverNonClientArea);
RegisterBeefFunction(context, scriptGlue, "setHoverMaximizeWindow", new:stdAlloc => HandleHoverMaximizeWindow);
}
protected override void OnDOMReady(C_View* caller, uint64 frame_id, bool is_main_frame, C_String* url)
@@ -224,14 +224,12 @@ abstract class UltralightWindow
ulDestroyMouseEvent(evt);
_cursorPosition = .(e.PositionX, e.PositionY);
Log.EngineLogger.Warning($"{_cursorPosition.X} {_cursorPosition.Y}");
return true;
}
private bool MousePressed(MouseButtonEvent e, bool press)
{
Log.ClientLogger.Warning($"{e.MouseButton} {press}");
ULMouseButton button = .kMouseButton_None;