February 23, 2024

Molybden 1.2.0: restarting application, command line arguments, window focus events, window display policy

We’re excited to announce the release of Molybden 1.2.0. In this version we introduce several new features and enhancements, including the ability to programmatically restart the application, access the passed application command line arguments, get notifications about the application window focus events, and more.

What’s new

Application restart

You can restart the application programmatically. To do this, use the following code:

app->restart();

It will close all application windows, release the allocated resources, terminate the application process, and then run the application again with the same command line arguments.

Command line arguments

You can now access the command line arguments passed to your application. To do this, use the following approach:

for (auto& arg : CommandLineArgs::get().list()) {
  std::cout << arg << std::endl;
}

The first argument in the list is the absolute path to the application executable.

Window focus events

You can now get notifications about the application window focus events. To do this, use the following approach:

browser->onFocusGained += [](const FocusGained& event) {
  // Application browser window is focused.
};

browser->onFocusLost += [](const FocusLost& event) {
  // Application browser window has lost focus.
};

Window display policy

On macOS, you can create additional desktops, called spaces, to organize the windows.

You can now control the behavior of the application window when the user switches between spaces and tell the application how its window should be displayed in the environment with multiple spaces. The following display policies are available:

// The window appears on only one desktop at a time.
browser->setWindowDisplayPolicy(WindowDisplayPolicy::kDefault);

// The window appears on all desktops.
browser->setWindowDisplayPolicy(WindowDisplayPolicy::kAppearOnAllDesktops);

// When the window becomes active, move it to the active desktop instead 
// of switching desktops.
browser->setWindowDisplayPolicy(WindowDisplayPolicy::kMoveToActiveDesktop);

Detecting current operating system

You can now detect the current operating system and apply different behavior to your application on different platforms. You can now use the following predefined constants in your C++ code to detect the current operating system:

#if OS_WIN
  // The current operating system is Windows.
#elif OS_MAC
  // The current operating system is macOS.
#elif OS_LINUX
  // The current operating system is Linux.
#else
  // The current operating system is unknown and unsupported.
#endif

CLI improvements

In this version we improved the command line interface (CLI) to provide better user experience and more informative output.

Informative output

We reduced the output for the npm run molybden dev and npm run molybden build commands, so you will see only the most important information about the build process. The output will be like this now:

$ npm run molybden build

> MyApp@0.0.0 molybden
> molybden build

✓ Checking environment
✓ Building application [8.31s]
✓ Packaging application resources [1.30s]
✓ Checking license and subscription [1.51s]
    License type: Trial
    Trial expiration date: February 22, 2024
✓ Signing application [7.19s]
✓ Notarizing application [97.88s]
✓ Building application installer [26.04s]
Application location: /Users/vladimir/MyApp/build-dist/bin
Application installer location: /Users/vladimir/MyApp/build-dist/pack

To see the full output, run the command with the --verbose option:

npm run molybden dev -- --verbose

Checking environment

Now the CLI checks the environment before running the npm run molybden dev and npm run molybden build commands. It checks if the required tools are installed and if the environment is set up correctly. If something is missing, the CLI will show a warning message with instructions on how to fix the issue.

Chromium 121.0.6167.184

We upgraded Chromium to a newer version, which introduces multiple security fixes that prevent a remote attacker to potentially exploit heap corruption via a crafted HTML page or malicious file, including:

For the complete list of Chromium fixes and improvements in 121.0.6167.184 please visit the product blog posts for the following versions:

Enhancements

  • Fixed an issue when the application cannot be signed with a valid certificate on Windows due to the SignTool error: 0x800700C1.

How to upgrade

To install the latest version of Molybden in your project, run the following command:

npm install @molybden-apps/molybden@latest

Please note that in this version we modified CMakeLists.txt. We extracted all internal project configuration into a separate Molybden.cmake file and keep only the necessary minimum to let you easily include third-party C++ libraries to your project.

To make your existing CMakeLists.txt compatible with the new version of Molybden, please replace the content of your CMakeLists.txt with the following content:

cmake_minimum_required(VERSION 3.21)

# Configures your project.
project(MyApp LANGUAGES CXX)

# Imports the Molybden app configuration and setups the auxiliary targets, 
# resources, etc.
# Important: Do not move this include above the project declaration.
include(node_modules/@molybden-apps/molybden/Molybden.cmake)

# The source files of your app.
set(APP_SOURCES src-cpp/src/main.cc)

# Defines the main target of the application.
add_library(molybden_lib STATIC ${APP_SOURCES})

# The Molybden API requires C++20.
set_property(TARGET molybden_lib PROPERTY CXX_STANDARD 20)

# Adds the Molybden API to the include path.
# Provide the additional include directories if needed.
target_include_directories(molybden_lib PRIVATE ${MOLYBDEN_SDK_DIR}/include)

Important: Don’t forget to replace MyApp with the name of your project and add your source code files to the APP_SOURCES list.

What’s next

We’re already working on the next version of Molybden, which will include a number of new features including application auto-updates on Windows and macOS, compatibility with Mac App Store, and more. Visit our product roadmap to see what’s coming next.

If you have any questions or feature requests, please feel free to join our Discord or contact us. We will be happy to hear from you!

On this page
Top