Move platform-specific init tasks into KIPLATFORM
This commit is contained in:
parent
7b4890e578
commit
3036683a2c
|
@ -47,10 +47,8 @@
|
||||||
#include <confirm.h>
|
#include <confirm.h>
|
||||||
#include <settings/settings_manager.h>
|
#include <settings/settings_manager.h>
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#include <kiplatform/app.h>
|
||||||
#include <config.h>
|
|
||||||
#include <VersionHelpers.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Only a single KIWAY is supported in this single_top top level component,
|
// Only a single KIWAY is supported in this single_top top level component,
|
||||||
// which is dedicated to loading only a single DSO.
|
// which is dedicated to loading only a single DSO.
|
||||||
|
@ -131,52 +129,11 @@ wxIMPLEMENT_DYNAMIC_CLASS(HtmlModule, wxModule);
|
||||||
*/
|
*/
|
||||||
struct APP_SINGLE_TOP : public wxApp
|
struct APP_SINGLE_TOP : public wxApp
|
||||||
{
|
{
|
||||||
#if defined (__LINUX__)
|
|
||||||
APP_SINGLE_TOP(): wxApp()
|
|
||||||
{
|
|
||||||
// Disable proxy menu in Unity window manager. Only usual menubar works with wxWidgets (at least <= 3.1)
|
|
||||||
// When the proxy menu menubar is enable, some important things for us do not work: menuitems UI events and shortcuts.
|
|
||||||
wxString wm;
|
|
||||||
|
|
||||||
if( wxGetEnv( wxT( "XDG_CURRENT_DESKTOP" ), &wm ) && wm.CmpNoCase( wxT( "Unity" ) ) == 0 )
|
|
||||||
{
|
|
||||||
wxSetEnv ( wxT("UBUNTU_MENUPROXY" ), wxT( "0" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Force the use of X11 backend (or wayland-x11 compatibilty layer). This is required until wxWidgets
|
|
||||||
// supports the Wayland compositors
|
|
||||||
wxSetEnv( wxT( "GDK_BACKEND" ), wxT( "x11" ) );
|
|
||||||
|
|
||||||
// Disable overlay scrollbars as they mess up wxWidgets window sizing and cause excessive redraw requests
|
|
||||||
wxSetEnv( wxT( "GTK_OVERLAY_SCROLLING" ), wxT( "0" ) );
|
|
||||||
|
|
||||||
// Set GTK2-style input instead of xinput2. This disables touchscreen and smooth scrolling
|
|
||||||
// Needed to ensure that we are not getting multiple mouse scroll events
|
|
||||||
wxSetEnv( wxT( "GDK_CORE_DEVICE_EVENTS" ), wxT( "1" ) );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool OnInit() override
|
bool OnInit() override
|
||||||
{
|
{
|
||||||
#if defined( _MSC_VER ) && defined( DEBUG )
|
// Init the platform-specific parts
|
||||||
// wxWidgets turns on leak dumping in debug but its "flawed" and will falsely dump for half a hour
|
if( !KIPLATFORM::APP::PlatformInit() )
|
||||||
// _CRTDBG_ALLOC_MEM_DF is the usual default for MSVC
|
|
||||||
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined( _WIN32 ) && defined( PYTHON_VERSION_MAJOR ) \
|
|
||||||
&& ( ( PYTHON_VERSION_MAJOR == 3 && PYTHON_VERSION_MINOR >= 8 ) \
|
|
||||||
|| PYTHON_VERSION_MAJOR > 3 )
|
|
||||||
|
|
||||||
// Python 3.8 switched to Windows 8+ API, we do not support Windows 7 and will not attempt to hack around it
|
|
||||||
// Gracefully inform the user and refuse to start (because python will crash us if we continue)
|
|
||||||
if( !IsWindows8OrGreater() )
|
|
||||||
{
|
|
||||||
wxMessageBox( _( "Windows 7 and older is no longer supported by KiCad and its dependencies." ),
|
|
||||||
_( "Unsupported Operating System" ), wxOK | wxICON_ERROR );
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Force wxHtmlWinParser initialization when a wxHtmlWindow is used only
|
// Force wxHtmlWinParser initialization when a wxHtmlWindow is used only
|
||||||
// in a shared library (.so or .dll file)
|
// in a shared library (.so or .dll file)
|
||||||
|
|
|
@ -48,10 +48,8 @@
|
||||||
#include "kicad_manager_frame.h"
|
#include "kicad_manager_frame.h"
|
||||||
#include "kicad_settings.h"
|
#include "kicad_settings.h"
|
||||||
|
|
||||||
#if defined( _WIN32 )
|
#include <kiplatform/app.h>
|
||||||
#include <config.h>
|
|
||||||
#include <VersionHelpers.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// a dummy to quiet linking with EDA_BASE_FRAME::config();
|
// a dummy to quiet linking with EDA_BASE_FRAME::config();
|
||||||
#include <kiface_i.h>
|
#include <kiface_i.h>
|
||||||
|
@ -257,57 +255,11 @@ KIWAY Kiway( &Pgm(), KFCTL_CPP_PROJECT_SUITE );
|
||||||
*/
|
*/
|
||||||
struct APP_KICAD : public wxApp
|
struct APP_KICAD : public wxApp
|
||||||
{
|
{
|
||||||
#if defined (__LINUX__)
|
|
||||||
APP_KICAD(): wxApp()
|
|
||||||
{
|
|
||||||
// Disable proxy menu in Unity window manager. Only usual menubar works with
|
|
||||||
// wxWidgets (at least <= 3.1). When the proxy menu menubar is enable, some
|
|
||||||
// important things for us do not work: menuitems UI events and shortcuts.
|
|
||||||
wxString wm;
|
|
||||||
|
|
||||||
if( wxGetEnv( wxT( "XDG_CURRENT_DESKTOP" ), &wm ) && wm.CmpNoCase( wxT( "Unity" ) ) == 0 )
|
|
||||||
{
|
|
||||||
wxSetEnv ( wxT("UBUNTU_MENUPROXY" ), wxT( "0" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Force the use of X11 backend (or wayland-x11 compatibilty layer). This is
|
|
||||||
// required until wxWidgets supports the Wayland compositors
|
|
||||||
wxSetEnv( wxT( "GDK_BACKEND" ), wxT( "x11" ) );
|
|
||||||
|
|
||||||
// Disable overlay scrollbars as they mess up wxWidgets window sizing and cause
|
|
||||||
// excessive redraw requests.
|
|
||||||
wxSetEnv( wxT( "GTK_OVERLAY_SCROLLING" ), wxT( "0" ) );
|
|
||||||
|
|
||||||
// Set GTK2-style input instead of xinput2. This disables touchscreen and smooth
|
|
||||||
// scrolling. It's needed to ensure that we are not getting multiple mouse scroll
|
|
||||||
// events.
|
|
||||||
wxSetEnv( wxT( "GDK_CORE_DEVICE_EVENTS" ), wxT( "1" ) );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool OnInit() override
|
bool OnInit() override
|
||||||
{
|
{
|
||||||
#if defined( _MSC_VER ) && defined( DEBUG )
|
// Init the platform-specific parts
|
||||||
// wxWidgets turns on leak dumping in debug but its "flawed" and will falsely dump
|
if( !KIPLATFORM::APP::PlatformInit() )
|
||||||
// for half a hour _CRTDBG_ALLOC_MEM_DF is the usual default for MSVC.
|
|
||||||
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined( _WIN32 ) && defined( PYTHON_VERSION_MAJOR ) \
|
|
||||||
&& ( ( PYTHON_VERSION_MAJOR == 3 && PYTHON_VERSION_MINOR >= 8 ) \
|
|
||||||
|| PYTHON_VERSION_MAJOR > 3 )
|
|
||||||
|
|
||||||
// Python 3.8 switched to Windows 8+ API, we do not support Windows 7 and will not
|
|
||||||
// attempt to hack around it. Gracefully inform the user and refuse to start (because
|
|
||||||
// python will crash us if we continue).
|
|
||||||
if( !IsWindows8OrGreater() )
|
|
||||||
{
|
|
||||||
wxMessageBox( _( "Windows 7 and older is no longer supported by KiCad and its "
|
|
||||||
"dependencies." ), _( "Unsupported Operating System" ),
|
|
||||||
wxOK | wxICON_ERROR );
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if( !program.OnPgmInit() )
|
if( !program.OnPgmInit() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,8 +21,35 @@
|
||||||
#include <kiplatform/app.h>
|
#include <kiplatform/app.h>
|
||||||
|
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
|
#include <wx/utils.h>
|
||||||
|
|
||||||
|
|
||||||
|
bool KIPLATFORM::APP::PlatformInit()
|
||||||
|
{
|
||||||
|
// Disable proxy menu in Unity window manager. Only usual menubar works with
|
||||||
|
// wxWidgets (at least <= 3.1). When the proxy menu menubar is enable, some
|
||||||
|
// important things for us do not work: menuitems UI events and shortcuts.
|
||||||
|
wxString wm;
|
||||||
|
|
||||||
|
if( wxGetEnv( wxT( "XDG_CURRENT_DESKTOP" ), &wm ) && wm.CmpNoCase( wxT( "Unity" ) ) == 0 )
|
||||||
|
wxSetEnv ( wxT("UBUNTU_MENUPROXY" ), wxT( "0" ) );
|
||||||
|
|
||||||
|
// Force the use of X11 backend (or wayland-x11 compatibilty layer). This is
|
||||||
|
// required until wxWidgets supports the Wayland compositors
|
||||||
|
wxSetEnv( wxT( "GDK_BACKEND" ), wxT( "x11" ) );
|
||||||
|
|
||||||
|
// Disable overlay scrollbars as they mess up wxWidgets window sizing and cause
|
||||||
|
// excessive redraw requests.
|
||||||
|
wxSetEnv( wxT( "GTK_OVERLAY_SCROLLING" ), wxT( "0" ) );
|
||||||
|
|
||||||
|
// Set GTK2-style input instead of xinput2. This disables touchscreen and smooth
|
||||||
|
// scrolling. It's needed to ensure that we are not getting multiple mouse scroll
|
||||||
|
// events.
|
||||||
|
wxSetEnv( wxT( "GDK_CORE_DEVICE_EVENTS" ), wxT( "1" ) );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool KIPLATFORM::APP::RegisterApplicationRestart( const wxString& aCommandLine )
|
bool KIPLATFORM::APP::RegisterApplicationRestart( const wxString& aCommandLine )
|
||||||
{
|
{
|
||||||
// Not implemented on this platform
|
// Not implemented on this platform
|
||||||
|
|
|
@ -28,6 +28,13 @@ namespace KIPLATFORM
|
||||||
{
|
{
|
||||||
namespace APP
|
namespace APP
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Perform platform-specific initialization tasks.
|
||||||
|
*
|
||||||
|
* @return true if init successful, false if unsuccessful
|
||||||
|
*/
|
||||||
|
bool PlatformInit();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers the application for restart with the OS with the given command line string to pass as args
|
* Registers the application for restart with the OS with the given command line string to pass as args
|
||||||
*
|
*
|
||||||
|
|
|
@ -26,6 +26,34 @@
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <strsafe.h>
|
#include <strsafe.h>
|
||||||
|
#include <config.h>
|
||||||
|
#include <VersionHelpers.h>
|
||||||
|
|
||||||
|
|
||||||
|
bool KIPLATFORM::APP::PlatformInit()
|
||||||
|
{
|
||||||
|
#if defined( _MSC_VER ) && defined( DEBUG )
|
||||||
|
// wxWidgets turns on leak dumping in debug but its "flawed" and will falsely dump
|
||||||
|
// for half a hour _CRTDBG_ALLOC_MEM_DF is the usual default for MSVC.
|
||||||
|
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined( PYTHON_VERSION_MAJOR ) && ( ( PYTHON_VERSION_MAJOR == 3 && PYTHON_VERSION_MINOR >= 8 ) \
|
||||||
|
|| PYTHON_VERSION_MAJOR > 3 )
|
||||||
|
// Python 3.8 switched to Windows 8+ API, we do not support Windows 7 and will not
|
||||||
|
// attempt to hack around it. Gracefully inform the user and refuse to start (because
|
||||||
|
// python will crash us if we continue).
|
||||||
|
if( !IsWindows8OrGreater() )
|
||||||
|
{
|
||||||
|
wxMessageBox( _( "Windows 7 and older is no longer supported by KiCad and its "
|
||||||
|
"dependencies." ), _( "Unsupported Operating System" ),
|
||||||
|
wxOK | wxICON_ERROR );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool KIPLATFORM::APP::RegisterApplicationRestart( const wxString& aCommandLine )
|
bool KIPLATFORM::APP::RegisterApplicationRestart( const wxString& aCommandLine )
|
||||||
|
|
|
@ -23,6 +23,13 @@
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
|
|
||||||
|
|
||||||
|
bool KIPLATFORM::APP::PlatformInit()
|
||||||
|
{
|
||||||
|
// No special OSX init tasks
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool KIPLATFORM::APP::RegisterApplicationRestart( const wxString& aCommandLine )
|
bool KIPLATFORM::APP::RegisterApplicationRestart( const wxString& aCommandLine )
|
||||||
{
|
{
|
||||||
// Not implemented on this platform
|
// Not implemented on this platform
|
||||||
|
|
Loading…
Reference in New Issue