Mercurial > octave
changeset 22165:20e684ec108e
move system dependent code to sysdep.cc
* octave-gui.cc (set_win_app_id): Move to sysdep.cc and rename to
set_application_id.
* sysdep.h: Provide decl.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 22 Jul 2016 15:26:58 -0400 |
parents | 5d4a286061c8 |
children | 44244c9c177f |
files | libgui/src/octave-gui.cc libinterp/corefcn/sysdep.cc libinterp/corefcn/sysdep.h |
diffstat | 3 files changed, 33 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/octave-gui.cc Thu Jun 30 18:17:26 2016 +1000 +++ b/libgui/src/octave-gui.cc Fri Jul 22 15:26:58 2016 -0400 @@ -47,6 +47,7 @@ # include "__init_qt__.h" #endif #include "octave.h" +#include "sysdep.h" #include "unistd-wrappers.h" #include "main-window.h" @@ -63,30 +64,6 @@ { } -#if defined (OCTAVE_USE_WINDOWS_API) -#include <windows.h> -// set app id if we have the SetCurrentProcessExplicitAppUserModelID -// available (>= Win7) -static void -set_win_app_id () -{ - typedef HRESULT (WINAPI *SETCURRENTAPPID)(PCWSTR AppID); - HMODULE hShell = LoadLibrary ("shell32.dll"); - if (hShell != NULL) - { - SETCURRENTAPPID pfnSetCurrentProcessExplicitAppUserModelID = - reinterpret_cast<SETCURRENTAPPID> (GetProcAddress (hShell, - "SetCurrentProcessExplicitAppUserModelID")); - - if (pfnSetCurrentProcessExplicitAppUserModelID) - { - pfnSetCurrentProcessExplicitAppUserModelID (L"gnu.octave"); - } - FreeLibrary (hShell); - } -} -#endif - namespace octave { bool gui_application::start_gui_p (void) const @@ -144,9 +121,7 @@ { octave_thread_manager::block_interrupt_signal (); -#if defined (OCTAVE_USE_WINDOWS_API) - set_win_app_id (); -#endif + set_application_id (); std::string show_gui_msgs = octave::sys::env::getenv ("OCTAVE_SHOW_GUI_MESSAGES");
--- a/libinterp/corefcn/sysdep.cc Thu Jun 30 18:17:26 2016 +1000 +++ b/libinterp/corefcn/sysdep.cc Fri Jul 22 15:26:58 2016 -0400 @@ -173,8 +173,37 @@ w32_shell_execute (const std::string& file) { } + #endif +// Set app id if we have the SetCurrentProcessExplicitAppUserModelID +// available (>= Win7). FIXME: Could we check for existence of this +// function in the configure script instead of dynamically loading +// shell32.dll? + +void +set_application_id (void) +{ +#if defined (__MINGW32__) || defined (_MSC_VER) + + typedef HRESULT (WINAPI *SETCURRENTAPPID)(PCWSTR AppID); + + HMODULE hShell = LoadLibrary ("shell32.dll"); + + if (hShell != NULL) + { + SETCURRENTAPPID pfnSetCurrentProcessExplicitAppUserModelID = + reinterpret_cast<SETCURRENTAPPID> (GetProcAddress (hShell, "SetCurrentProcessExplicitAppUserModelID")); + + if (pfnSetCurrentProcessExplicitAppUserModelID) + pfnSetCurrentProcessExplicitAppUserModelID (L"gnu.octave"); + + FreeLibrary (hShell); + } + +#endif +} + DEFUN (__open_with_system_app__, args, , doc: /* -*- texinfo -*- @deftypefn {} {} __open_with_system_app__ (@var{file})
--- a/libinterp/corefcn/sysdep.h Thu Jun 30 18:17:26 2016 +1000 +++ b/libinterp/corefcn/sysdep.h Fri Jul 22 15:26:58 2016 -0400 @@ -34,6 +34,8 @@ extern OCTINTERP_API void sysdep_init (void); +extern OCTINTERP_API void set_application_id (void); + extern OCTINTERP_API void sysdep_cleanup (void); extern OCTINTERP_API void raw_mode (bool, bool wait = true);