Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Headers/x11/XGCursorScale.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2026 Simon Peter
*
* SPDX-License-Identifier: BSD-2-Clause OR LGPL-2.1-or-later
*/

#ifndef _XGCursorScale_h_INCLUDE
#define _XGCursorScale_h_INCLUDE

#include <stdint.h>

#define XG_CURSOR_BASE_SIZE 24

int XGCursorThemeSize(double factor, int allFactorsOne);

int XGCursorScaledLength(double points, double factor);

void XGCursorScaleARGB(const uint32_t *src, int sw, int sh,
uint32_t *dst, int dw, int dh);

#endif
5 changes: 5 additions & 0 deletions Headers/x11/XGServerWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ typedef struct _gswindow_device_t {
uint32_t net_wm_sync_request_counter_value_high;
XSyncCounter net_wm_sync_request_counter;
#endif
float extents[4];
BOOL extents_cached;
unsigned long resize_serial;
BOOL resize_pending;
} gswindow_device_t;

#define GET_XDRAWABLE(win) ((win)->buffer ? (win)->buffer: (win)->ident)
Expand All @@ -139,6 +143,7 @@ typedef struct _gswindow_device_t {

/* This needs to go in GSDisplayServer */
- (void) _DPSsetcursor: (Cursor)c : (BOOL)set;
- (void) _pointerMovedToRootX: (int)x y: (int)y;

- (int) _wm_state: (Window) win;
- (BOOL) _ewmh_isHidden: (Window) win;
Expand Down
3 changes: 3 additions & 0 deletions Source/x11/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,21 @@ SUBPROJECT_NAME=x11
ifeq ($(USE_WRASTER),1)
ifeq ($(WITH_WRASTER),yes)
x11_C_FILES = \
cursorscale.c \
xdnd.c
else
x11_C_FILES = \
context.c \
convert.c \
cursorscale.c \
raster.c \
scale.c \
xdnd.c \
xutil.c
endif
else
x11_C_FILES = \
cursorscale.c \
xdnd.c \
xlibimage.c
endif
Expand Down
3 changes: 2 additions & 1 deletion Source/x11/XGServer.m
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,8 @@ - (id) _initXContext

#ifdef HAVE_XRANDR
XRRQueryExtension(dpy, &randrEventBase, &randrErrorBase);
XRRSelectInput(dpy, RootWindow(dpy, defScreen), RRScreenChangeNotifyMask);
XRRSelectInput(dpy, RootWindow(dpy, defScreen),
RRScreenChangeNotifyMask | RROutputPropertyNotifyMask);
#endif
return self;
}
Expand Down
85 changes: 85 additions & 0 deletions Source/x11/XGServerEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,19 @@ void __objc_xgcontextevent_linking (void)
{
}

static Bool
realConfigureQueued(Display *dpy, XEvent *ev, XPointer arg)
{
Window *w = (Window *)arg;

if (ev->type == ConfigureNotify && ev->xconfigure.window == w[0]
&& ev->xconfigure.send_event == False)
{
w[1] = 1;
}
return False;
}

static SEL procSel = 0;
static void (*procEvent)(id, SEL, XEvent*) = 0;

Expand Down Expand Up @@ -996,6 +1009,33 @@ - (void) processEvent: (XEvent *) event
x.origin.y = root_y;
}

if (xEvent.xconfigure.send_event
|| (long)(xEvent.xconfigure.serial - cWin->resize_serial) < 0)
{
x.size = r.size;
}
else if (cWin->resize_pending && !NSEqualSizes(x.size, r.size))
{
XEvent scratch;
Window probe[2] = { cWin->ident, 0 };

XSync(dpy, False);
XCheckIfEvent(dpy, &scratch, realConfigureQueued,
(XPointer)probe);
if (probe[1])
{
x.size = r.size;
}
else
{
cWin->resize_pending = NO;
}
}
else if (xEvent.xconfigure.send_event == False)
{
cWin->resize_pending = NO;
}

cWin->xframe = x;
n = [self _XFrameToOSFrame: x for: cWin];
NSDebugLLog(@"Moving",
Expand Down Expand Up @@ -1102,6 +1142,8 @@ - (void) processEvent: (XEvent *) event
case EnterNotify:
NSDebugLLog(@"NSEvent", @"%lu EnterNotify\n",
xEvent.xcrossing.window);
[self _pointerMovedToRootX: xEvent.xcrossing.x_root
y: xEvent.xcrossing.y_root];
break;

// when the pointer leaves a window
Expand Down Expand Up @@ -1558,6 +1600,8 @@ - (void) processEvent: (XEvent *) event

generic.lastMotion = xEvent.xmotion.time;
[self setLastTime: generic.lastMotion];
[self _pointerMovedToRootX: xEvent.xmotion.x_root
y: xEvent.xmotion.y_root];
state = xEvent.xmotion.state;
if (state & generic.lMouseMask)
{
Expand Down Expand Up @@ -1618,6 +1662,35 @@ - (void) processEvent: (XEvent *) event
NSDebugLLog(@"NSEvent", @"%lu PropertyNotify - '%s'\n",
xEvent.xproperty.window,
XGetAtomName(dpy, xEvent.xproperty.atom));
if (xEvent.xproperty.atom == generic._NET_FRAME_EXTENTS_ATOM)
{
gswindow_device_t *device
= [XGServer _windowForXWindow: xEvent.xproperty.window];

if (device != NULL)
{
NSRect osframe;

device->extents_cached = NO;
osframe = [self _XFrameToOSFrame: device->xframe for: device];
if (!NSEqualRects(osframe, device->osframe))
{
NSEvent *r;

device->osframe = osframe;
r = [NSEvent otherEventWithType: NSAppKitDefined
location: osframe.origin
modifierFlags: 0
timestamp: xEvent.xproperty.time / 1000
windowNumber: device->number
context: gcontext
subtype: GSAppKitWindowResized
data1: osframe.size.width
data2: osframe.size.height];
[[NSApp windowWithWindowNumber: device->number] sendEvent: r];
}
}
}
if (xEvent.xproperty.atom == generic.WM_STATE_ATOM)
{
if (cWin == 0 || xEvent.xproperty.window != cWin->ident)
Expand Down Expand Up @@ -1933,6 +2006,18 @@ - (void) processEvent: (XEvent *) event
}
#endif
#ifdef HAVE_XRANDR
if (xEvent.type == randrEventBase + RRNotify
&& ((XRRNotifyEvent *)&xEvent)->subtype == RRNotify_OutputProperty
&& ((XRROutputPropertyNotifyEvent *)&xEvent)->property
== XInternAtom(dpy, "DPI", True))
{
[self screenList];
[NSScreen resetScreens];
[[NSNotificationCenter defaultCenter]
postNotificationName: NSApplicationDidChangeScreenParametersNotification
object: NSApp];
break;
}
int randr_event_type = randrEventBase + RRScreenChangeNotify;
if (xEvent.type == randr_event_type
&& (xEvent.xconfigure.window == RootWindow(dpy, defScreen)))
Expand Down
Loading
Loading