Exemple #1
0
        /// <summary> Register a  "configure notify action" to application context, translate the "configure notify action", add/overwrite
        /// the shell widget's translation table and set windows manager protocol hook for the shell widget. </summary>
        /// <param name="appContext">  The application's context to register the action to.  <see cref="System.IntPtr"/> </param>
        /// <param name="configureNotifyAction"> The action to register to the application's context. <see cref="XtActionProc"/> </param>
        /// <remarks> This method can be called *** BEFORE *** XtRealizeWidget (). </remarks>
        public void RegisterConfigureNotifyAction(IntPtr appContext, XtActionProc configureNotifyAction)
        {
            try
            {
                // Register (instance method) action procedure to runtime action marshaller and let it map the signal to the (global static) action procedure.
                IntPtr configureNotifyActionPtr = ActionMarshaler.Add(_shell, X11.XEventName.ConfigureNotify, configureNotifyAction);

                // Create an actions record, to provide the application's context with a "action-name" to "action-procedure" translation.
                XtActionsRec[] actionProcs = new XtActionsRec[] {
                    new XtActionsRec(X11Utils.StringToSByteArray(XtWmShell.COFIGURE_NOTIFY_ACTION_NAME + "\0"), configureNotifyActionPtr)
                };

                // Register the actions record to the application's context.
                Xtlib.XtAppAddActions(appContext, actionProcs, (XCardinal)1);

                // Create a compiled translation table, to provide the widget with a "message" to "action-name" translation.
                IntPtr translationTable = Xtlib.XtParseTranslationTable("<Configure>: " + XtWmShell.COFIGURE_NOTIFY_ACTION_NAME + "()");

                // Merge new translations to the widget, overriding existing ones.
                Xtlib.XtOverrideTranslations(_shell, translationTable);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
        }
Exemple #2
0
        /// <summary> Register a "delete window action" to application context, translate the "delete
        /// window action", add/overwrite the shell widget's translation table and set windows manager
        /// protocol hook for the shell widget. </summary>
        /// <param name="appContext">  The application's context to register the action to.
        /// <see cref="System.IntPtr"/> </param>
        /// <param name="deleteWindowAction"> The action to register to the application's context.
        /// <see cref="XtActionProc"/> </param>
        /// <remarks> This must be done *** AFTER *** XtRealizeWidget (). </remarks>
        public void RegisterDeleteWindowAction(IntPtr appContext, XtActionProc deleteWindowAction)
        {
            try
            {
                // Register (instance method) action procedure to runtime action marshaller
                // and let it map the signal to the (global static) action procedure.
                IntPtr deleteWindowActionPtr = ActionMarshaler.Add(_shell,
                                                                   X11.XEventName.ClientMessage, deleteWindowAction);

                // Create an actions record, to provide the application's context
                // with a "action-name" to "action-procedure" translation.
                XtActionsRec[] actionProcs = new XtActionsRec[] {
                    new XtActionsRec(X11Utils.StringToSByteArray(XtWmShell.DELETE_WINDOW_ACTION_NAME + "\0"),
                                     deleteWindowActionPtr)
                };

                // Register the actions record to the application's context.
                Xtlib.XtAppAddActions(appContext, actionProcs, (XCardinal)1);

                // Create a compiled translation table, to provide the widget with
                // a "message" to "action-name" translation.
                IntPtr translationTable = Xtlib.XtParseTranslationTable("<Message>WM_PROTOCOLS: " +
                                                                        XtWmShell.DELETE_WINDOW_ACTION_NAME + "()");

                // Merge new translations to the widget, overriding existing ones.
                Xtlib.XtOverrideTranslations(_shell, translationTable);

                /// The delete message from the windows manager. Closing an app via window
                /// title functionality doesn't generate a window message - it only generates a
                /// window manager message, thot must be routed to the window (message loop).
                IntPtr wmDeleteMessage = IntPtr.Zero;

                // Hook the closing event from windows manager.
                // Must be done *** AFTER *** XtRealizeWidget () to determine display and window!
                wmDeleteMessage = X11lib.XInternAtom(Xtlib.XtDisplay(_shell), "WM_DELETE_WINDOW", false);
                if (X11lib.XSetWMProtocols(Xtlib.XtDisplay(_shell), Xtlib.XtWindow(_shell),
                                           ref wmDeleteMessage, (X11.TInt) 1) == 0)
                {
                    Console.WriteLine(CLASS_NAME + "::RegisterDeleteWindowAction () " +
                                      "WARNING: Failed to register 'WM_DELETE_WINDOW' event.");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
        }
Exemple #3
0
        // ###############################################################################
        // ### M E T H O D S
        // ###############################################################################

        #region Methods

        /// <summary> Add a widget specific action registration. </summary>
        /// <param name="widget"> The widget to register the action for. <see cref="System.IntPtr"/> </param>
        /// <param name="eventType"> The event type to register the action for. <see cref="X11.XEventName"/> </param>
        /// <param name="action"> The action to execute. <see cref="XtActionProc"/> </param>
        /// <returns> The managed code to native code marshalable generic action procedure. <see cref="System.IntPtr"/> </returns>
        public static IntPtr Add(IntPtr widget, X11.XEventName eventType, XtActionProc action)
        {
            ActionKey actionKey = new ActionKey(widget, eventType);

            if (_list.ContainsKey(actionKey))
            {
                Console.WriteLine(CLASS_NAME + "::Add() WARNING: ActionProc already registered for widget. Perform refresh.");
                _list[actionKey] = action;
            }
            else
            {
                _list.Add(actionKey, action);
            }

            return(_actionPtr);
        }