Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11video.c @ 4008:a19fd8bcdd52 SDL-1.2
Fixed bug #322
Need to resync the keyboard state every time we set a video mode, since
the code in SDL_video.c is clearing the keyboard state.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 06 Jul 2007 07:45:33 +0000 |
parents | 3270e88063a2 |
children | a6264945ac52 |
comparison
equal
deleted
inserted
replaced
4007:4e4866a72905 | 4008:a19fd8bcdd52 |
---|---|
1076 XChangeWindowAttributes(SDL_Display, SDL_Window, | 1076 XChangeWindowAttributes(SDL_Display, SDL_Window, |
1077 CWBackingStore, &a); | 1077 CWBackingStore, &a); |
1078 } | 1078 } |
1079 } | 1079 } |
1080 | 1080 |
1081 /* Map them both and go fullscreen, if requested */ | |
1082 if ( ! SDL_windowid ) { | |
1083 XMapWindow(SDL_Display, SDL_Window); | |
1084 XMapWindow(SDL_Display, WMwindow); | |
1085 X11_WaitMapped(this, WMwindow); | |
1086 if ( flags & SDL_FULLSCREEN ) { | |
1087 screen->flags |= SDL_FULLSCREEN; | |
1088 X11_EnterFullScreen(this); | |
1089 } else { | |
1090 screen->flags &= ~SDL_FULLSCREEN; | |
1091 } | |
1092 } | |
1093 | |
1094 return(0); | |
1095 } | |
1096 | |
1097 static int X11_ResizeWindow(_THIS, | |
1098 SDL_Surface *screen, int w, int h, Uint32 flags) | |
1099 { | |
1100 if ( ! SDL_windowid ) { | |
1101 /* Resize the window manager window */ | |
1102 X11_SetSizeHints(this, w, h, flags); | |
1103 window_w = w; | |
1104 window_h = h; | |
1105 XResizeWindow(SDL_Display, WMwindow, w, h); | |
1106 | |
1107 /* Resize the fullscreen and display windows */ | |
1108 if ( flags & SDL_FULLSCREEN ) { | |
1109 if ( screen->flags & SDL_FULLSCREEN ) { | |
1110 X11_ResizeFullScreen(this); | |
1111 } else { | |
1112 screen->flags |= SDL_FULLSCREEN; | |
1113 X11_EnterFullScreen(this); | |
1114 } | |
1115 } else { | |
1116 if ( screen->flags & SDL_FULLSCREEN ) { | |
1117 screen->flags &= ~SDL_FULLSCREEN; | |
1118 X11_LeaveFullScreen(this); | |
1119 } | |
1120 } | |
1121 XResizeWindow(SDL_Display, SDL_Window, w, h); | |
1122 } | |
1123 return(0); | |
1124 } | |
1125 | |
1126 SDL_Surface *X11_SetVideoMode(_THIS, SDL_Surface *current, | |
1127 int width, int height, int bpp, Uint32 flags) | |
1128 { | |
1129 Uint32 saved_flags; | |
1130 | |
1131 /* Lock the event thread, in multi-threading environments */ | |
1132 SDL_Lock_EventThread(); | |
1133 | |
1134 /* Check the combination of flags we were passed */ | |
1135 if ( flags & SDL_FULLSCREEN ) { | |
1136 /* Clear fullscreen flag if not supported */ | |
1137 if ( SDL_windowid ) { | |
1138 flags &= ~SDL_FULLSCREEN; | |
1139 } | |
1140 } | |
1141 | |
1142 /* Flush any delayed updates */ | |
1143 XSync(GFX_Display, False); | |
1144 | |
1145 /* Set up the X11 window */ | |
1146 saved_flags = current->flags; | |
1147 if ( (SDL_Window) && ((saved_flags&SDL_OPENGL) == (flags&SDL_OPENGL)) | |
1148 && (bpp == current->format->BitsPerPixel) | |
1149 && ((saved_flags&SDL_NOFRAME) == (flags&SDL_NOFRAME)) ) { | |
1150 if (X11_ResizeWindow(this, current, width, height, flags) < 0) { | |
1151 current = NULL; | |
1152 goto done; | |
1153 } | |
1154 } else { | |
1155 if (X11_CreateWindow(this,current,width,height,bpp,flags) < 0) { | |
1156 current = NULL; | |
1157 goto done; | |
1158 } | |
1159 } | |
1160 | |
1081 /* Update the internal keyboard state */ | 1161 /* Update the internal keyboard state */ |
1082 X11_SetKeyboardState(SDL_Display, NULL); | 1162 X11_SetKeyboardState(SDL_Display, NULL); |
1083 | 1163 |
1084 /* When the window is first mapped, ignore non-modifier keys */ | 1164 /* When the window is first mapped, ignore non-modifier keys */ |
1085 { | 1165 if ( !current->w && !current->h ) { |
1086 Uint8 *keys = SDL_GetKeyState(NULL); | 1166 Uint8 *keys = SDL_GetKeyState(NULL); |
1167 int i; | |
1087 for ( i = 0; i < SDLK_LAST; ++i ) { | 1168 for ( i = 0; i < SDLK_LAST; ++i ) { |
1088 switch (i) { | 1169 switch (i) { |
1089 case SDLK_NUMLOCK: | 1170 case SDLK_NUMLOCK: |
1090 case SDLK_CAPSLOCK: | 1171 case SDLK_CAPSLOCK: |
1091 case SDLK_LCTRL: | 1172 case SDLK_LCTRL: |
1100 break; | 1181 break; |
1101 default: | 1182 default: |
1102 keys[i] = SDL_RELEASED; | 1183 keys[i] = SDL_RELEASED; |
1103 break; | 1184 break; |
1104 } | 1185 } |
1105 } | |
1106 } | |
1107 | |
1108 /* Map them both and go fullscreen, if requested */ | |
1109 if ( ! SDL_windowid ) { | |
1110 XMapWindow(SDL_Display, SDL_Window); | |
1111 XMapWindow(SDL_Display, WMwindow); | |
1112 X11_WaitMapped(this, WMwindow); | |
1113 if ( flags & SDL_FULLSCREEN ) { | |
1114 screen->flags |= SDL_FULLSCREEN; | |
1115 X11_EnterFullScreen(this); | |
1116 } else { | |
1117 screen->flags &= ~SDL_FULLSCREEN; | |
1118 } | |
1119 } | |
1120 | |
1121 return(0); | |
1122 } | |
1123 | |
1124 static int X11_ResizeWindow(_THIS, | |
1125 SDL_Surface *screen, int w, int h, Uint32 flags) | |
1126 { | |
1127 if ( ! SDL_windowid ) { | |
1128 /* Resize the window manager window */ | |
1129 X11_SetSizeHints(this, w, h, flags); | |
1130 window_w = w; | |
1131 window_h = h; | |
1132 XResizeWindow(SDL_Display, WMwindow, w, h); | |
1133 | |
1134 /* Resize the fullscreen and display windows */ | |
1135 if ( flags & SDL_FULLSCREEN ) { | |
1136 if ( screen->flags & SDL_FULLSCREEN ) { | |
1137 X11_ResizeFullScreen(this); | |
1138 } else { | |
1139 screen->flags |= SDL_FULLSCREEN; | |
1140 X11_EnterFullScreen(this); | |
1141 } | |
1142 } else { | |
1143 if ( screen->flags & SDL_FULLSCREEN ) { | |
1144 screen->flags &= ~SDL_FULLSCREEN; | |
1145 X11_LeaveFullScreen(this); | |
1146 } | |
1147 } | |
1148 XResizeWindow(SDL_Display, SDL_Window, w, h); | |
1149 } | |
1150 return(0); | |
1151 } | |
1152 | |
1153 SDL_Surface *X11_SetVideoMode(_THIS, SDL_Surface *current, | |
1154 int width, int height, int bpp, Uint32 flags) | |
1155 { | |
1156 Uint32 saved_flags; | |
1157 | |
1158 /* Lock the event thread, in multi-threading environments */ | |
1159 SDL_Lock_EventThread(); | |
1160 | |
1161 /* Check the combination of flags we were passed */ | |
1162 if ( flags & SDL_FULLSCREEN ) { | |
1163 /* Clear fullscreen flag if not supported */ | |
1164 if ( SDL_windowid ) { | |
1165 flags &= ~SDL_FULLSCREEN; | |
1166 } | |
1167 } | |
1168 | |
1169 /* Flush any delayed updates */ | |
1170 XSync(GFX_Display, False); | |
1171 | |
1172 /* Set up the X11 window */ | |
1173 saved_flags = current->flags; | |
1174 if ( (SDL_Window) && ((saved_flags&SDL_OPENGL) == (flags&SDL_OPENGL)) | |
1175 && (bpp == current->format->BitsPerPixel) | |
1176 && ((saved_flags&SDL_NOFRAME) == (flags&SDL_NOFRAME)) ) { | |
1177 if (X11_ResizeWindow(this, current, width, height, flags) < 0) { | |
1178 current = NULL; | |
1179 goto done; | |
1180 } | |
1181 } else { | |
1182 if (X11_CreateWindow(this,current,width,height,bpp,flags) < 0) { | |
1183 current = NULL; | |
1184 goto done; | |
1185 } | 1186 } |
1186 } | 1187 } |
1187 | 1188 |
1188 /* Set up the new mode framebuffer */ | 1189 /* Set up the new mode framebuffer */ |
1189 if ( ((current->w != width) || (current->h != height)) || | 1190 if ( ((current->w != width) || (current->h != height)) || |