Handle client-requested resize (bit of a hack)

This commit is contained in:
Kevin Lange 2013-06-15 19:46:16 -07:00
parent 308b039c92
commit b582be7175
3 changed files with 24 additions and 4 deletions

View File

@ -49,8 +49,12 @@ void TOARU_PumpEvents(_THIS) {
window_t * window = NULL; window_t * window = NULL;
switch (event->command_type) { switch (event->command_type) {
case WE_RESIZED: case WE_RESIZED:
fprintf(stderr, "[SDL] Window resized, need to update buffers!\n"); fprintf(stderr, "[SDL] Received RESIZE message from server.\n");
SDL_PrivateResize(evt->width - this->hidden->x_w, evt->height - this->hidden->x_h); if (this->hidden->triggered_resize != 2) {
fprintf(stderr, "--- From a natural resize. Informing SDL.\n");
this->hidden->triggered_resize = 1;
SDL_PrivateResize(evt->width - this->hidden->x_w, evt->height - this->hidden->x_h);
}
break; break;
case WE_FOCUSCHG: case WE_FOCUSCHG:
window = wins_get_window(evt->wid); window = wins_get_window(evt->wid);

View File

@ -149,6 +149,7 @@ int TOARU_VideoInit(_THIS, SDL_PixelFormat *vformat)
setup_windowing(); setup_windowing();
init_decorations(); init_decorations();
this->hidden->triggered_resize = 0;
/* We're done! */ /* We're done! */
return(0); return(0);
@ -159,20 +160,34 @@ SDL_Rect **TOARU_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
return (SDL_Rect **) -1; return (SDL_Rect **) -1;
} }
extern void wins_send_command(wid_t, int16_t, int16_t, uint16_t, uint16_t, int, int);
SDL_Surface *TOARU_SetVideoMode(_THIS, SDL_Surface *current, SDL_Surface *TOARU_SetVideoMode(_THIS, SDL_Surface *current,
int width, int height, int bpp, Uint32 flags) int width, int height, int bpp, Uint32 flags)
{ {
if ( this->hidden->window) { if ( this->hidden->window) {
fprintf(stderr, "waaat, already have a window! need to resize instead!\n"); fprintf(stderr, "Resize request to %d x %d.\n", width, height);
if (!this->hidden->triggered_resize) {
this->hidden->triggered_resize = 2;
fprintf(stderr, "Requesting window resize.\n");
window_t * w = (window_t *) this->hidden->window;
wins_send_command(w->wid, 0, 0, width + this->hidden->x_w, height + this->hidden->x_h, WC_RESIZE, 0);
fprintf(stderr, "Window resize request completed.\n");
} else {
this->hidden->triggered_resize = 0;
}
fprintf(stderr, "Resizing client window buffer...\n");
resize_window_buffer_client(this->hidden->window, 0, 0, width + this->hidden->x_w, height + this->hidden->x_h); resize_window_buffer_client(this->hidden->window, 0, 0, width + this->hidden->x_w, height + this->hidden->x_h);
fprintf(stderr, "Reinitializing graphics context...\n");
reinit_graphics_window(this->hidden->ctx, this->hidden->window); reinit_graphics_window(this->hidden->ctx, this->hidden->window);
if (this->hidden->bordered) { if (this->hidden->bordered) {
this->hidden->buffer = realloc(this->hidden->buffer, sizeof(uint32_t) * width * height); this->hidden->buffer = realloc(this->hidden->buffer, sizeof(uint32_t) * width * height);
this->hidden->redraw_borders = 1; this->hidden->redraw_borders = 1;
} }
} else { } else {
if (flags & SDL_NOFRAME) { if (flags & SDL_NOFRAME) {

View File

@ -42,6 +42,7 @@ struct SDL_PrivateVideoData {
int x_w, x_h; int x_w, x_h;
int o_w, o_h; int o_w, o_h;
int redraw_borders; int redraw_borders;
int triggered_resize;
}; };
#endif /* _SDL_nullvideo_h */ #endif /* _SDL_nullvideo_h */