Skip to content

Fix gtk4 migration#39

Open
Paramveersingh-S wants to merge 7 commits into
CERN:mainfrom
Paramveersingh-S:feat/gtk4-migration
Open

Fix gtk4 migration#39
Paramveersingh-S wants to merge 7 commits into
CERN:mainfrom
Paramveersingh-S:feat/gtk4-migration

Conversation

@Paramveersingh-S

Copy link
Copy Markdown
Contributor

Description

This PR introduces the initial framework for Issue #37 (Native Support for GTK4), allowing the library to be conditionally compiled against modern GTK4 instead of legacy Motif/Xaw via the USE_GTK4=ON CMake flag.

Changes Included

  • Build System Integration: Updated CMakeLists.txt to conditionally probe for gtk4.pc using pkg_check_modules when USE_GTK4 is active.
  • Type Abstraction: Abstracted core UI types (XtAppContext and Widget) in ws.h and sin.h to dynamically typedef to GtkWidget* and generic pointers under GTK4 context.
  • Event Loop Integration: Overhauled phg_cpm_init_toolkit and the workstation event dispatchers (wsx_inp.c, ws_pm.c) to safely invoke gtk_init() and poll g_main_context_iteration() alongside the native X11 message queue, bridging the gap between raw GLX rendering and GTK4 GUI event handling.
  • Input Widget Upgrades: Rewrote the Motif/Xaw conditional blocks in sin_val.c, sin_str.c, and sin_cho.c to wrap the legacy inputs with modern GtkDialog configurations using GtkScale, GtkEntry, and GtkListBox.

please test the changes, tell me if they are working , if there are any errors please tell me

@schwicke

schwicke commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

This does not compile:

In file included from OpenPHIGS/src/include/phigs/ws_inp.h:53,
from OpenPHIGS/src/include/phigs/phg.h:60,
from OpenPHIGS/src/libphigs/archive/ar.c:59:
OpenPHIGS/src/include/phigs/sin.h:403:10: error: unknown type name ‘XtActionProc’
403 | extern XtActionProc phg_sin_xt_request_satisfied(Widget);
| ^~~~~~~~~~~~
OpenPHIGS/src/include/phigs/sin.h:404:10: error: unknown type name ‘XtActionProc’
404 | extern XtActionProc phg_sin_xt_string_event(Widget, XEvent*, String , Cardinal);
| ^~~~~~~~~~~~
OpenPHIGS/src/include/phigs/sin.h:404:68: error: unknown type name ‘String’; did you mean ‘GString’?
404 | extern XtActionProc phg_sin_xt_string_event(Widget, XEvent*, String , Cardinal);
| ^~~~~~
| GString
OpenPHIGS/src/include/phigs/sin.h:404:78: error: unknown type name ‘Cardinal’
404 | extern XtActionProc phg_sin_xt_string_event(Widget, XEvent*, String , Cardinal);
| ^~~~~~~~

@Paramveersingh-S

Copy link
Copy Markdown
Contributor Author

@schwicke thank you for catching that!

The XtActionProc, Widget, String, and Cardinal types belong to the legacy X Toolkit framework (Xt). Since the GTK4 build path strips out those legacy dependencies, the compiler naturally threw "unknown type name" errors when it hit those old declarations.

Since GTK4 doesn't use Xt action procs for input handling, I have wrapped those specific declarations in sin.h and their implementations in sin_ws.c / sin_str.c with #ifndef USE_GTK4 preprocessor directives. This ensures they are cleanly compiled out when USE_GTK4=ON is set.

I have pushed the fix. Please pull the latest changes and try compiling again! Let me know if you run into anything else.

@schwicke

schwicke commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

It may make sense to update the tests to run with GTK4 enabled since it still fails to compile, now in
OpenPHIGS/src/include/phigs/sin.h:404:10: error: unknown type name ‘XtActionProc’

@schwicke

schwicke commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

As for the other one, this feature is not urgent: Motif is still present in all recently released Linux distributions I have checked so far, so we have literally years to get this fixed. Please do not waste too much time with this. This one will be tricky, and it will require quite some code changes. I think what you did already gives a good hint into which direction to go to get this fixed.

Many thanks for your contributions !!!

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.

2 participants