PreviousUpNext

15.4.1536  src/lib/x-kit/widget/old/lib/run-in-x-window-old.pkg

## run-in-x-window-old.pkg
#
# This package provides a higher-level interface to invoking applications.
# Users may set the shell variable "DISPLAY" to specify the display connection.

# Compiled by:
#     src/lib/x-kit/widget/xkit-widget.sublib






###                  "There should be no such thing as boring mathematics."
###
###                                           -- E.J. Dijkstra

stipulate
    include package   threadkit;                                                        # threadkit                     is from   src/lib/src/lib/thread-kit/src/core-thread-kit/threadkit.pkg
    #
    package fil =  file__premicrothread;                                                # file__premicrothread          is from   src/lib/std/src/posix/file--premicrothread.pkg
    package wg  =  widget;                                                              # widget                        is from   src/lib/x-kit/widget/old/basic/widget.pkg
    package xc  =  xclient;                                                             # xclient                       is from   src/lib/x-kit/xclient/xclient.pkg
herein

    package   run_in_x_window_old
    : (weak)  Run_In_X_Window_Old                                                       # Run_In_X_Window_Old           is from   src/lib/x-kit/widget/old/lib/run-in-x-window-old.api
    {
                                                                                        # thread_scheduler_control_g    is from   src/lib/src/lib/thread-kit/src/glue/thread-scheduler-control-g.pkg
        fun make_root_window
                display_or_null                                                         # Allow overriding of the DISPLAY environment variable setting.
            =
            {   (xc::get_xdisplay_string_and_xauthentication  display_or_null)
                    ->
                    ( xdisplay,                                                         # Typically from $DISPLAY environment variable.
                      xauthentication:  Null_Or(xc::Xauthentication)                    # Typically from ~/.Xauthority
                    );
                    

                wg::make_root_window (xdisplay, xauthentication)                        # make_root_window is nominally from  src/lib/x-kit/widget/old/basic/widget.pkg   but actually from   src/lib/x-kit/widget/old/basic/root-window-old.pkg
                except
                    x as xclient::XSERVER_CONNECT_ERROR s
                        =
                        {   fil::write
                                ( fil::stderr,
                                  string::cat
                                    [ "run_in_x_window_old: unable to open display \"",   xdisplay,   "\"\n",
                                      "  ",   s,   "\n"
                                    ]
                                );

                            raise exception x;  
#                           shut_down_thread_scheduler  winix::process::failure;        # No longer kosher since 6.3
                        };
              };

        fun run_in_x_window_old  do_it
            =
            {
                {   do_it (make_root_window NULL);
                    #
                    winix__premicrothread::process::success;
                }
                except
                    _ = winix__premicrothread::process::failure;

                ();
            };

        Run_In_X_Window_Old_Options
          #
          = DISPLAY String                                                              # Connect to this display. String is as in DISPLAY environment var: "127.0.0.1:0.0" or such.  Value of "" will be ignored.
          ;

        fun run_in_x_window_old' app (options:  List(Run_In_X_Window_Old_Options))
            =
            run_in_x_window_old'' (options, NULL: Null_Or(String))
            where
                fun run_in_x_window_old'' ((DISPLAY "" ! rest), display_or_null)
                        =>
                        run_in_x_window_old'' (rest, display_or_null);                  # Ignore DISPLAY values of "".

                    run_in_x_window_old'' ((DISPLAY display ! rest), display_or_null)
                        =>
                        run_in_x_window_old'' (rest, THE display);                              # Note DISPLAY value.

                    run_in_x_window_old'' ([], display_or_null)
                        => 
                        {   {   app (make_root_window display_or_null);
                                #
                                winix__premicrothread::process::success;
                            }
                            except  _ = winix__premicrothread::process::failure;

                            ();
                        };
                end;
            end;

    };                                                                          # package run_in_x_window_old 

end;


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext