Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: Miguel Gimenez on May 22, 2026, 02:38:14 pm

Title: Force X11 compatibility mode
Post by: Miguel Gimenez on May 22, 2026, 02:38:14 pm
Currently most Linux distributions are removing X11 support forcing Wayland usage.

C::B relies heavily on Aui, and currently Aui does not work correctly with Wayland. Forcing XWayland, if it is available, would make Aui work again on these systems (this is the method used by KiCAD).

Adding these lines to OnInit() should be enough:

Code
#ifdef __WXGTK__
    wxSetEnv("GDK_BACKEND", "x11");
#endif

Opinions?

EDIT: The change does not work, while "GDK_BACKEND=x11 ./codeblocks" works. Looks like the variable must be set using setenv() just before the App object is created, i.e., before the call to wxEntry()

Title: Re: Force X11 compatibility mode
Post by: Miguel Gimenez on May 23, 2026, 10:53:40 am
With this patch Aui docking works on Ubuntu 24.04/Wayland:

Code
Index: src/src/app.cpp
===================================================================
--- src/src/app.cpp (revision: 13846)
+++ src/src/app.cpp (copia de trabajo)
@@ -367,8 +367,19 @@
 
 } // namespace
 
-IMPLEMENT_APP(CodeBlocksApp) // TODO: This gives a "redundant declaration" warning, though I think it's false. Dig through macro and check.
+#ifdef __WXGTK__
+wxIMPLEMENT_APP_NO_MAIN(CodeBlocksApp);
 
+int main(int argc, char **argv)
+{
+    setenv("GDK_BACKEND", "x11", 1);
+    wxDISABLE_DEBUG_SUPPORT();
+    return wxEntry(argc, argv);
+}
+#else
+wxIMPLEMENT_APP(CodeBlocksApp);
+#endif
+
 BEGIN_EVENT_TABLE(CodeBlocksApp, wxApp)
     EVT_ACTIVATE_APP(CodeBlocksApp::OnAppActivate)
     EVT_TASKBAR_LEFT_DOWN(CodeBlocksApp::OnTBIconLeftDown)
Title: Re: Force X11 compatibility mode
Post by: blauzahn on May 23, 2026, 03:00:32 pm
With that patch, docking is fixed under Arch Linux Wayland as well, e.g. open-files-list dock.

Wonderful! Thank you.
Title: Re: Force X11 compatibility mode
Post by: Miguel Gimenez on May 25, 2026, 09:58:10 am
Thanks for testing.

Applied in r13848 (https://sourceforge.net/p/codeblocks/code/13848/).
Title: Re: Force X11 compatibility mode
Post by: unixpro1970 on May 29, 2026, 11:08:31 am
Can someone please update AUR with a new codeblocks (with all required patches)?  The latest AUR codeblocks from 2025 hangs when launched on Manjaro.  I am unsure what patches are needed to make it work.

https://archlinux.org/packages/extra/x86_64/codeblocks/
Title: Re: Force X11 compatibility mode
Post by: Miguel Gimenez on May 29, 2026, 11:13:21 am
You need r13775 (https://sourceforge.net/p/codeblocks/code/13775/), r13841 (https://sourceforge.net/p/codeblocks/code/13841/) and r13842 (https://sourceforge.net/p/codeblocks/code/13842/).

For AUI docking, r13848 (https://sourceforge.net/p/codeblocks/code/13848/).