Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--intern/ghost/GHOST_Types.h5
-rw-r--r--intern/ghost/intern/GHOST_EventPrinter.cpp4
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.h2
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm47
-rw-r--r--intern/ghost/intern/GHOST_SystemSDL.cpp7
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c2
-rw-r--r--source/blender/windowmanager/intern/wm_window.c21
7 files changed, 37 insertions, 51 deletions
diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h
index faba5bb996a..f38154cbf94 100644
--- a/intern/ghost/GHOST_Types.h
+++ b/intern/ghost/GHOST_Types.h
@@ -125,9 +125,6 @@ typedef enum {
// GHOST_kWindowStateUnModified,
} GHOST_TWindowState;
-/** Constants for the answer to the blender exit request */
-typedef enum { GHOST_kExitCancel = 0, GHOST_kExitNow } GHOST_TExitRequestResponse;
-
typedef enum { GHOST_kWindowOrderTop = 0, GHOST_kWindowOrderBottom } GHOST_TWindowOrder;
typedef enum {
@@ -165,7 +162,7 @@ typedef enum {
GHOST_kEventKeyUp,
// GHOST_kEventKeyAuto,
- GHOST_kEventQuit,
+ GHOST_kEventQuitRequest,
GHOST_kEventWindowClose,
GHOST_kEventWindowActivate,
diff --git a/intern/ghost/intern/GHOST_EventPrinter.cpp b/intern/ghost/intern/GHOST_EventPrinter.cpp
index 3c5f613e11f..ba9ed6e3037 100644
--- a/intern/ghost/intern/GHOST_EventPrinter.cpp
+++ b/intern/ghost/intern/GHOST_EventPrinter.cpp
@@ -139,8 +139,8 @@ bool GHOST_EventPrinter::processEvent(GHOST_IEvent *event)
std::cout << "GHOST_kEventOpenMainFile with no path specified!!";
} break;
- case GHOST_kEventQuit:
- std::cout << "GHOST_kEventQuit";
+ case GHOST_kEventQuitRequest:
+ std::cout << "GHOST_kEventQuitRequest";
break;
case GHOST_kEventWindowClose:
std::cout << "GHOST_kEventWindowClose";
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h
index 749139fee76..1201b5c4a14 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.h
+++ b/intern/ghost/intern/GHOST_SystemCocoa.h
@@ -140,7 +140,7 @@ class GHOST_SystemCocoa : public GHOST_System {
* Handle User request to quit, from Menu bar Quit, and Cmd+Q
* Display alert panel if changes performed since last save
*/
- GHOST_TUns8 handleQuitRequest();
+ void handleQuitRequest();
/**
* Handle Cocoa openFile event
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 1fd0914eb73..9afc882955c 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -427,10 +427,8 @@ extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG])
/* TODO: implement graceful termination through Cocoa mechanism
* to avoid session log off to be canceled. */
/* Note that Cmd+Q is already handled by keyhandler. */
- if (systemCocoa->handleQuitRequest() == GHOST_kExitNow)
- return NSTerminateCancel; //NSTerminateNow;
- else
- return NSTerminateCancel;
+ systemCocoa->handleQuitRequest();
+ return NSTerminateCancel;
}
// To avoid canceling a log off process, we must use Cocoa termination process
@@ -1342,46 +1340,17 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
return GHOST_kSuccess;
}
-GHOST_TUns8 GHOST_SystemCocoa::handleQuitRequest()
+void GHOST_SystemCocoa::handleQuitRequest()
{
GHOST_Window *window = (GHOST_Window *)m_windowManager->getActiveWindow();
// Discard quit event if we are in cursor grab sequence
if (window && window->getCursorGrabModeIsWarp())
- return GHOST_kExitCancel;
-
- // Check open windows if some changes are not saved
- if (m_windowManager->getAnyModifiedState()) {
- int shouldQuit = NSRunAlertPanel(
- @"Exit Blender",
- @"Some changes have not been saved.\nDo you really want to quit?",
- @"Cancel",
- @"Quit Anyway",
- nil);
- if (shouldQuit == NSAlertAlternateReturn) {
- pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventQuit, NULL));
- return GHOST_kExitNow;
- }
- else {
- // Give back focus to the blender window if user selected cancel quit
- NSArray *windowsList = [NSApp orderedWindows];
- if ([windowsList count]) {
- [[windowsList objectAtIndex:0] makeKeyAndOrderFront:nil];
- // Handle the modifiers keyes changed state issue
- // as recovering from the quit dialog is like application
- // gaining focus back.
- // Main issue fixed is Cmd modifier not being cleared
- handleApplicationBecomeActiveEvent();
- }
- }
- }
- else {
- pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventQuit, NULL));
- m_outsideLoopEventProcessed = true;
- return GHOST_kExitNow;
- }
+ return;
- return GHOST_kExitCancel;
+ // Push the event to Blender so it can open a dialog if needed
+ pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventQuitRequest, window));
+ m_outsideLoopEventProcessed = true;
}
bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr)
@@ -1400,7 +1369,7 @@ bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr)
/* Discard event if we are in cursor grab sequence,
* it'll lead to "stuck cursor" situation if the alert panel is raised */
if (window && window->getCursorGrabModeIsWarp())
- return GHOST_kExitCancel;
+ return NO;
// Check open windows if some changes are not saved
if (m_windowManager->getAnyModifiedState()) {
diff --git a/intern/ghost/intern/GHOST_SystemSDL.cpp b/intern/ghost/intern/GHOST_SystemSDL.cpp
index 7b0407c6c4c..18163882cec 100644
--- a/intern/ghost/intern/GHOST_SystemSDL.cpp
+++ b/intern/ghost/intern/GHOST_SystemSDL.cpp
@@ -338,9 +338,12 @@ void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
break;
}
- case SDL_QUIT:
- g_event = new GHOST_Event(getMilliSeconds(), GHOST_kEventQuit, NULL);
+
+ case SDL_QUIT: {
+ GHOST_IWindow *window = m_windowManager->getActiveWindow();
+ g_event = new GHOST_Event(getMilliSeconds(), GHOST_kEventQuitRequest, window);
break;
+ }
case SDL_MOUSEMOTION: {
SDL_MouseMotionEvent &sdl_sub_evt = sdl_event->motion;
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index 844316bc925..7cc44bcad99 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -1063,7 +1063,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
break;
}
- case GHOST_kEventQuit:
+ case GHOST_kEventQuitRequest:
case GHOST_kEventWindowClose: {
ps->go = false;
break;
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index c7168673f26..1ac23754972 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -1117,8 +1117,25 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
GHOST_TEventType type = GHOST_GetEventType(evt);
int time = GHOST_GetEventTime(evt);
- if (type == GHOST_kEventQuit) {
- WM_exit(C);
+ if (type == GHOST_kEventQuitRequest) {
+ /* Find an active window to display quit dialog in. */
+ GHOST_WindowHandle ghostwin = GHOST_GetEventWindow(evt);
+ wmWindow *win;
+
+ if (ghostwin && GHOST_ValidWindow(g_system, ghostwin)) {
+ win = GHOST_GetWindowUserData(ghostwin);
+ }
+ else {
+ win = wm->winactive;
+ }
+
+ /* Display quit dialog or quit immediately. */
+ if (win) {
+ wm_quit_with_optional_confirmation_prompt(C, win);
+ }
+ else {
+ wm_exit_schedule_delayed(C);
+ }
}
else {
GHOST_WindowHandle ghostwin = GHOST_GetEventWindow(evt);