Handle client-requested resize (bit of a hack)
This commit is contained in:
parent
308b039c92
commit
b582be7175
@ -49,8 +49,12 @@ void TOARU_PumpEvents(_THIS) {
|
||||
window_t * window = NULL;
|
||||
switch (event->command_type) {
|
||||
case WE_RESIZED:
|
||||
fprintf(stderr, "[SDL] Window resized, need to update buffers!\n");
|
||||
fprintf(stderr, "[SDL] Received RESIZE message from server.\n");
|
||||
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;
|
||||
case WE_FOCUSCHG:
|
||||
window = wins_get_window(evt->wid);
|
||||
|
@ -149,6 +149,7 @@ int TOARU_VideoInit(_THIS, SDL_PixelFormat *vformat)
|
||||
|
||||
setup_windowing();
|
||||
init_decorations();
|
||||
this->hidden->triggered_resize = 0;
|
||||
|
||||
/* We're done! */
|
||||
return(0);
|
||||
@ -159,20 +160,34 @@ SDL_Rect **TOARU_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
|
||||
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,
|
||||
int width, int height, int bpp, Uint32 flags)
|
||||
{
|
||||
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);
|
||||
|
||||
fprintf(stderr, "Reinitializing graphics context...\n");
|
||||
reinit_graphics_window(this->hidden->ctx, this->hidden->window);
|
||||
|
||||
if (this->hidden->bordered) {
|
||||
this->hidden->buffer = realloc(this->hidden->buffer, sizeof(uint32_t) * width * height);
|
||||
this->hidden->redraw_borders = 1;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (flags & SDL_NOFRAME) {
|
||||
|
@ -42,6 +42,7 @@ struct SDL_PrivateVideoData {
|
||||
int x_w, x_h;
|
||||
int o_w, o_h;
|
||||
int redraw_borders;
|
||||
int triggered_resize;
|
||||
};
|
||||
|
||||
#endif /* _SDL_nullvideo_h */
|
||||
|
Loading…
x
Reference in New Issue
Block a user