Changeset 2b5d29462f7970d80c8af22aeacea8309da6d11b

Show
Ignore:
Timestamp:
29/07/03 11:32:14 (5 years ago)
Author:
Sam Hocevar <sam@videolan.org>
git-committer:
Sam Hocevar <sam@videolan.org> 1059471134 +0000
git-parent:

[8bfdb6f8e34b0f089e16dcfc4fb843909269b37a]

git-author:
Sam Hocevar <sam@videolan.org> 1059471134 +0000
Message:
  • modules/video_output/x11/xcommon.c: Hopefully a proper fix for the Mozilla
    event handling bug.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/video_output/x11/xcommon.c

    r8bfdb6f r2b5d294  
    33 ***************************************************************************** 
    44 * Copyright (C) 1998-2001 VideoLAN 
    5  * $Id: xcommon.c,v 1.24 2003/07/28 22:46:00 gbazin Exp $ 
     5 * $Id: xcommon.c,v 1.25 2003/07/29 09:32:14 sam Exp $ 
    66 * 
    77 * Authors: Vincent Seguin <seguin@via.ecp.fr> 
     
    912912    XEvent                  xevent; 
    913913 
    914     vlc_bool_t              b_expose
    915     vlc_bool_t              b_configure_notify
    916     vlc_bool_t              b_map_notify
     914    vlc_bool_t              b_expose = VLC_FALSE
     915    vlc_bool_t              b_configure_notify = VLC_FALSE
     916    vlc_bool_t              b_map_notify = VLC_FALSE
    917917 
    918918    vlc_value_t             val; 
     
    940940    if( !i_drawable ) 
    941941    { 
    942         p_win->b_owned = VLC_TRUE; 
    943  
    944942        /* Create the window and set hints - the window must receive 
    945943         * ConfigureNotify events, and until it is displayed, Expose and 
     
    976974    else 
    977975    { 
    978         p_win->b_owned = VLC_FALSE; 
    979         p_win->base_window = i_drawable; 
    980  
    981         XChangeWindowAttributes( p_vout->p_sys->p_display, 
    982                                  p_win->base_window, 
    983                                  CWBackingStore | CWBackPixel | CWEventMask, 
    984                                  &xwindow_attributes ); 
     976        /* Get the parent window's geometry information */ 
     977        Window dummy1; 
     978        unsigned int dummy2, dummy3; 
     979        XGetGeometry( p_vout->p_sys->p_display, i_drawable, 
     980                      &dummy1, &dummy2, &dummy3, 
     981                      &p_win->i_width, 
     982                      &p_win->i_height, 
     983                      &dummy2, &dummy3 ); 
     984 
     985        /* We are already configured */ 
     986        b_configure_notify = VLC_TRUE; 
     987 
     988        /* From man XSelectInput: only one client at a time can select a 
     989         * ButtonPress event, so we need to open a new window anyway. */ 
     990        p_win->base_window = 
     991            XCreateWindow( p_vout->p_sys->p_display, 
     992                           i_drawable, 
     993                           0, 0, 
     994                           p_win->i_width, p_win->i_height, 
     995                           0, 
     996                           0, CopyFromParent, 0, 
     997                           CWBackingStore | CWBackPixel | CWEventMask, 
     998                           &xwindow_attributes ); 
    985999    } 
    9861000 
     
    10011015                           GCGraphicsExposures, &xgcvalues ); 
    10021016 
    1003     if( p_win->b_owned ) 
    1004     { 
    1005         /* Send orders to server, and wait until window is displayed - three 
    1006          * events must be received: a MapNotify event, an Expose event allowing 
    1007          * drawing in the window, and a ConfigureNotify to get the window 
    1008          * dimensions. Once those events have been received, only 
    1009          * ConfigureNotify events need to be received. */ 
    1010         b_expose = 0; 
    1011         b_configure_notify = 0; 
    1012         b_map_notify = 0; 
    1013         XMapWindow( p_vout->p_sys->p_display, p_win->base_window ); 
    1014         do 
    1015         { 
    1016             XNextEvent( p_vout->p_sys->p_display, &xevent); 
    1017             if( (xevent.type == Expose) 
    1018                 && (xevent.xexpose.window == p_win->base_window) ) 
    1019             { 
    1020                 b_expose = 1; 
    1021             } 
    1022             else if( (xevent.type == MapNotify) 
    1023                      && (xevent.xmap.window == p_win->base_window) ) 
    1024             { 
    1025                 b_map_notify = 1; 
    1026             } 
    1027             else if( (xevent.type == ConfigureNotify) 
    1028                      && (xevent.xconfigure.window == p_win->base_window) ) 
    1029             { 
    1030                 b_configure_notify = 1; 
    1031                 p_win->i_width = xevent.xconfigure.width; 
    1032                 p_win->i_height = xevent.xconfigure.height; 
    1033             } 
    1034         } while( !( b_expose && b_configure_notify && b_map_notify ) ); 
    1035     } 
    1036     else 
    1037     { 
    1038         /* Get the window's geometry information */ 
    1039         Window dummy1; 
    1040         unsigned int dummy2, dummy3; 
    1041         XGetGeometry( p_vout->p_sys->p_display, p_win->base_window, 
    1042                       &dummy1, &dummy2, &dummy3, 
    1043                       &p_win->i_width, 
    1044                       &p_win->i_height, 
    1045                       &dummy2, &dummy3 ); 
    1046     } 
    1047  
    1048     /* When we don't own the window we cannot put ButtonPressMask in the list, 
    1049      * because according to the XSelectInput manpage, only one client at a 
    1050      * time can select a ButtonPress event. Programs such as Mozilla may be 
    1051      * already selecting this event. */ 
    1052     if( p_win->b_owned ) 
    1053         XSelectInput( p_vout->p_sys->p_display, p_win->base_window, 
    1054                       StructureNotifyMask | KeyPressMask | 
    1055                       ButtonPressMask | ButtonReleaseMask | 
    1056                       PointerMotionMask ); 
    1057     else 
    1058         XSelectInput( p_vout->p_sys->p_display, p_win->base_window, 
    1059                       StructureNotifyMask ); 
     1017    /* Send orders to server, and wait until window is displayed - three 
     1018     * events must be received: a MapNotify event, an Expose event allowing 
     1019     * drawing in the window, and a ConfigureNotify to get the window 
     1020     * dimensions. Once those events have been received, only 
     1021     * ConfigureNotify events need to be received. */ 
     1022    XMapWindow( p_vout->p_sys->p_display, p_win->base_window ); 
     1023    do 
     1024    { 
     1025        XNextEvent( p_vout->p_sys->p_display, &xevent); 
     1026        if( (xevent.type == Expose) 
     1027            && (xevent.xexpose.window == p_win->base_window) ) 
     1028        { 
     1029            b_expose = VLC_TRUE; 
     1030        } 
     1031        else if( (xevent.type == MapNotify) 
     1032                 && (xevent.xmap.window == p_win->base_window) ) 
     1033        { 
     1034            b_map_notify = VLC_TRUE; 
     1035        } 
     1036        else if( (xevent.type == ConfigureNotify) 
     1037                 && (xevent.xconfigure.window == p_win->base_window) ) 
     1038        { 
     1039            b_configure_notify = VLC_TRUE; 
     1040            p_win->i_width = xevent.xconfigure.width; 
     1041            p_win->i_height = xevent.xconfigure.height; 
     1042        } 
     1043    } while( !( b_expose && b_configure_notify && b_map_notify ) ); 
     1044 
     1045    XSelectInput( p_vout->p_sys->p_display, p_win->base_window, 
     1046                  StructureNotifyMask | KeyPressMask | 
     1047                  ButtonPressMask | ButtonReleaseMask | 
     1048                  PointerMotionMask ); 
    10601049 
    10611050#ifdef MODULE_NAME_IS_x11 
    1062     if( p_win->b_owned && 
    1063          XDefaultDepth(p_vout->p_sys->p_display, p_vout->p_sys->i_screen) == 8 ) 
     1051    if( XDefaultDepth(p_vout->p_sys->p_display, p_vout->p_sys->i_screen) == 8 ) 
    10641052    { 
    10651053        /* Allocate a new palette */ 
     
    11291117    XFreeGC( p_vout->p_sys->p_display, p_win->gc ); 
    11301118 
    1131     if( p_win->b_owned ) 
    1132     { 
    1133         XUnmapWindow( p_vout->p_sys->p_display, p_win->base_window ); 
    1134         XDestroyWindow( p_vout->p_sys->p_display, p_win->base_window ); 
    1135     } 
     1119    XUnmapWindow( p_vout->p_sys->p_display, p_win->base_window ); 
     1120    XDestroyWindow( p_vout->p_sys->p_display, p_win->base_window ); 
    11361121} 
    11371122 
     
    14121397            config_GetInt( p_vout, MODULE_STRING "-altfullscreen" ); 
    14131398 
    1414         if( p_vout->p_sys->p_win->b_owned ) 
    1415         { 
    1416             XUnmapWindow( p_vout->p_sys->p_display, 
    1417                           p_vout->p_sys->p_win->base_window); 
    1418         } 
     1399        XUnmapWindow( p_vout->p_sys->p_display, 
     1400                      p_vout->p_sys->p_win->base_window); 
    14191401 
    14201402        p_vout->p_sys->p_win = &p_vout->p_sys->fullscreen_window; 
     
    15261508        p_vout->p_sys->p_win = &p_vout->p_sys->original_window; 
    15271509 
    1528         if( p_vout->p_sys->p_win->b_owned ) 
    1529         { 
    1530             XMapWindow( p_vout->p_sys->p_display, 
    1531                         p_vout->p_sys->p_win->base_window); 
    1532         } 
     1510        XMapWindow( p_vout->p_sys->p_display, 
     1511                    p_vout->p_sys->p_win->base_window); 
    15331512    } 
    15341513 
     
    15371516     * has not necessarily been sent directly to our window (remember, 
    15381517     * the call is first redirected to the window manager) */ 
    1539     if( p_vout->p_sys->p_win->b_owned ) 
    1540     { 
    1541         do 
    1542         { 
    1543             XWindowEvent( p_vout->p_sys->p_display, 
    1544                           p_vout->p_sys->p_win->base_window, 
    1545                           StructureNotifyMask, &xevent ); 
    1546         } while( xevent.type != MapNotify ); 
    1547     } 
    1548     else 
    1549     { 
    1550         XSync( p_vout->p_sys->p_display, False ); 
    1551     } 
    1552  
    1553     /* Becareful, this can generate a BadMatch error if the window is not 
     1518    do 
     1519    { 
     1520        XWindowEvent( p_vout->p_sys->p_display, 
     1521                      p_vout->p_sys->p_win->base_window, 
     1522                      StructureNotifyMask, &xevent ); 
     1523    } while( xevent.type != MapNotify ); 
     1524 
     1525    /* Be careful, this can generate a BadMatch error if the window is not 
    15541526     * already mapped by the server (see above) */ 
    15551527    XSetInputFocus(p_vout->p_sys->p_display, 
  • modules/video_output/x11/xcommon.h

    re1dd3aa r2b5d294  
    33 ***************************************************************************** 
    44 * Copyright (C) 1998-2001 VideoLAN 
    5  * $Id: xcommon.h,v 1.6 2003/07/28 18:02:06 massiot Exp $ 
     5 * $Id: xcommon.h,v 1.7 2003/07/29 09:32:14 sam Exp $ 
    66 * 
    77 * Authors: Vincent Seguin <seguin@via.ecp.fr> 
     
    7070    Atom                wm_protocols; 
    7171    Atom                wm_delete_window; 
    72  
    73     vlc_bool_t          b_owned;                   /* do we own this window? */ 
    7472 
    7573#ifdef HAVE_XINERAMA