Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@ jobs:
- linux/arm/v6
- linux/arm/v7
- linux/arm64
gtk4: [ON, OFF]

steps:
- uses: actions/checkout@v4

- name: dependencies
run: sudo apt install --fix-missing cmake gcc gfortran libx11-dev libglu1-mesa-dev libmotif-dev tcsh libxaw7-dev libglew-dev libdlm-dev libgl2ps-dev libpng-dev
run: sudo apt install --fix-missing cmake gcc gfortran libx11-dev libglu1-mesa-dev libmotif-dev tcsh libxaw7-dev libglew-dev libdlm-dev libgl2ps-dev libpng-dev libgtk-4-dev

- name: clean
run: make clean

- name: configure
run: make config
run: make config OPENPHIGS_OPTS="-DUSE_GTK4=${{ matrix.gtk4 }}"

- name: Build
run: make build
Expand Down
50 changes: 39 additions & 11 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@ FIND_PACKAGE(PNG REQUIRED)
FIND_PACKAGE(OpenGL REQUIRED)
FIND_PACKAGE(X11 REQUIRED)
FIND_PACKAGE(XMU REQUIRED)
FIND_PACKAGE(Motif REQUIRED)
FIND_PACKAGE(Motif)
FIND_PACKAGE(GLEW)
FIND_PACKAGE(epoxy)
FIND_LIBRARY(MATH_LIBRARY m)

option(USE_GTK4 "Use GTK4 for widgets instead of Motif/Xaw" OFF)
if (USE_GTK4)
FIND_PACKAGE(PkgConfig REQUIRED)
pkg_check_modules(GTK4 REQUIRED gtk4)
else()
if(NOT Motif_FOUND)
message(FATAL_ERROR "Motif not found but USE_GTK4 is OFF. You must have Motif installed.")
endif()
endif()

if (APPLE)
set(CMAKE_C_COMPILER gcc)
set(CMAKE_C_COMPILER_ID GNU)
Expand Down Expand Up @@ -50,8 +60,12 @@ add_definitions(-g)
# add_definitions(-DDEBUGINP)
#add_definitions(-DDEBUGCL)
#
# use Motif widgets rather than Xaw
add_definitions(-DMOTIF)
# use Motif or GTK4 widgets rather than Xaw
if(USE_GTK4)
add_definitions(-DGTK4_EXT)
else()
add_definitions(-DMOTIF)
endif()

# use GLEW or epoxy
if (USE_GLEW)
Expand All @@ -65,15 +79,23 @@ endif()
# gl2ps
FIND_PATH(GL2PS_INCLUDE_DIR gl2ps.h)
FIND_LIBRARY(GL2PS_LIBRARY NAMES gl2ps)
add_definitions(-DGLEW)
set (GL_INCLUDES ${GL2PS_INCLUDE_DIR})
if (GL2PS_INCLUDE_DIR)
list(APPEND GL_INCLUDES ${GL2PS_INCLUDE_DIR})
endif()

message(STATUS "GL Includes=${GL_INCLUDES}")
include_directories(${X11_INCLUDE_DIR} ${MOTIF_INCLUDE_DIR} ${GL_INCLUDES})
if (USE_GTK4)
include_directories(${X11_INCLUDE_DIR} ${GTK4_INCLUDE_DIRS} ${GL_INCLUDES})
SET(CMAKE_C_FLAGS "$ENV{CFLAGS} -DGTK4_EXT -g -O0 -fPIC -Wno-deprecated-non-prototype")
SET(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -DGTK4_EXT -g -O0 -fPIC -Wno-deprecated-non-prototype")
SET(CMAKE_Fortran_FLAGS "$ENV{FFLAGS} -DGTK4_EXT -finit-local-zero -g -O0 -fPIC")
else()
include_directories(${X11_INCLUDE_DIR} ${MOTIF_INCLUDE_DIR} ${GL_INCLUDES})
SET(CMAKE_C_FLAGS "$ENV{CFLAGS} -DMOTIF -g -O0 -fPIC -Wno-deprecated-non-prototype")
SET(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -DMOTIF -g -O0 -fPIC -Wno-deprecated-non-prototype")
SET(CMAKE_Fortran_FLAGS "$ENV{FFLAGS} -DMOTIF -finit-local-zero -g -O0 -fPIC")
endif()

SET(CMAKE_C_FLAGS "$ENV{CFLAGS} -DMOTIF -g -O0 -fPIC -Wno-deprecated-non-prototype")
SET(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -DMOTIF -g -O0 -fPIC -Wno-deprecated-non-prototype")
SET(CMAKE_Fortran_FLAGS "$ENV{FFLAGS} -DMOTIF -finit-local-zero -g -O0 -fPIC")

SET(CMAKE_EXE_LINKER_FLAGS $ENV{LDFLAGS})
if (OPENPHIGS_FORCE_32)
Expand All @@ -98,11 +120,17 @@ INCLUDE_DIRECTORIES(
set (XLIBS "")
endif()

if (USE_GTK4)
set(UI_LIBRARIES ${GTK4_LIBRARIES})
else()
set(UI_LIBRARIES ${MOTIF_LIBRARIES})
endif()

if (USE_GLEW)
SET(PHIGS_LIBRARIES
phigs
${XLIBS}
${MOTIF_LIBRARIES}
${UI_LIBRARIES}
${XMU_LIBRARY}
${PNG_LIBRARY}
${X11_Xaw_LIB}
Expand All @@ -117,7 +145,7 @@ else()
SET(PHIGS_LIBRARIES
phigs
${XLIBS}
${MOTIF_LIBRARIES}
${UI_LIBRARIES}
${XMU_LIBRARY}
${PNG_LIBRARY}
${X11_Xaw_LIB}
Expand Down
11 changes: 11 additions & 0 deletions src/include/phigs/private/wsglP.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,17 @@ extern "C" {
*/
void wsgl_clear_geometry();

/*******************************************************************************
/*******************************************************************************
* wsgl_set_transparency_pass
*
* DESCR: Set the transparency pass and update HLHSR depth mask.
* RETURNS: N/A
*/
void wsgl_set_transparency_pass(Ws *ws, int pass);

extern int wsgl_current_transparency_pass;

/*******************************************************************************
* wsgl_init
*
Expand Down
17 changes: 17 additions & 0 deletions src/include/phigs/sin.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,22 @@ SOFTWARE.

#include <sys/types.h>
#include <X11/Xlib.h>
#ifdef GTK4_EXT
#include <gtk/gtk.h>
#ifndef OPENPHIGS_GTK4_TYPES_DEFINED
#define OPENPHIGS_GTK4_TYPES_DEFINED
typedef void* XtAppContext;
typedef GtkWidget* Widget;
typedef void* XtPointer;
typedef unsigned int Cardinal;
typedef char* String;
typedef void* Arg;
typedef void* ArgList;
typedef unsigned long XtArgVal;
#endif
#else
#include <X11/Intrinsic.h>
#endif

#include "phigs.h"
#include "ws_type.h"
Expand Down Expand Up @@ -391,8 +406,10 @@ extern void phg_sin_sample();
*/

/* Xt action procs for input. */
#ifndef GTK4_EXT
extern XtActionProc phg_sin_xt_request_satisfied(Widget);
extern XtActionProc phg_sin_xt_string_event(Widget, XEvent*, String *, Cardinal*);
#endif

#define SIN_CLASS_INDEX(_class) \
((int)(_class))
Expand Down
15 changes: 15 additions & 0 deletions src/include/phigs/ws.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,22 @@ SOFTWARE.

#include <stdio.h>
#include <X11/Xlib.h>
#ifdef GTK4_EXT
#include <gtk/gtk.h>
#ifndef OPENPHIGS_GTK4_TYPES_DEFINED
#define OPENPHIGS_GTK4_TYPES_DEFINED
typedef void* XtAppContext;
typedef GtkWidget* Widget;
typedef void* XtPointer;
typedef unsigned int Cardinal;
typedef char* String;
typedef void* Arg;
typedef void* ArgList;
typedef unsigned long XtArgVal;
#endif
#else
#include <X11/Intrinsic.h>
#endif
#include <GL/glx.h>

#include "phigs.h"
Expand Down
38 changes: 35 additions & 3 deletions src/libphigs/cp/cpm_tlkt.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,17 @@ SOFTWARE.

******************************************************************/
#include <stdio.h>
#ifndef GTK4_EXT
#include <X11/StringDefs.h>
#ifndef GTK4_EXT
#include <X11/Shell.h>
#endif
#endif
#include "phg.h"
#include "ws.h"
#include "sin.h"

#ifndef GTK4_EXT
/* TODO: Fill in the real options. */
static XrmOptionDescRec options[] = {
{"-horiz", "scrollbar.orientation", XrmoptionNoArg, "horizontal"}
Expand Down Expand Up @@ -300,15 +305,19 @@ static XtActionsRec actions[] = {
};

XContext phg_sin_device_context_id;
#endif

/* No need for a "destroy_toolkit function since all the resources are
* destroyed when the PM terminates.
*/

XtAppContext phg_cpm_init_toolkit( int argc, char **argv )
{
XtAppContext app_con;
XtAppContext app_con = NULL;

#ifdef GTK4_EXT
gtk_init();
#else
XtToolkitInitialize();
#ifdef DEBUGINP
printf("Initialising Xt Toolkit\n");
Expand All @@ -321,27 +330,36 @@ XtAppContext phg_cpm_init_toolkit( int argc, char **argv )
XtAppAddActions( app_con, actions, XtNumber(actions) );
phg_sin_device_context_id = XUniqueContext();
}
#endif
return app_con;
}

Widget phg_cpm_toolkit_add_connection( XtAppContext context, Display* display, Pint* err )
{
int argc = 0, status = 0;
char **argv = (char **)NULL;
Widget top_level;
Widget top_level = NULL;

*err = 0;
#ifdef GTK4_EXT
/* In GTK4, Display connection is handled by gtk_init() or implicitly. */
/* We can create a dummy or invisible top-level window if needed, but
* OpenPHIGS handles GLX on X11 windows directly. We just need to return
* a valid pointer to indicate success if the caller checks it. */
top_level = (Widget)gtk_window_new();
#else
/* TODO: XtDisplayInitialize destroys the arg vector, but we need to
* keep it for the next display initialized. So copy it to scratch
* space then pass the copy.
*/
*err = 0;
XtDisplayInitialize( context, display,
"Workstation", NULL, NULL, 0,
&argc, argv );
top_level = XtVaAppCreateShell( NULL, NULL, applicationShellWidgetClass,
display, NULL );
if (top_level == NULL)
*err = ERRN204;
#endif
return top_level;
}

Expand All @@ -354,16 +372,30 @@ int phg_cpm_toolkit_open_ws( Ws *ws ) {
#endif
status = 0;
sprintf( buf, "workstation%d", ws->id );
#ifdef GTK4_EXT
ws->shell = (Widget)gtk_window_new();
if (ws->shell == NULL){
status = 1;
}
#else
ws->shell = XtVaCreatePopupShell( buf, applicationShellWidgetClass,
ws->top_level, NULL);
if (ws->shell == NULL){
printf("Failed to create shell for %s! Top_level was %ld\n", buf, (long)ws->top_level);
status = 1;
}
#endif

return status;
}

void phg_cpm_toolkit_close_ws( Ws *ws ) {
#ifdef GTK4_EXT
if (ws->shell) {
gtk_window_destroy(GTK_WINDOW(ws->shell));
ws->shell = NULL;
}
#else
XtDestroyWidget( ws->shell );
#endif
}
22 changes: 21 additions & 1 deletion src/libphigs/input/sin_cho.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,21 @@ SOFTWARE.
#include "sin.h"
#include "private/sinP.h"

#ifndef GTK4_EXT
#include <X11/StringDefs.h>
#include <X11/Shell.h>
#endif
#ifdef MOTIF
#include <stdbool.h>
#include <Xm/Frame.h>
#include <Xm/ToggleB.h>
#include <Xm/RowColumn.h>
#else
#ifndef GTK4_EXT
#include <X11/Xaw/Viewport.h>
#include <X11/Xaw/List.h>
#endif
#endif
/*******************************************************************************
* choice_notify
*
Expand Down Expand Up @@ -167,7 +171,19 @@ static void enable_choice(
sprintf( buf, "choice%d", device->num );
sprintf( title, "Options:");
/* Create the containing shell. */
#ifdef MOTIF
#ifdef GTK4_EXT
if (device->item_handle.choice.shell) {
gtk_window_destroy(GTK_WINDOW(device->item_handle.choice.shell));
device->item_handle.choice.shell = NULL;
}
device->item_handle.choice.shell = (Widget)gtk_window_new();
gtk_window_set_title(GTK_WINDOW(device->item_handle.choice.shell), title);
GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
gtk_window_set_child(GTK_WINDOW(device->item_handle.choice.shell), box);
device->item_handle.choice.list = (Widget)gtk_list_box_new();
gtk_box_append(GTK_BOX(box), (GtkWidget*)device->item_handle.choice.list);
w = device->item_handle.choice.list;
#elif defined(MOTIF)
device->item_handle.choice.shell =
XtVaCreatePopupShell( buf, applicationShellWidgetClass,
parent,
Expand Down Expand Up @@ -230,10 +246,14 @@ static void enable_choice(
XtNcallback, choice_notify, (XtPointer)device );
#endif

#ifdef GTK4_EXT
gtk_window_present(GTK_WINDOW(device->item_handle.choice.shell));
#else
XtPopup( device->item_handle.choice.shell, XtGrabNone );
if ( device->mode == SIN_REQUEST_PENDING )
XSaveContext( XtDisplay(w), XtWindow(w), phg_sin_device_context_id,
(caddr_t)device );
#endif
#ifdef DEBUGINP
printf("Enabling choice finished\n");
#endif
Expand Down
Loading
Loading