Skip to content
Merged
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
1 change: 1 addition & 0 deletions src/video/cocoa/SDL_cocoavideo.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
device->GetWindowWMInfo = Cocoa_GetWindowWMInfo;
device->SetWindowHitTest = Cocoa_SetWindowHitTest;
device->AcceptDragAndDrop = Cocoa_AcceptDragAndDrop;
device->FlashWindow = Cocoa_FlashWindow;

device->shape_driver.CreateShaper = Cocoa_CreateShaper;
device->shape_driver.SetWindowShape = Cocoa_SetWindowShape;
Expand Down
1 change: 1 addition & 0 deletions src/video/cocoa/SDL_cocoawindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ extern void Cocoa_DestroyWindow(_THIS, SDL_Window * window);
extern SDL_bool Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info);
extern int Cocoa_SetWindowHitTest(SDL_Window *window, SDL_bool enabled);
extern void Cocoa_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept);
extern int Cocoa_FlashWindow(_THIS, SDL_Window * window, Uint32 flash_count);

#endif /* SDL_cocoawindow_h_ */

Expand Down
9 changes: 9 additions & 0 deletions src/video/cocoa/SDL_cocoawindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -2116,6 +2116,15 @@ take effect properly (e.g. setting the window size, etc.)
}
}

int
Cocoa_FlashWindow(_THIS, SDL_Window *window, Uint32 flash_count)
{ @autoreleasepool
{
/* Note that this is app-wide and not window-specific! */
[NSApp requestUserAttention:NSInformationalRequest];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There isn't a way to specify the exact number of 'flashes' (icon bounces) in macOS as far as I know but NSCriticalRequest can be used to make the icon bounce continuously instead of just once. This comment is probably out of the scope of this specific PR but maybe it makes sense to change SDL_FlashWindow's external API to more closely follow a common denominator across operating systems? For example in my own stuff I've implemented similar functionality with a continuous bool parameter, which I've implemented in both macOS and Windows.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A continuous bool makes sense to me - I'm surprised any OS has it down to a specific number of flashes in the first place. X11 and Wayland are indifferent either way so I'm up for whatever here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose an enum (FLASH_ONCE, FLASH_CONTINUOUS) is nicer than a bool – but in any case I feel a bit bad for cluttering this self-contained PR. :)

return 0;
}}

int
Cocoa_SetWindowOpacity(_THIS, SDL_Window * window, float opacity)
{
Expand Down