Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build errors with Wayland on Debian 13 (trixie) using Clang 16 #48

Merged
merged 9 commits into from
Aug 28, 2024
4 changes: 3 additions & 1 deletion Source/wayland/WaylandServer+Cursor.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
#include <linux/input.h>
#include "wayland-cursor.h"

extern void wl_cursor_destroy(struct wl_cursor *cursor);

// XXX should this be configurable by the user?
#define DOUBLECLICK_DELAY 300
#define DOUBLECLICK_MOVE_THREASHOLD 3
Expand Down Expand Up @@ -852,4 +854,4 @@ - (void)mouseOptionsChanged:(NSNotification *)aNotif
wlconfig->mouse_scroll_multiplier = 1.0f;
}
}
@end
@end
1 change: 1 addition & 0 deletions Source/wayland/WaylandServer+Keyboard.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <linux/input.h>
#include <AppKit/NSText.h>
#include <sys/mman.h>
#include <unistd.h>

static void
keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard,
Expand Down
71 changes: 34 additions & 37 deletions Source/wayland/WaylandServer+Xdgshell.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
#include "wayland/WaylandServer.h"
#include <AppKit/NSEvent.h>
#include <AppKit/NSApplication.h>
#include <AppKit/NSGraphics.h>

static void
xdg_surface_on_configure(void *data, struct xdg_surface *xdg_surface,
uint32_t serial)
uint32_t serial)
{
struct window *window = data;

Expand All @@ -43,7 +44,6 @@
free(window);
return;
}
WaylandConfig *wlconfig = window->wlconfig;

NSEvent *ev = nil;
NSWindow *nswindow = GSWindowWithNumber(window->window_id);
Expand All @@ -57,38 +57,37 @@
if (window->buffer_needs_attach)
{
[window->instance flushwindowrect:NSMakeRect(window->pos_x, window->pos_y,
window->width, window->height
):window->window_id];
window->width, window->height)
:window->window_id];
}

if (wlconfig->pointer.focus
&& wlconfig->pointer.focus->window_id == window->window_id)
if (window->wlconfig->pointer.focus
&& window->wlconfig->pointer.focus->window_id == window->window_id)
{
ev = [NSEvent otherEventWithType:NSAppKitDefined
location:NSZeroPoint
modifierFlags:0
timestamp:0
windowNumber:(int) window->window_id
context:GSCurrentContext()
subtype:GSAppKitWindowFocusIn
data1:0
data2:0];
location:NSZeroPoint
modifierFlags:0
timestamp:0
windowNumber:(int) window->window_id
context:GSCurrentContext()
subtype:GSAppKitWindowFocusIn
data1:0
data2:0];

[nswindow sendEvent:ev];
}
}

static void
xdg_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel,
int32_t width, int32_t height, struct wl_array *states)
int32_t width, int32_t height, struct wl_array *states)
{
struct window *window = data;
WaylandConfig *wlconfig = window->wlconfig;

NSDebugLog(@"[%d] xdg_toplevel_configure %ldx%ld", window->window_id, width,
height);
NSDebugLog(@"[%d] xdg_toplevel_configure %dx%d", window->window_id, width,
height);

// the compositor can send 0.0x0.0
// The compositor can send 0x0
if (width == 0 || height == 0)
{
return;
Expand All @@ -99,53 +98,51 @@
window->height = height;

xdg_surface_set_window_geometry(window->xdg_surface, 0, 0, window->width,
window->height);
window->height);

NSEvent *ev = [NSEvent otherEventWithType:NSAppKitDefined
location:NSMakePoint(0.0, 0.0)
modifierFlags:0
timestamp:0
windowNumber:window->window_id
context:GSCurrentContext()
subtype:GSAppKitWindowResized
data1:window->width
data2:window->height];
location:NSMakePoint(0.0, 0.0)
modifierFlags:0
timestamp:0
windowNumber:window->window_id
context:GSCurrentContext()
subtype:GSAppKitWindowResized
data1:window->width
data2:window->height];
[(GSWindowWithNumber(window->window_id)) sendEvent:ev];
}
NSDebugLog(@"[%d] notify resize from backend=%ldx%ld", window->window_id,
width, height);
NSDebugLog(@"[%d] notify resize from backend=%dx%d", window->window_id,
width, height);
}

static void
xdg_toplevel_close_handler(void *data, struct zxdg_toplevel_v6 *xdg_toplevel)
xdg_toplevel_close_handler(void *data, struct xdg_toplevel *xdg_toplevel)
{
NSDebugLog(@"xdg_toplevel_close_handler");
}

static void
xdg_popup_configure(void *data, struct xdg_popup *xdg_popup, int32_t x,
int32_t y, int32_t width, int32_t height)
int32_t y, int32_t width, int32_t height)
{
struct window *window = data;
WaylandConfig *wlconfig = window->wlconfig;

NSDebugLog(@"[%d] xdg_popup_configure [%d,%d %dx%d]", window->window_id, x, y,
width, height);
width, height);
}

static void
xdg_popup_done(void *data, struct xdg_popup *xdg_popup)
{
struct window *window = data;
WaylandConfig *wlconfig = window->wlconfig;
window->terminated = YES;
xdg_popup_destroy(xdg_popup);
wl_surface_destroy(window->surface);
}

static void
wm_base_handle_ping(void *data, struct xdg_wm_base *xdg_wm_base,
uint32_t serial)
uint32_t serial)
{
NSDebugLog(@"wm_base_handle_ping");
xdg_wm_base_pong(xdg_wm_base, serial);
Expand All @@ -167,4 +164,4 @@
const struct xdg_toplevel_listener xdg_toplevel_listener = {
.configure = xdg_toplevel_configure,
.close = xdg_toplevel_close_handler,
};
};
4 changes: 2 additions & 2 deletions Source/wayland/WaylandServer.m
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ - (void)createSurfaceShell:(struct window *)window
break;
case NSPopUpMenuWindowLevel:
NSDebugLog(@"[%d] NSPopUpMenuWindowLevel", win);
[self createPopup:win];
[self createPopup:window];
break;
case NSScreenSaverWindowLevel:
NSDebugLog(@"[%d] NSScreenSaverWindowLevel", win);
Expand Down Expand Up @@ -1099,4 +1099,4 @@ - (void)destroyWindowShell:(struct window *)window
wl_display_flush(window->wlconfig->display);
}

@end
@end
Loading