Skip to content

[gui] Native GUI draws canvas without defaulting to web - #23163

Closed
ThePhisch wants to merge 1 commit into
root-project:masterfrom
ThePhisch:nativeguifix
Closed

ThePhisch wants to merge 1 commit into
root-project:masterfrom
ThePhisch:nativeguifix

Conversation

@ThePhisch

Copy link
Copy Markdown

When drawing a canvas in a native GUI (e.g. using
tutorials/visualisation/gui/guitest.C and Test->Dialog->Tab3), the canvas used to default to black. The workaround was --web=off, which is inconvenient.

Implements a new method TGuiFactory::CreateCanvasImpNative that bypasses the gROOT->IsWebDisplay() check and directly returns a TCanvasImp as required by the native GUI.

TGuiFactory::CreateCanvasImp receives TCanvas *c as a parameter. For a web canvas, the canvas ID is 111222333 (see TWebCanvas.cxx:293), this would be enough to determine that we do not want to create a web canvas element, but a native one instead. However, TCanvas is only forward declared within TGuiFactory, hence we cannot access its methods.

Checklist:

  • tested changes locally
  • updated the docs (not necessary)
  • added tests (not sure how to write a test for this behaviour)
  • ran clang-format

AI Disclaimer

I used AI in the debugging process, but I wrote the code myself. It is a very small edit anyway.

When drawing a canvas in a native GUI (e.g. using
`tutorials/visualisation/gui/guitest.C` and Test->Dialog->Tab3), the canvas
used to default to black. The workaround was `--web=off`, which is
inconvenient.

Implements a new method `TGuiFactory::CreateCanvasImpNative` that bypasses the
`gROOT->IsWebDisplay()` check and directly returns a `TCanvasImp` as required
by the native GUI.

`TGuiFactory::CreateCanvasImp` receives `TCanvas *c` as a parameter. For a web
canvas, the canvas ID is `111222333` (see `TWebCanvas.cxx:293`), this would be
enough to determine that we do not want to create a web canvas element, but a
native one instead. However, `TCanvas` is only forward declared within
`TGuiFactory`, hence we cannot access its methods.
@linev linev self-assigned this Aug 27, 2026
@linev linev added the in:GUI label Aug 27, 2026

@linev linev left a comment

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.

This is wrong approach.

TGuiFactory is "native" at the moment when instantiated in the ROOT application.
And it has necessary methods to create implementation for canvas.

Code cannot work - while it only provides basic TCanvasImp instance which has no real implementation and only created in batch mode.

I see no problem with guitest.C macro - nor in master neither in the released ROOT version 6.40.x

We are follow now different strategy to extend existing TGuiFactory/TCanvasImp classes to be able provide real alternatives for current TVirtualX-based graphics and guis. See PR for such example #22736

@linev

linev commented Aug 27, 2026

Copy link
Copy Markdown
Member

I close PR as wan't merge

@linev linev closed this Aug 27, 2026
@ThePhisch

ThePhisch commented Aug 27, 2026 •

Copy link
Copy Markdown
Author

This is wrong approach.

TGuiFactory is "native" at the moment when instantiated in the ROOT application. And it has necessary methods to create implementation for canvas.

Code cannot work - while it only provides basic TCanvasImp instance which has no real implementation and only created in batch mode.

I see no problem with guitest.C macro - nor in master neither in the released ROOT version 6.40.x

We are follow now different strategy to extend existing TGuiFactory/TCanvasImp classes to be able provide real alternatives for current TVirtualX-based graphics and guis. See PR for such example #22736

are you running on linux or MacOS? I should have mentioned that I have this issue on MacOS.

This is what it looks like:
image

This is what is should look like (i.e. with the workaround root --web=off
image

This is guitest.C on 6.40.02 running on Tahoe 26.3.1 (a)

@linev

linev commented Aug 27, 2026

Copy link
Copy Markdown
Member

On Mac I see no problem on master, 6.40 and 6.38 branches.

Do you have special rootlogon.C macro or .rootrc file in current directory?

@ThePhisch

Copy link
Copy Markdown
Author

On Mac I see no problem on master, 6.40 and 6.38 branches.

Do you have special rootlogon.C macro or .rootrc file in current directory?

It was my .rootrc file that caused the issue. Thank you for helping me catch that.

@couet
couet removed their request for review September 1, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants