Use `wxApp` class name as app ID (PR #25548)

64 views
Skip to first unread message

VZ

unread,
Jun 19, 2025, 5:00:36 PM6/19/25
to wx-...@googlegroups.com, Subscribed

Replaces #25486.

Closes #24668.


You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/25548

Commit Summary

  • af2f951 Allow setting Wayland app_id via wxApp:SetClassName()
  • d8d397e Use wxApp class name as AppUserModelID under Windows

File Changes

(3 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25548@github.com>

paulcor

unread,
Jun 20, 2025, 8:18:41 PM6/20/25
to wx-...@googlegroups.com, Subscribed

@paulcor approved this pull request.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25548/review/2947446506@github.com>

PB

unread,
Jun 21, 2025, 3:19:09 AM6/21/25
to wx-...@googlegroups.com, Subscribed
PBfordev left a comment (wxWidgets/wxWidgets#25548)

On MSW, is this the same appID as used in wxTaskBarJumpList?

If so, we probably can't use the wxApp one when passed an empty one to wxTaskBarJumpList now, but perhaps it could be cross-referenced in the docs?


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25548/c2993395105@github.com>

VZ

unread,
Jun 21, 2025, 9:41:34 AM6/21/25
to wx-...@googlegroups.com, Push

@vadz pushed 3 commits.

  • 54d57e0 Make wxTaskBarJumpList ctor explicit
  • 6a30460 Use current link to Application User Model IDs documentation
  • 0acf281 Improve app ID support documentation


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25548/before/d8d397e65fb10e9f28d6535182da57a531be9749/after/0acf281e2163f9a46c6e7ce279cb06c52476c7f6@github.com>

VZ

unread,
Jun 21, 2025, 9:41:43 AM6/21/25
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25548)

Good catch, thanks! It's indeed the same app ID and this should indeed be mentioned in the docs, I've updated this PR to do it.

Note that I don't think any changes in the code are needed as by leaving the appID parameter empty we should be already using the previously set global app ID.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25548/c2993590101@github.com>

VZ

unread,
Jun 22, 2025, 2:51:32 PM6/22/25
to wx-...@googlegroups.com, Subscribed

Merged #25548 into master.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25548/issue_event/18262264041@github.com>

Mark Roszko

unread,
Jul 8, 2025, 1:12:45 PM7/8/25
to wx-...@googlegroups.com, Subscribed
marekr left a comment (wxWidgets/wxWidgets#25548)

FYI

This creates a behavior change on Windows.

In particular, the Shift+Middle click function of the taskbar will no longer launch a new instance of the process when a explicit app user model id is set.

This can be fixed by also allowing the specification of the relaunch command on the windows's shell property store (SHGerPropertyStoreForWindow)


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25548/c3049709822@github.com>

VZ

unread,
Jul 8, 2025, 1:21:29 PM7/8/25
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25548)

This creates a behavior change on Windows.

Thanks, I had no idea...

In particular, the Shift+Middle click function of the taskbar will no longer launch a new instance of the process when a explicit app user model id is set.

This can be fixed by also allowing the specification of the relaunch command on the windows's shell property store (SHGerPropertyStoreForWindow)

Do you already have code doing this somewhere I could steal^H^H^H^H^H use as an inspiration?

Probably needs to be explained to a user or documented. And it may not be wise to automatically set the relaunch command in case custom args are required.

Yes, we could need to add some wxApp::MSWSetRelaunchCommand().

(Note kicad uses app user model id but we did it our own way)

Will you be able to switch to wx way once you require 3.3 or is there still anything missing here from your point of view?


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25548/c3049731245@github.com>

Mark Roszko

unread,
Jul 8, 2025, 8:17:23 PM7/8/25
to wx-...@googlegroups.com, Subscribed
marekr left a comment (wxWidgets/wxWidgets#25548)

Do you already have code doing this somewhere I could steal^H^H^H^H^H use as an inspiration?

Sure. This is actually hacky because I started looking at this due to a user complaint. But this does work.

The main bits:

  • The property store is per window
  • The app user model id must be configured on the property store as a separate step from SetCurrentProcessExplicitAppUserModelID
  • It may be very undesirable to support relaunch on some random sub-dialog, so I am only going to do this on KiCad's main frames
  • PKEY_AppUserModel_RelaunchCommand configures the relaunch behavior. It is used both for pinned taskbar icons AND shift-middle click on running processes.
  • win32 ::GetCommandLine() could be set to Relaunch command, however that may not be desirable for all applications, I am evaluating my options here in kicad, including appending a new arg to avoid content on already open files
  • PKEY_AppUserModel_RelaunchDisplayNameResource is not required. However, it becomes the "tooltip" name for pinned applications. Instead of allowing it to pick the window name by default I believe
void KIPLATFORM::ENV::SetWindowRelaunchCommand( wxWindow* aWindow, const wxString& aCommand )
{
    IPropertyStore* pps;
    HRESULT         hr = ::SHGetPropertyStoreForWindow( aWindow->GetHWND(), IID_PPV_ARGS( &pps ) );
    if( SUCCEEDED( hr ) )
    {
        PROPVARIANT pv;

        if( !aCommand.empty() )
        {
            hr = ::InitPropVariantFromString( GetAppUserModelId(), &pv );
        }
        else
        {
            // empty var
            ::PropVariantInit( &pv );
        }

        if( SUCCEEDED( hr ) )
        {
            hr = pps->SetValue( PKEY_AppUserModel_ID, pv );
            PropVariantClear( &pv );
        }


        if( !aCommand.empty() )
        {
            hr = ::InitPropVariantFromString( aCommand.wc_str(), &pv );
        }
        else
        {
            // empty var
            ::PropVariantInit( &pv );
        }

        if( SUCCEEDED( hr ) )
        {
            hr = pps->SetValue( PKEY_AppUserModel_RelaunchCommand, pv );
            PropVariantClear( &pv );
        }

        if( !aCommand.empty() )
        {
            hr = ::InitPropVariantFromString( L"KiCad", &pv );
        }
        else
        {
            // empty var
            ::PropVariantInit( &pv );
        }

        if( SUCCEEDED( hr ) )
        {
            hr = pps->SetValue( PKEY_AppUserModel_RelaunchDisplayNameResource, pv );
            PropVariantClear( &pv );
        }
        pps->Release();
    }
}


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25548/c3050645029@github.com>

Mark Roszko

unread,
Jul 8, 2025, 8:21:18 PM7/8/25
to wx-...@googlegroups.com, Subscribed
marekr left a comment (wxWidgets/wxWidgets#25548)

Will you be able to switch to wx way once you require 3.3 or is there still anything missing here from your point of view?

I need to explore if we are using wxApp::GetClassName for anything else. For the app user model id we have a microsoft formatted string of <organization>.<product>.<subproduct>.<version> which we then pass onto our external third party plugin ecosystem to keep things unified. I don't want to blow things up because we were using GetclassName for something else


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25548/c3050651233@github.com>

VZ

unread,
Jul 10, 2025, 1:33:21 PM7/10/25
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25548)

Thanks for the code, but it looks like this might require adding some new API, as it doesn't seem possible to decide about the right thing to do inside wx itself.

I wonder if this could/should be tied up with some API wrapping RegisterApplicationRestart() which I think would be also useful to have in wx, wouldn't it?


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25548/c3058334006@github.com>

Mark Roszko

unread,
Jul 10, 2025, 1:36:30 PM7/10/25
to wx-...@googlegroups.com, Subscribed
marekr left a comment (wxWidgets/wxWidgets#25548)

Register application restart is also something we handle in kicad. Basically to offer post-update restart when used with the session restoration.

But in kicad's case, implemented the relaunchcommand with a "-n" arg specifically because a user can trigger it while kicad is already open with a project. If you launch kicad again, it would otherwise try to reopen that exist same project. The -n arg in my case tells it to start blank.

But in the register application restart case, I would want it to open the previous project.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25548/c3058341631@github.com>

Mark Roszko

unread,
Jul 10, 2025, 1:39:06 PM7/10/25
to wx-...@googlegroups.com, Subscribed
marekr left a comment (wxWidgets/wxWidgets#25548)

Also, there's another behavior change by app model id. That I am also fixing in kicad.

The MRU file list in windows for shortcuts in your start menu that point to your application stop working.

Fixing it requires implementing SHAddToRecentDocs to add recent items to the shell MRU using app model IDs.

https://gitlab.com/kicad/code/kicad/-/commit/743988bd57b2f74097ed09a5c46899c10522e441#83968e0062c0e041190aca75cc1be793ab662965_484_485

And using setting the app model id within the shortcut itself which is actually not trivial, Microsoft only intended for people to do this via MSI installs.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25548/c3058347891@github.com>

VZ

unread,
Jul 10, 2025, 4:36:04 PM7/10/25
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25548)

Also, there's another behavior change by app model id. That I am also fixing in kicad.

The MRU file list in windows for shortcuts in your start menu that point to your application stop working.

This looks like something wxFileHistory could do, I think. Would it be useful for you if it took care of this?

For the restart problem, unless you'd be interested in discussing restart API more in depth (in which case we need to open a new issue and do it there), I think we'll just have to settle for documenting the limitation for now as I can't say it's obvious to me what should wx do here.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25548/c3058982643@github.com>

Reply all
Reply to author
Forward
0 new messages