From 7d4f8af2456fd3d357f7bb064cf5a7cd387c3ef1 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Wed, 1 Nov 2017 04:13:10 -0400 Subject: [PATCH 1/5] - fixed compile on Linux and (maybe?) Mac --- src/posix/cocoa/i_video.mm | 16 +++++++++++----- src/posix/sdl/sdlvideo.cpp | 5 +++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index c89a6601d..2c305b49e 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -1523,10 +1523,16 @@ void I_SetMainWindowVisible(bool visible) // each platform has its own specific version of this function. void I_SetWindowTitle(const char* title) { - static NSString* const TITLE_STRING; if (title) - TITLE_STRING = [NSString stringWithFormat:@"%s", title]; + { + static NSString* const TITLE_STRING = + [NSString stringWithFormat:@"%s", title]; + [m_window setTitle:TITLE_STRING]; + } else - TITLE_STRING = [NSString stringWithFormat:@"%s %s", GAMESIG, GetVersionString()]; - [m_window setTitle:TITLE_STRING]; -} \ No newline at end of file + { + static NSString* const TITLE_STRING = + [NSString stringWithFormat:@"%s %s", GAMESIG, GetVersionString()]; + [m_window setTitle:TITLE_STRING]; + } +} diff --git a/src/posix/sdl/sdlvideo.cpp b/src/posix/sdl/sdlvideo.cpp index 318a91e6e..6a0420ae8 100644 --- a/src/posix/sdl/sdlvideo.cpp +++ b/src/posix/sdl/sdlvideo.cpp @@ -556,11 +556,12 @@ ADD_STAT (blit) void I_SetWindowTitle(const char* caption) { if (caption) - SDL_SetWindowTitle(Screen, caption); + SDL_SetWindowTitle(static_cast(screen)->GetSDLWindow(), caption); else { FString default_caption; default_caption.Format(GAMESIG " %s (%s)", GetVersionString(), GetGitTime()); - SDL_SetWindowTitle(Screen, default_caption); + SDL_SetWindowTitle(static_cast(screen)->GetSDLWindow(), default_caption); } } + From c3c637a0cc724d13985bcb4d4f82f9bd2a3f3332 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 18 Nov 2017 00:53:16 -0500 Subject: [PATCH 2/5] - set i_friendlywindowtitle to true by default --- src/d_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 130091d16..4ea71b3cd 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2902,7 +2902,7 @@ DEFINE_FIELD_X(InputEventData, event_t, x) DEFINE_FIELD_X(InputEventData, event_t, y) -CUSTOM_CVAR(Bool, I_FriendlyWindowTitle, false, CVAR_GLOBALCONFIG|CVAR_ARCHIVE|CVAR_NOINITCALL) +CUSTOM_CVAR(Bool, I_FriendlyWindowTitle, true, CVAR_GLOBALCONFIG|CVAR_ARCHIVE|CVAR_NOINITCALL) { if (self) I_SetWindowTitle(DoomStartupInfo.Name.GetChars()); From 35bb9ba9d36e8dd474ea1c133fc055bb132d8c8c Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 18 Nov 2017 13:24:17 +0200 Subject: [PATCH 3/5] Implemented setting of window title in Cocoa backend # Conflicts: # src/posix/cocoa/i_video.mm --- src/posix/cocoa/i_video.mm | 48 ++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 2c305b49e..a1bc96403 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -197,9 +197,12 @@ namespace @interface CocoaWindow : NSWindow { + NSString* m_title; } - (BOOL)canBecomeKeyWindow; +- (void)setTitle:(NSString*)title; +- (void)updateTitle; @end @@ -211,6 +214,23 @@ namespace return true; } +- (void)setTitle:(NSString*)title +{ + m_title = title; + + [self updateTitle]; +} + +- (void)updateTitle +{ + if (nil == m_title) + { + m_title = [NSString stringWithFormat:@"%s %s", GAMESIG, GetVersionString()]; + } + + [super setTitle:m_title]; +} + @end @@ -271,6 +291,7 @@ public: static void UseHiDPI(bool hiDPI); static void SetCursor(NSCursor* cursor); static void SetWindowVisible(bool visible); + static void SetWindowTitle(const char* title); private: struct ModeIterator @@ -717,6 +738,16 @@ void CocoaVideo::SetWindowVisible(bool visible) } } +void CocoaVideo::SetWindowTitle(const char* title) +{ + if (CocoaVideo* const video = GetInstance()) + { + NSString* const nsTitle = nullptr == title ? nil : + [NSString stringWithCString:title encoding:NSISOLatin1StringEncoding]; + [video->m_window setTitle:nsTitle]; + } +} + void CocoaVideo::SetFullscreenMode(const int width, const int height) { @@ -813,9 +844,7 @@ void CocoaVideo::SetMode(const int width, const int height, const bool fullscree [[NSOpenGLContext currentContext] flushBuffer]; - static NSString* const TITLE_STRING = - [NSString stringWithFormat:@"%s %s", GAMESIG, GetVersionString()]; - [m_window setTitle:TITLE_STRING]; + [m_window updateTitle]; if (![m_window isKeyWindow]) { @@ -1523,16 +1552,5 @@ void I_SetMainWindowVisible(bool visible) // each platform has its own specific version of this function. void I_SetWindowTitle(const char* title) { - if (title) - { - static NSString* const TITLE_STRING = - [NSString stringWithFormat:@"%s", title]; - [m_window setTitle:TITLE_STRING]; - } - else - { - static NSString* const TITLE_STRING = - [NSString stringWithFormat:@"%s %s", GAMESIG, GetVersionString()]; - [m_window setTitle:TITLE_STRING]; - } + CocoaVideo::SetWindowTitle(title); } From 28d47d463f95742e73daece1aea3c566871ece88 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Sat, 18 Nov 2017 08:11:27 -0500 Subject: [PATCH 4/5] - fix linux compile # Conflicts: # src/posix/sdl/sdlvideo.cpp --- src/posix/sdl/sdlvideo.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/posix/sdl/sdlvideo.cpp b/src/posix/sdl/sdlvideo.cpp index 6a0420ae8..8cae68739 100644 --- a/src/posix/sdl/sdlvideo.cpp +++ b/src/posix/sdl/sdlvideo.cpp @@ -555,6 +555,7 @@ ADD_STAT (blit) // each platform has its own specific version of this function. void I_SetWindowTitle(const char* caption) { + auto Screen = static_cast(screen)->GetSDLWindow(); if (caption) SDL_SetWindowTitle(static_cast(screen)->GetSDLWindow(), caption); else From c80c2ba635d0cc560f3f468cfb93b4ba11e3b559 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Fri, 24 Nov 2017 14:38:55 -0500 Subject: [PATCH 5/5] - added 100% CPU fix provided by Leonard2: https://forum.zdoom.org/viewtopic.php?p=1028500#p1028500 --- src/i_time.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i_time.cpp b/src/i_time.cpp index 2aada4861..516ecfad1 100644 --- a/src/i_time.cpp +++ b/src/i_time.cpp @@ -132,7 +132,7 @@ int I_WaitForTic(int prevtic) { // The minimum amount of time a thread can sleep is controlled by timeBeginPeriod. // We set this to 1 ms in DoMain. - int sleepTime = prevtic - time; + uint64_t sleepTime = NSToMS(FirstFrameStartTime + TicToNS(prevtic + 1) - I_nsTime()); if (sleepTime > 2) std::this_thread::sleep_for(std::chrono::milliseconds(sleepTime - 2)); @@ -154,7 +154,7 @@ uint64_t I_msTime() int I_GetTime() { - return NSToTic(CurrentFrameStartTime - FirstFrameStartTime) + 1; + return NSToTic(CurrentFrameStartTime - FirstFrameStartTime); } double I_GetTimeFrac()