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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/g4tools/include/toolx/Xt/session (Version 11.3.0) and /externals/g4tools/include/toolx/Xt/session (Version 11.1.3)


  1 // Copyright (C) 2010, Guy Barrand. All rights      1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  2 // See the file tools.license for terms.            2 // See the file tools.license for terms.
  3                                                     3 
  4 #ifndef toolx_Xt_session                            4 #ifndef toolx_Xt_session
  5 #define toolx_Xt_session                            5 #define toolx_Xt_session
  6                                                     6 
                                                   >>   7 #include <ostream>
                                                   >>   8 
  7 #include <X11/Intrinsic.h>                          9 #include <X11/Intrinsic.h>
  8 #include <X11/Shell.h>                             10 #include <X11/Shell.h>
  9 #include <X11/StringDefs.h>                        11 #include <X11/StringDefs.h>
 10                                                    12 
 11 #include <ostream>                             << 
 12                                                << 
 13 namespace toolx {                                  13 namespace toolx {
 14 namespace Xt {                                     14 namespace Xt {
 15                                                    15 
 16 class session {                                    16 class session {
 17 public:                                            17 public:
 18   session(std::ostream& a_out)                 << 
 19   :m_out(a_out),m_app_context(0),m_app_widget( << 
 20   {}                                           << 
 21   session(std::ostream& a_out,XtAppContext a_a << 
 22   :m_out(a_out),m_app_context(a_app_context),m << 
 23   {}                                           << 
 24   session(std::ostream& a_out,int& a_argc,char     18   session(std::ostream& a_out,int& a_argc,char** a_argv)
 25   :m_out(a_out),m_app_context(0),m_app_widget( <<  19   :m_out(a_out),m_app_context(0),m_app_widget(0)
 26   {                                                20   {
 27   //LookDSM_Problem();                             21   //LookDSM_Problem();
 28     Arg args[1];                                   22     Arg args[1];
 29     XtSetArg(args[0],XtNgeometry,XtNewString("     23     XtSetArg(args[0],XtNgeometry,XtNewString("100x100"));
 30     m_app_widget = ::XtAppInitialize(&m_app_co     24     m_app_widget = ::XtAppInitialize(&m_app_context,"toolx::Xt::session",NULL,(Cardinal)0,&a_argc,a_argv,NULL,args,1);
 31     if(!m_app_context || !m_app_widget) {          25     if(!m_app_context || !m_app_widget) {
 32       m_app_context = 0;                           26       m_app_context = 0;
 33       m_app_widget = 0;                            27       m_app_widget = 0;
 34       m_app_owner = false;                     << 
 35       return;                                  << 
 36     }                                              28     }
 37     m_app_owner = true;                        << 
 38   }                                                29   }
 39   virtual ~session() {                             30   virtual ~session() {
 40     if(m_app_owner) {                          <<  31     if(m_app_widget) {::XtDestroyWidget(m_app_widget);m_app_widget = 0;}
 41       if(m_app_widget) {::XtDestroyWidget(m_ap <<  32     if(m_app_context) {::XtDestroyApplicationContext(m_app_context);m_app_context = 0;}
 42       if(m_app_context) {::XtDestroyApplicatio << 
 43     }                                          << 
 44   }                                                33   }
 45 protected:                                         34 protected:
 46   session(const session& a_from)                   35   session(const session& a_from)
 47   :m_out(a_from.m_out),m_app_context(0),m_app_ <<  36   :m_out(a_from.m_out),m_app_context(0),m_app_widget(0)
 48   {}                                               37   {}
 49   session& operator=(const session&){return *t     38   session& operator=(const session&){return *this;}
 50 public:                                            39 public:
 51   std::ostream& out() const {return m_out;}        40   std::ostream& out() const {return m_out;}
 52   bool is_valid() {return m_app_context && m_a     41   bool is_valid() {return m_app_context && m_app_widget?true:false;}
 53   bool steer() {                                   42   bool steer() {
 54     if(!m_app_context) return false;               43     if(!m_app_context) return false;
 55     while(true) {                                  44     while(true) {
 56       XEvent event;                                45       XEvent event;
 57       ::XtAppNextEvent(m_app_context,&event);      46       ::XtAppNextEvent(m_app_context,&event);
 58       ::XtDispatchEvent(&event);                   47       ::XtDispatchEvent(&event);
 59       //if(m_exit) break;                          48       //if(m_exit) break;
 60     }                                              49     }
 61     return true;                                   50     return true;
 62   }                                                51   }
 63   bool sync() {                                    52   bool sync() {
 64   //if(!m_app_widget) return false;                53   //if(!m_app_widget) return false;
 65   //Display* display = XtDisplay(m_app_widget)     54   //Display* display = XtDisplay(m_app_widget);
 66   //::XSync(display,False);                        55   //::XSync(display,False);
 67     if(!m_app_context) return false;               56     if(!m_app_context) return false;
 68     while(true) {                                  57     while(true) { 
 69       XtInputMask input = ::XtAppPending(m_app     58       XtInputMask input = ::XtAppPending(m_app_context);
 70       if(input==0) break;                          59       if(input==0) break;
 71       XEvent event;                                60       XEvent event;
 72       ::XtAppNextEvent(m_app_context,&event);      61       ::XtAppNextEvent(m_app_context,&event);
 73       ::XtDispatchEvent(&event);                   62       ::XtDispatchEvent(&event);        
 74     }                                              63     }
 75     return true;                                   64     return true;
 76   }                                                65   }
 77 public:                                            66 public:
 78   Widget get_app_widget() {return m_app_widget     67   Widget get_app_widget() {return m_app_widget;}
 79 protected:                                         68 protected:
 80   std::ostream& m_out;                             69   std::ostream& m_out;
                                                   >>  70   bool m_app_owner;
 81   XtAppContext m_app_context;                      71   XtAppContext m_app_context;
 82   Widget m_app_widget;                             72   Widget m_app_widget;  
 83   bool m_app_owner;                            << 
 84 };                                                 73 };
 85                                                    74 
 86 }}                                                 75 }}
 87                                                << 
 88                                                    76 
 89 #endif                                             77 #endif