Browse Source

Fix shift+middle click on windows no longer working

Fixes https://gitlab.com/kicad/code/kicad/-/issues/21267
9.0
Mark Roszko 4 months ago
parent
commit
589bfeafe3
  1. 4
      common/single_top.cpp
  2. 2
      kicad/kicad.cpp
  3. 12
      libs/kiplatform/include/kiplatform/environment.h
  4. 12
      libs/kiplatform/os/apple/environment.mm
  5. 12
      libs/kiplatform/os/unix/environment.cpp
  6. 65
      libs/kiplatform/os/windows/environment.cpp

4
common/single_top.cpp

@ -43,6 +43,7 @@
#include <wx/html/htmlwin.h>
#include <kiway.h>
#include <build_version.h>
#include <pgm_base.h>
#include <kiway_player.h>
#include <macros.h>
@ -388,6 +389,9 @@ bool PGM_SINGLE_TOP::OnPgmInit()
App().SetTopWindow( frame ); // wxApp gets a face.
App().SetAppDisplayName( frame->GetAboutTitle() );
wxString relaunchDisplayName = frame->GetAboutTitle() + " " + GetMajorMinorVersion();
KIPLATFORM::ENV::SetAppDetailsForWindow( frame, KIPLATFORM::ENV::GetCommandLineStr(), relaunchDisplayName );
// Allocate a slice of time to show the frame and update wxWidgets widgets
// (especially setting valid sizes) after creating frame and before calling
// OpenProjectFiles() that can update/use some widgets.

2
kicad/kicad.cpp

@ -239,6 +239,8 @@ bool PGM_KICAD::OnPgmInit()
Kiway.SetTop( frame );
KIPLATFORM::ENV::SetAppDetailsForWindow( frame, KIPLATFORM::ENV::GetCommandLineStr(), frame->GetTitle() );
KICAD_SETTINGS* settings = static_cast<KICAD_SETTINGS*>( PgmSettings() );
#ifdef KICAD_IPC_API

12
libs/kiplatform/include/kiplatform/environment.h

@ -20,6 +20,8 @@
#include <wx/string.h>
class wxWindow;
namespace KIPLATFORM
{
namespace ENV
@ -118,5 +120,15 @@ namespace KIPLATFORM
* @returns The app user model id on Windows, empty on all other platforms
*/
wxString GetAppUserModelId();
/**
* Sets the relaunch command for taskbar pins, this is intended for Windows
*/
void SetAppDetailsForWindow( wxWindow* aWindow, const wxString& aRelaunchCommand, const wxString& aRelaunchDisplayName );
/**
* @returns the command line string used to launch the process
*/
wxString GetCommandLineStr();
}
}

12
libs/kiplatform/os/apple/environment.mm

@ -121,6 +121,18 @@ bool KIPLATFORM::ENV::VerifyFileSignature( const wxString& aPath )
wxString KIPLATFORM::ENV::GetAppUserModelId()
{
return wxEmptyString;
}
void KIPLATFORM::ENV::SetAppDetailsForWindow( wxWindow* aWindow, const wxString& aRelaunchCommand,
const wxString& aRelaunchDisplayName )
{
}
wxString KIPLATFORM::ENV::GetCommandLineStr()
{
return wxEmptyString;
}

12
libs/kiplatform/os/unix/environment.cpp

@ -130,6 +130,18 @@ bool KIPLATFORM::ENV::VerifyFileSignature( const wxString& aPath )
wxString KIPLATFORM::ENV::GetAppUserModelId()
{
return wxEmptyString;
}
void KIPLATFORM::ENV::SetAppDetailsForWindow( wxWindow* aWindow, const wxString& aRelaunchCommand,
const wxString& aRelaunchDisplayName )
{
}
wxString KIPLATFORM::ENV::GetCommandLineStr()
{
return wxEmptyString;
}

65
libs/kiplatform/os/windows/environment.cpp

@ -26,10 +26,13 @@
#include <wx/tokenzr.h>
#include <wx/app.h>
#include <wx/uri.h>
#include <wx/window.h>
#include <Windows.h>
#include <shellapi.h>
#include <shlwapi.h>
#include <propkey.h>
#include <propvarutil.h>
#if defined( __MINGW32__ )
#include <shobjidl.h>
#else
@ -416,4 +419,66 @@ wxString KIPLATFORM::ENV::GetAppUserModelId()
// the other limitation is 127 characters but we arent trying to hit that limit yet
return modelId;
}
void KIPLATFORM::ENV::SetAppDetailsForWindow( wxWindow* aWindow, const wxString& aRelaunchCommand,
const wxString& aRelaunchDisplayName )
{
IPropertyStore* pps;
HRESULT hr = ::SHGetPropertyStoreForWindow( aWindow->GetHWND(), IID_PPV_ARGS( &pps ) );
if( SUCCEEDED( hr ) )
{
PROPVARIANT pv;
// This is required for any the other properties to actually work
hr = ::InitPropVariantFromString( GetAppUserModelId(), &pv );
if( SUCCEEDED( hr ) )
{
hr = pps->SetValue( PKEY_AppUserModel_ID, pv );
PropVariantClear( &pv );
}
if( !aRelaunchCommand.empty() )
{
hr = ::InitPropVariantFromString( aRelaunchCommand.wc_str(), &pv );
}
else
{
// empty var
::PropVariantInit( &pv );
}
if( SUCCEEDED( hr ) )
{
hr = pps->SetValue( PKEY_AppUserModel_RelaunchCommand, pv );
PropVariantClear( &pv );
}
if( !aRelaunchDisplayName.empty() )
{
hr = ::InitPropVariantFromString( aRelaunchDisplayName.wc_str(), &pv );
}
else
{
// empty var
::PropVariantInit( &pv );
}
if( SUCCEEDED( hr ) )
{
hr = pps->SetValue( PKEY_AppUserModel_RelaunchDisplayNameResource, pv );
PropVariantClear( &pv );
}
pps->Release();
}
}
wxString KIPLATFORM::ENV::GetCommandLineStr()
{
return ::GetCommandLine();
}
Loading…
Cancel
Save