Skip to content

[x11] Add kdialog support, more robust detection#187

Merged
dacap merged 1 commit into
aseprite:betafrom
ckaiser:kdialog-kfeature-kbranch
Jun 9, 2026
Merged

[x11] Add kdialog support, more robust detection#187
dacap merged 1 commit into
aseprite:betafrom
ckaiser:kdialog-kfeature-kbranch

Conversation

@ckaiser

@ckaiser ckaiser commented May 28, 2026

Copy link
Copy Markdown
Member

Adds kdialog support and improves the check (popen was either racing or something else strange was happening because it was always defaulting to the built-in Aseprite dialog except when I was stepping through with the debugger to give it time, std::system will always block).

@aseprite-bot aseprite-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread dlgs/file_dialog_x11.cpp Outdated
#include "base/replace_string.h"
#include "base/split_string.h"

#include "fmt/format.h"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'fmt/format.h' file not found [clang-diagnostic-error]

#include "fmt/format.h"
         ^

Comment thread dlgs/file_dialog_x11.cpp Outdated
if (s_cliTool == CLITool::Unknown) {
FILE* f = popen("zenity --version", "r");
if (f && pclose(f) == 0) {
if (std::system("kdialog --version > /dev/null 2>&1") == 0)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function is not thread safe [concurrency-mt-unsafe]

      if (std::system("kdialog --version > /dev/null 2>&1") == 0)
          ^

Comment thread dlgs/file_dialog_x11.cpp Outdated
if (f && pclose(f) == 0) {
if (std::system("kdialog --version > /dev/null 2>&1") == 0)
s_cliTool = CLITool::KDialog;
else if (std::system("zenity --version > /dev/null 2>&1") == 0)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function is not thread safe [concurrency-mt-unsafe]

      else if (std::system("zenity --version > /dev/null 2>&1") == 0)
               ^

@aseprite-bot aseprite-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread dlgs/file_dialog_x11.cpp Outdated
if (s_cliTool == CLITool::Unknown) {
FILE* f = popen("zenity --version", "r");
if (f && pclose(f) == 0) {
if (backend == "kdialog" || std::system("kdialog --version > /dev/null 2>&1") == 0)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function is not thread safe [concurrency-mt-unsafe]

      if (backend == "kdialog" || std::system("kdialog --version > /dev/null 2>&1") == 0)
                                  ^

Comment thread dlgs/file_dialog_x11.cpp Outdated
if (f && pclose(f) == 0) {
if (backend == "kdialog" || std::system("kdialog --version > /dev/null 2>&1") == 0)
s_cliTool = CLITool::KDialog;
else if (backend == "zenity" || std::system("zenity --version > /dev/null 2>&1") == 0)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function is not thread safe [concurrency-mt-unsafe]

      else if (backend == "zenity" || std::system("zenity --version > /dev/null 2>&1") == 0)
                                      ^

Comment thread dlgs/file_dialog.h Outdated
// Connection to the X11 server (the Display* pointer returned by
// XOpenDisplay()).
void* x11display = nullptr;
std::string backend = "autodetect";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if this is an enum (probably the CLITool could be moved inside FileDialog), and we convert the string <-> enum from the Aseprite side.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the enum and made the backend selection fall back to whatever it finds that is working

@ckaiser ckaiser force-pushed the kdialog-kfeature-kbranch branch from 71adbbb to ce82135 Compare June 4, 2026 16:09

@aseprite-bot aseprite-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread dlgs/file_dialog_x11.cpp
if (f && pclose(f) == 0) {
s_cliTool = CLITool::Zenity;
const auto hasZenity = [] {
static bool check = std::system("zenity --version > /dev/null 2>&1") == 0;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function is not thread safe [concurrency-mt-unsafe]

        static bool check = std::system("zenity --version > /dev/null 2>&1") == 0;
                            ^

Comment thread dlgs/file_dialog_x11.cpp
if (f && pclose(f) == 0) {
s_cliTool = CLITool::Zenity;
const auto hasZenity = [] {
static bool check = std::system("zenity --version > /dev/null 2>&1") == 0;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'check' of type 'bool' can be declared 'const' [misc-const-correctness]

Suggested change
static bool check = std::system("zenity --version > /dev/null 2>&1") == 0;
static bool const check = std::system("zenity --version > /dev/null 2>&1") == 0;

Comment thread dlgs/file_dialog_x11.cpp
return check;
};
const auto hasKdialog = [] {
static bool check = std::system("kdialog --version > /dev/null 2>&1") == 0;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function is not thread safe [concurrency-mt-unsafe]

        static bool check = std::system("kdialog --version > /dev/null 2>&1") == 0;
                            ^

Comment thread dlgs/file_dialog_x11.cpp
return check;
};
const auto hasKdialog = [] {
static bool check = std::system("kdialog --version > /dev/null 2>&1") == 0;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'check' of type 'bool' can be declared 'const' [misc-const-correctness]

Suggested change
static bool check = std::system("kdialog --version > /dev/null 2>&1") == 0;
static bool const check = std::system("kdialog --version > /dev/null 2>&1") == 0;

Comment thread dlgs/file_dialog_x11.cpp
@dacap

dacap commented Jun 5, 2026

Copy link
Copy Markdown
Member

There is just that minor change, but after that I think we can merge it 👍 looks good.

@dacap dacap assigned ckaiser and unassigned dacap Jun 5, 2026
@ckaiser ckaiser force-pushed the kdialog-kfeature-kbranch branch from ce82135 to abee677 Compare June 5, 2026 20:06
@ckaiser ckaiser assigned dacap and unassigned ckaiser Jun 5, 2026
@dacap

dacap commented Jun 9, 2026

Copy link
Copy Markdown
Member

Looks great 🗄️ 🚀

@dacap dacap merged commit 9494e91 into aseprite:beta Jun 9, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants