Changeset 8278 for trunk

Show
Ignore:
Timestamp:
05/12/11 11:50:35 (6 months ago)
Author:
westram
Message:
  • fix ARB<>Unity incompatibilities
    • buttons of freshly generated ARB windows were clickable, but nothing happened when clicked.
      • Slightly moving the window or otherwise triggering an expose-callback fixed that behavior, but only for this window.
    • changes for this fix
      • the hack to calculate the WM-offsets failed, since unity does not provide the already-set, but not yet exposed window-position
        • assume that the values in awars are correct and use them to set position (again)
      • unity forgets window position when hiding a window. ARB did not restore the previously used position and button again where w/o effect. fixed by:
        • store position on hide
        • always set position in show_internal
Location:
trunk/WINDOW
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/WINDOW/AW_nawar.cxx

    r8103 r8278  
    619619        error = GB_push_transaction(gb_main); 
    620620        if (!error) { 
    621             aw_update_awar_window_geometry(this); 
     621            aw_update_all_window_geometry_awars(this); 
    622622            error = GB_pop_transaction(gb_main); 
    623623            if (!error) error = GB_save_in_arbprop(gb_main, filename, "a"); 
  • trunk/WINDOW/AW_window.cxx

    r8271 r8278  
    601601#define aw_awar_name_height(aww) aw_size_awar_name((aww), "height") 
    602602 
    603 static void aw_calculate_WM_offsets(AW_window *aww) { 
    604     if (p_aww(aww)->WM_top_offset == AW_FIX_POS_ON_EXPOSE) {        // very bad hack continued 
    605         // get last position stored in properties 
    606         AW_root *root  = aww->get_root(); 
    607         int      oposx = root->awar(aw_awar_name_posx(aww))->read_int(); 
    608         int      oposy = root->awar(aw_awar_name_posy(aww))->read_int(); 
    609  
    610         // get current window position 
    611         short            posy, posx; 
    612         AW_window_Motif *motif = p_aww(aww); 
    613         XtVaGetValues(motif->shell,  XmNx, &posx, XmNy, &posy, NULL); 
    614  
    615         // calculate offset 
    616         motif->WM_top_offset  = posy-oposy; 
    617         motif->WM_left_offset = posx-oposx; 
    618  
    619 #if defined(DEBUG) && 0 
    620         printf("aw_calculate_WM_offsets: WM_left_offset=%i WM_top_offset=%i\n", motif->WM_left_offset, motif->WM_top_offset); 
    621 #endif // DEBUG 
    622     } 
    623  
    624 #if defined(DEBUG) && 0 
    625     { 
    626         short posx, posy; 
    627         AW_window_Motif *motif = p_aww(aww); 
    628         XtVaGetValues(motif->shell,  XmNx, &posx, XmNy, &posy, NULL); 
    629         printf("[expose] Position reported by motif: %i/%i\n", posx, posy); 
    630     } 
    631 #endif // DEBUG 
     603static void aw_onExpose_calc_WM_offsets(AW_window *aww) { 
     604    if (p_aww(aww)->WM_top_offset != AW_CALC_OFFSET_ON_EXPOSE) return; // @@@ remove me when using called-once-expose-callbacks 
     605    aw_assert(p_aww(aww)->WM_top_offset == AW_CALC_OFFSET_ON_EXPOSE); 
     606 
     607    // get last position stored in properties 
     608    AW_root *root  = aww->get_root(); 
     609    int      oposx = root->awar(aw_awar_name_posx(aww))->read_int(); 
     610    int      oposy = root->awar(aw_awar_name_posy(aww))->read_int(); 
     611 
     612    AW_window_Motif *motif = p_aww(aww); 
     613 
     614    int posx, posy; 
     615    aww->get_window_pos(posx, posy); 
     616 
     617    if (posx == 0 && posy == 0) { // oops - motif has no idea where the window has been placed 
     618        // assume positions stored in awars are correct and use them.  
     619        // This works around problems with unclickable GUI-elements when running on 'Unity' 
     620        aww->set_window_pos(oposx, oposy); 
     621        posx = oposx; 
     622        posy = oposy; 
     623    } 
     624 
     625    // calculate offset 
     626    motif->WM_top_offset  = posy-oposy; 
     627    motif->WM_left_offset = posx-oposx; 
     628} 
     629 
     630static void aw_onExpose_setPosFromAwars(AW_window *aww) { 
     631    AW_root *root  = aww->get_root(); 
     632    int oposx = root->awar(aw_awar_name_posx(aww))->read_int(); 
     633    int oposy = root->awar(aw_awar_name_posy(aww))->read_int(); 
     634         
     635    aww->set_window_pos(oposx, oposy); 
    632636} 
    633637 
     
    16811685} 
    16821686 
    1683 static long aw_loop_get_window_geometry(const char *, long val, void *) { 
    1684     AW_window *aww = (AW_window *)val; 
    1685     short posx, posy; 
    1686  
     1687void aw_update_window_geometry_awars(AW_window *aww) { 
    16871688    AW_root *root = aww->get_root(); 
     1689 
     1690    short          posx, posy; 
    16881691    unsigned short width, height, borderwidth; 
    1689  
    16901692    XtVaGetValues(p_aww(aww)->shell,                // bad hack 
    16911693                  XmNborderWidth, &borderwidth, 
     
    16961698                  NULL); 
    16971699 
    1698     if (p_aww(aww)->WM_top_offset != AW_FIX_POS_ON_EXPOSE) { 
     1700    if (p_aww(aww)->WM_top_offset != AW_CALC_OFFSET_ON_EXPOSE) { 
    16991701        posy -= p_aww(aww)->WM_top_offset; 
    17001702    } 
    1701     posx -= p_aww(aww)->WM_left_offset; 
     1703    posx -= p_aww(aww)->WM_left_offset; // why is this not handled like posy? 
    17021704 
    17031705    if (posx<0) posx = 0; 
     
    17081710    root->awar(aw_awar_name_posx (aww))->write_int(posx); 
    17091711    root->awar(aw_awar_name_posy (aww))->write_int(posy); 
    1710  
     1712} 
     1713 
     1714static long aw_loop_get_window_geometry(const char *, long val, void *) { 
     1715    aw_update_window_geometry_awars((AW_window *)val); 
    17111716    return val; 
    17121717} 
    17131718 
    1714 void aw_update_awar_window_geometry(AW_root *awr) { 
     1719void aw_update_all_window_geometry_awars(AW_root *awr) { 
    17151720    GBS_hash_do_loop(awr->hash_for_windows, aw_loop_get_window_geometry, NULL); 
    17161721} 
     
    19521957    } 
    19531958    XtRealizeWidget(p_aww(aww)->shell); 
    1954     p_aww(aww)->WM_top_offset = AW_FIX_POS_ON_EXPOSE; 
     1959    p_aww(aww)->WM_top_offset = AW_CALC_OFFSET_ON_EXPOSE; 
    19551960} 
    19561961 
     
    31803185        } 
    31813186 
    3182         if (setPos) { 
    3183             int currx, curry; 
    3184             get_window_pos(currx, curry); 
    3185             if (currx != posx || curry != posy) { 
    3186 #if defined(DEBUG) && 0 
    3187                 printf("force position at show_internal: %i/%i\n", posx, posy); 
    3188 #endif // DEBUG 
    3189                 set_window_pos(posx, posy); 
    3190             } 
    3191         } 
     3187        if (setPos) set_window_pos(posx, posy); // @@@ try if it's better to set this via aw_onExpose_setPosFromAwars 
    31923188    } 
    31933189 
    31943190    XtPopup(p_w->shell, grab); 
    3195     if (p_w->WM_top_offset == AW_FIX_POS_ON_EXPOSE) {              // very bad hack 
    3196         set_expose_callback(AW_INFO_AREA, (AW_CB)aw_calculate_WM_offsets, 0, 0); 
     3191    if (p_w->WM_top_offset == AW_CALC_OFFSET_ON_EXPOSE) {              // very bad hack 
     3192        set_expose_callback(AW_INFO_AREA, (AW_CB)aw_onExpose_calc_WM_offsets, 0, 0); // @@@ should be removed after it was called once 
     3193    } 
     3194    else if (recalc_pos_at_show == AW_KEEP_POS) { 
     3195        set_expose_callback(AW_INFO_AREA, (AW_CB)aw_onExpose_setPosFromAwars, 0, 0); // @@@ should be removed after it was called once 
    31973196    } 
    31983197} 
     
    32103209void AW_window::hide() { 
    32113210    if (window_is_shown) { 
     3211        aw_update_window_geometry_awars(this); 
    32123212        if (hide_cb) hide_cb(this); 
    32133213        get_root()->window_hide(); 
  • trunk/WINDOW/aw_nawar.hxx

    r7623 r8278  
    9292}; 
    9393 
    94 void aw_update_awar_window_geometry(AW_root *awr); 
     94void aw_update_window_geometry_awars(AW_window *aww); // one window 
     95void aw_update_all_window_geometry_awars(AW_root *awr); // all windows 
    9596 
    9697#else 
  • trunk/WINDOW/aw_window_Xm.hxx

    r7669 r8278  
    272272 
    273273const int AW_NUMBER_OF_F_KEYS = 20; 
    274 #define AW_FIX_POS_ON_EXPOSE -12345 
     274#define AW_CALC_OFFSET_ON_EXPOSE -12345 
    275275 
    276276class AW_window_Motif : virtual Noncopyable {