Fixed minimizing fullscreen windows.
Removed misleading hide/unhide Cocoa notifications. We have no way of knowing when a Cocoa window is maximized and then restored (right?) Disabled spamy mouse motion events by default.
This commit is contained in:
parent
ade868c17f
commit
99de5726b1
4 changed files with 34 additions and 37 deletions
|
@ -1018,12 +1018,12 @@ SDL_GetWindowPixelFormat(SDL_Window * window)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
SDL_UpdateFullscreenMode(SDL_Window * window)
|
SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
|
||||||
{
|
{
|
||||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||||
SDL_Window *other;
|
SDL_Window *other;
|
||||||
|
|
||||||
if (FULLSCREEN_VISIBLE(window)) {
|
if (fullscreen) {
|
||||||
/* Hide any other fullscreen windows */
|
/* Hide any other fullscreen windows */
|
||||||
if (display->fullscreen_window &&
|
if (display->fullscreen_window &&
|
||||||
display->fullscreen_window != window) {
|
display->fullscreen_window != window) {
|
||||||
|
@ -1032,15 +1032,24 @@ SDL_UpdateFullscreenMode(SDL_Window * window)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See if anything needs to be done now */
|
/* See if anything needs to be done now */
|
||||||
if ((display->fullscreen_window == window) == FULLSCREEN_VISIBLE(window)) {
|
if ((display->fullscreen_window == window) == fullscreen) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See if there are any fullscreen windows */
|
/* See if there are any fullscreen windows */
|
||||||
for (other = _this->windows; other; other = other->next) {
|
for (other = _this->windows; other; other = other->next) {
|
||||||
if (FULLSCREEN_VISIBLE(other) &&
|
SDL_bool setDisplayMode = SDL_FALSE;
|
||||||
SDL_GetDisplayForWindow(other) == display) {
|
|
||||||
|
if (other == window) {
|
||||||
|
setDisplayMode = fullscreen;
|
||||||
|
} else if (FULLSCREEN_VISIBLE(other) &&
|
||||||
|
SDL_GetDisplayForWindow(other) == display) {
|
||||||
|
setDisplayMode = SDL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setDisplayMode) {
|
||||||
SDL_DisplayMode fullscreen_mode;
|
SDL_DisplayMode fullscreen_mode;
|
||||||
|
|
||||||
if (SDL_GetWindowDisplayMode(other, &fullscreen_mode) == 0) {
|
if (SDL_GetWindowDisplayMode(other, &fullscreen_mode) == 0) {
|
||||||
SDL_bool resized = SDL_TRUE;
|
SDL_bool resized = SDL_TRUE;
|
||||||
|
|
||||||
|
@ -1144,7 +1153,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
||||||
|
|
||||||
displayIndex = SDL_GetIndexOfDisplay(display);
|
displayIndex = SDL_GetIndexOfDisplay(display);
|
||||||
SDL_GetDisplayBounds(displayIndex, &bounds);
|
SDL_GetDisplayBounds(displayIndex, &bounds);
|
||||||
if (SDL_WINDOWPOS_ISUNDEFINED(x) || SDL_WINDOWPOS_ISCENTERED(y)) {
|
if (SDL_WINDOWPOS_ISUNDEFINED(x) || SDL_WINDOWPOS_ISCENTERED(x)) {
|
||||||
window->x = bounds.x + (bounds.w - w) / 2;
|
window->x = bounds.x + (bounds.w - w) / 2;
|
||||||
}
|
}
|
||||||
if (SDL_WINDOWPOS_ISUNDEFINED(y) || SDL_WINDOWPOS_ISCENTERED(y)) {
|
if (SDL_WINDOWPOS_ISUNDEFINED(y) || SDL_WINDOWPOS_ISCENTERED(y)) {
|
||||||
|
@ -1512,6 +1521,8 @@ SDL_HideWindow(SDL_Window * window)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_UpdateFullscreenMode(window, SDL_FALSE);
|
||||||
|
|
||||||
if (_this->HideWindow) {
|
if (_this->HideWindow) {
|
||||||
_this->HideWindow(_this, window);
|
_this->HideWindow(_this, window);
|
||||||
}
|
}
|
||||||
|
@ -1528,9 +1539,6 @@ SDL_RaiseWindow(SDL_Window * window)
|
||||||
}
|
}
|
||||||
if (_this->RaiseWindow) {
|
if (_this->RaiseWindow) {
|
||||||
_this->RaiseWindow(_this, window);
|
_this->RaiseWindow(_this, window);
|
||||||
} else {
|
|
||||||
/* FIXME: What we really want is a way to request focus */
|
|
||||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1557,6 +1565,8 @@ SDL_MinimizeWindow(SDL_Window * window)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_UpdateFullscreenMode(window, SDL_FALSE);
|
||||||
|
|
||||||
if (_this->MinimizeWindow) {
|
if (_this->MinimizeWindow) {
|
||||||
_this->MinimizeWindow(_this, window);
|
_this->MinimizeWindow(_this, window);
|
||||||
}
|
}
|
||||||
|
@ -1574,7 +1584,6 @@ SDL_RestoreWindow(SDL_Window * window)
|
||||||
if (_this->RestoreWindow) {
|
if (_this->RestoreWindow) {
|
||||||
_this->RestoreWindow(_this, window);
|
_this->RestoreWindow(_this, window);
|
||||||
}
|
}
|
||||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -1582,10 +1591,7 @@ SDL_SetWindowFullscreen(SDL_Window * window, SDL_bool fullscreen)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, -1);
|
CHECK_WINDOW_MAGIC(window, -1);
|
||||||
|
|
||||||
if (fullscreen) {
|
if (!!fullscreen == !!(window->flags & SDL_WINDOW_FULLSCREEN)) {
|
||||||
fullscreen = SDL_WINDOW_FULLSCREEN;
|
|
||||||
}
|
|
||||||
if ((window->flags & SDL_WINDOW_FULLSCREEN) == fullscreen) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (fullscreen) {
|
if (fullscreen) {
|
||||||
|
@ -1593,7 +1599,7 @@ SDL_SetWindowFullscreen(SDL_Window * window, SDL_bool fullscreen)
|
||||||
} else {
|
} else {
|
||||||
window->flags &= ~SDL_WINDOW_FULLSCREEN;
|
window->flags &= ~SDL_WINDOW_FULLSCREEN;
|
||||||
}
|
}
|
||||||
SDL_UpdateFullscreenMode(window);
|
SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1682,7 +1688,7 @@ SDL_SetWindowGrab(SDL_Window * window, SDL_bool grabbed)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window, );
|
||||||
|
|
||||||
if ((!!grabbed == !!(window->flags & SDL_WINDOW_INPUT_GRABBED))) {
|
if (!!grabbed == !!(window->flags & SDL_WINDOW_INPUT_GRABBED)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (grabbed) {
|
if (grabbed) {
|
||||||
|
@ -1704,14 +1710,13 @@ SDL_GetWindowGrab(SDL_Window * window)
|
||||||
void
|
void
|
||||||
SDL_OnWindowShown(SDL_Window * window)
|
SDL_OnWindowShown(SDL_Window * window)
|
||||||
{
|
{
|
||||||
SDL_RaiseWindow(window);
|
SDL_OnWindowRestored(window);
|
||||||
SDL_UpdateFullscreenMode(window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SDL_OnWindowHidden(SDL_Window * window)
|
SDL_OnWindowHidden(SDL_Window * window)
|
||||||
{
|
{
|
||||||
SDL_UpdateFullscreenMode(window);
|
SDL_UpdateFullscreenMode(window, SDL_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1724,14 +1729,17 @@ SDL_OnWindowResized(SDL_Window * window)
|
||||||
void
|
void
|
||||||
SDL_OnWindowMinimized(SDL_Window * window)
|
SDL_OnWindowMinimized(SDL_Window * window)
|
||||||
{
|
{
|
||||||
SDL_UpdateFullscreenMode(window);
|
SDL_UpdateFullscreenMode(window, SDL_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SDL_OnWindowRestored(SDL_Window * window)
|
SDL_OnWindowRestored(SDL_Window * window)
|
||||||
{
|
{
|
||||||
SDL_RaiseWindow(window);
|
SDL_RaiseWindow(window);
|
||||||
SDL_UpdateFullscreenMode(window);
|
|
||||||
|
if (FULLSCREEN_VISIBLE(window)) {
|
||||||
|
SDL_UpdateFullscreenMode(window, SDL_TRUE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -49,8 +49,6 @@ typedef struct SDL_WindowData SDL_WindowData;
|
||||||
-(void) windowDidDeminiaturize:(NSNotification *) aNotification;
|
-(void) windowDidDeminiaturize:(NSNotification *) aNotification;
|
||||||
-(void) windowDidBecomeKey:(NSNotification *) aNotification;
|
-(void) windowDidBecomeKey:(NSNotification *) aNotification;
|
||||||
-(void) windowDidResignKey:(NSNotification *) aNotification;
|
-(void) windowDidResignKey:(NSNotification *) aNotification;
|
||||||
-(void) windowDidHide:(NSNotification *) aNotification;
|
|
||||||
-(void) windowDidUnhide:(NSNotification *) aNotification;
|
|
||||||
|
|
||||||
/* Window event handling */
|
/* Window event handling */
|
||||||
-(void) mouseDown:(NSEvent *) theEvent;
|
-(void) mouseDown:(NSEvent *) theEvent;
|
||||||
|
|
|
@ -63,8 +63,6 @@ static __inline__ void ConvertNSRect(NSRect *r)
|
||||||
} else {
|
} else {
|
||||||
[window setDelegate:self];
|
[window setDelegate:self];
|
||||||
}
|
}
|
||||||
[center addObserver:self selector:@selector(windowDidHide:) name:NSApplicationDidHideNotification object:NSApp];
|
|
||||||
[center addObserver:self selector:@selector(windowDidUnhide:) name:NSApplicationDidUnhideNotification object:NSApp];
|
|
||||||
|
|
||||||
[window setNextResponder:self];
|
[window setNextResponder:self];
|
||||||
[window setAcceptsMouseMovedEvents:YES];
|
[window setAcceptsMouseMovedEvents:YES];
|
||||||
|
@ -94,8 +92,6 @@ static __inline__ void ConvertNSRect(NSRect *r)
|
||||||
} else {
|
} else {
|
||||||
[window setDelegate:nil];
|
[window setDelegate:nil];
|
||||||
}
|
}
|
||||||
[center removeObserver:self name:NSApplicationDidHideNotification object:NSApp];
|
|
||||||
[center removeObserver:self name:NSApplicationDidUnhideNotification object:NSApp];
|
|
||||||
|
|
||||||
if ([window nextResponder] == self) {
|
if ([window nextResponder] == self) {
|
||||||
[window setNextResponder:nil];
|
[window setNextResponder:nil];
|
||||||
|
@ -206,16 +202,6 @@ static __inline__ void ConvertNSRect(NSRect *r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidHide:(NSNotification *)aNotification
|
|
||||||
{
|
|
||||||
SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_HIDDEN, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)windowDidUnhide:(NSNotification *)aNotification
|
|
||||||
{
|
|
||||||
SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)mouseDown:(NSEvent *)theEvent
|
- (void)mouseDown:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
int button;
|
int button;
|
||||||
|
|
|
@ -810,6 +810,11 @@ CommonInit(CommonState * state)
|
||||||
static void
|
static void
|
||||||
PrintEvent(SDL_Event * event)
|
PrintEvent(SDL_Event * event)
|
||||||
{
|
{
|
||||||
|
if (event->type == SDL_MOUSEMOTION) {
|
||||||
|
/* Mouse motion is really spammy */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(stderr, "SDL EVENT: ");
|
fprintf(stderr, "SDL EVENT: ");
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue