Skip to content

Commit d60272e

Browse files
committed
Added SDL_SetWindowMousePassthrough
1 parent 29213ef commit d60272e

18 files changed

+98
-0
lines changed

include/SDL3/SDL_video.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,6 +2703,18 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowOpacity(SDL_Window *window, float
27032703
*/
27042704
extern SDL_DECLSPEC float SDLCALL SDL_GetWindowOpacity(SDL_Window *window);
27052705

2706+
/**
2707+
* Enable or disable mouse passthrough for a window.
2708+
*
2709+
* \param window the window to set mouse passthrough for.
2710+
* \param passthrough true to make the window transparent to mouse input, false to capture mouse input.
2711+
*
2712+
* \threadsafety This function should only be called on the main thread.
2713+
*
2714+
* \since This function is available since SDL 3.6.0.
2715+
*/
2716+
extern SDL_DECLSPEC void SDLCALL SDL_SetWindowMousePassthrough(SDL_Window *window, bool passthrough);
2717+
27062718
/**
27072719
* Set the window as a child of a parent window.
27082720
*

src/dynapi/SDL_dynapi.sym

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,7 @@ SDL3_0.0.0 {
12701270
SDL_RotateSurface;
12711271
SDL_LoadSurface_IO;
12721272
SDL_LoadSurface;
1273+
SDL_SetWindowMousePassthrough;
12731274
# extra symbols go here (don't modify this line)
12741275
local: *;
12751276
};

src/dynapi/SDL_dynapi_overrides.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,3 +1296,4 @@
12961296
#define SDL_RotateSurface SDL_RotateSurface_REAL
12971297
#define SDL_LoadSurface_IO SDL_LoadSurface_IO_REAL
12981298
#define SDL_LoadSurface SDL_LoadSurface_REAL
1299+
#define SDL_SetWindowMousePassthrough SDL_SetWindowMousePassthrough_REAL

src/dynapi/SDL_dynapi_procs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,3 +1304,4 @@ SDL_DYNAPI_PROC(SDL_Cursor*,SDL_CreateAnimatedCursor,(SDL_CursorFrameInfo *a,int
13041304
SDL_DYNAPI_PROC(SDL_Surface*,SDL_RotateSurface,(SDL_Surface *a,float b),(a,b),return)
13051305
SDL_DYNAPI_PROC(SDL_Surface*,SDL_LoadSurface_IO,(SDL_IOStream *a,bool b),(a,b),return)
13061306
SDL_DYNAPI_PROC(SDL_Surface*,SDL_LoadSurface,(const char *a),(a),return)
1307+
SDL_DYNAPI_PROC(void,SDL_SetWindowMousePassthrough,(SDL_Window *a,bool b),(a,b),)

src/video/SDL_sysvideo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ struct SDL_VideoDevice
284284
float (*GetWindowContentScale)(SDL_VideoDevice *_this, SDL_Window *window);
285285
void (*GetWindowSizeInPixels)(SDL_VideoDevice *_this, SDL_Window *window, int *w, int *h);
286286
bool (*SetWindowOpacity)(SDL_VideoDevice *_this, SDL_Window *window, float opacity);
287+
void (*SetWindowMousePassthrough)(SDL_VideoDevice *_this, SDL_Window *window, bool passthrough);
287288
bool (*SetWindowParent)(SDL_VideoDevice *_this, SDL_Window *window, SDL_Window *parent);
288289
bool (*SetWindowModal)(SDL_VideoDevice *_this, SDL_Window *window, bool modal);
289290
void (*ShowWindow)(SDL_VideoDevice *_this, SDL_Window *window);

src/video/SDL_video.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3793,6 +3793,16 @@ float SDL_GetWindowOpacity(SDL_Window *window)
37933793
return window->opacity;
37943794
}
37953795

3796+
void SDL_SetWindowMousePassthrough(SDL_Window *window, bool passthrough)
3797+
{
3798+
if (!_this->SetWindowMousePassthrough) {
3799+
SDL_Unsupported();
3800+
return;
3801+
}
3802+
3803+
_this->SetWindowMousePassthrough(_this, window, passthrough);
3804+
}
3805+
37963806
bool SDL_SetWindowParent(SDL_Window *window, SDL_Window *parent)
37973807
{
37983808
CHECK_WINDOW_MAGIC(window, false);

src/video/cocoa/SDL_cocoavideo.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ static void Cocoa_DeleteDevice(SDL_VideoDevice *device)
101101
device->SetWindowMaximumSize = Cocoa_SetWindowMaximumSize;
102102
device->SetWindowAspectRatio = Cocoa_SetWindowAspectRatio;
103103
device->SetWindowOpacity = Cocoa_SetWindowOpacity;
104+
device->SetWindowMousePassthrough = Cocoa_SetWindowMousePassthrough;
104105
device->GetWindowSizeInPixels = Cocoa_GetWindowSizeInPixels;
105106
device->ShowWindow = Cocoa_ShowWindow;
106107
device->HideWindow = Cocoa_HideWindow;

src/video/cocoa/SDL_cocoawindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ extern void Cocoa_SetWindowMaximumSize(SDL_VideoDevice *_this, SDL_Window *windo
173173
extern void Cocoa_SetWindowAspectRatio(SDL_VideoDevice *_this, SDL_Window *window);
174174
extern void Cocoa_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int *w, int *h);
175175
extern bool Cocoa_SetWindowOpacity(SDL_VideoDevice *_this, SDL_Window *window, float opacity);
176+
extern void Cocoa_SetWindowMousePassthrough(SDL_VideoDevice *_this, SDL_Window *window, bool passthrough);
176177
extern void Cocoa_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window);
177178
extern void Cocoa_HideWindow(SDL_VideoDevice *_this, SDL_Window *window);
178179
extern void Cocoa_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window);

src/video/cocoa/SDL_cocoawindow.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3416,6 +3416,13 @@ bool Cocoa_SetWindowOpacity(SDL_VideoDevice *_this, SDL_Window *window, float op
34163416
}
34173417
}
34183418

3419+
void Cocoa_SetWindowMousePassthrough(SDL_VideoDevice *_this, SDL_Window *window, bool passthrough) {
3420+
@autoreleasepool {
3421+
SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal;
3422+
[data.nswindow setIgnoresMouseEvents:passthrough];
3423+
}
3424+
}
3425+
34193426
bool Cocoa_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window)
34203427
{
34213428
bool result = false;

src/video/wayland/SDL_waylandvideo.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,7 @@ static SDL_VideoDevice *Wayland_CreateDevice(bool require_preferred_protocols)
656656
device->SetWindowParent = Wayland_SetWindowParent;
657657
device->SetWindowModal = Wayland_SetWindowModal;
658658
device->SetWindowOpacity = Wayland_SetWindowOpacity;
659+
device->SetWindowMousePassthrough = Wayland_SetWindowMousePassthrough;
659660
device->SetWindowTitle = Wayland_SetWindowTitle;
660661
device->SetWindowIcon = Wayland_SetWindowIcon;
661662
device->GetWindowSizeInPixels = Wayland_GetWindowSizeInPixels;

0 commit comments

Comments
 (0)