# HG changeset patch # User John W. Eaton # Date 1469215618 14400 # Node ID 20e684ec108eae51ab1ec12454f100aa69b5b3c6 # Parent 5d4a286061c8a13116eec4d8770c22493304be78 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. diff -r 5d4a286061c8 -r 20e684ec108e libgui/src/octave-gui.cc --- 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 -// 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 (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"); diff -r 5d4a286061c8 -r 20e684ec108e libinterp/corefcn/sysdep.cc --- 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 (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}) diff -r 5d4a286061c8 -r 20e684ec108e libinterp/corefcn/sysdep.h --- 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);