| 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 ); |
|---|
| 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 ); |
|---|
| 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 |
|---|