From 2920f27077212235690407c6d32c1871f73dfd4b Mon Sep 17 00:00:00 2001 From: Kevin Lange Date: Thu, 26 Mar 2015 17:57:24 -0700 Subject: [PATCH] Window resizing --- src/video/toaru/SDL_toaruevents.c | 21 +++++++++++++++++++++ src/video/toaru/SDL_toaruvideo.c | 21 +++++++++++---------- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/video/toaru/SDL_toaruevents.c b/src/video/toaru/SDL_toaruevents.c index 508ace0..5931d36 100644 --- a/src/video/toaru/SDL_toaruevents.c +++ b/src/video/toaru/SDL_toaruevents.c @@ -49,7 +49,28 @@ void TOARU_PumpEvents(_THIS) { } break; case YUTANI_MSG_WINDOW_FOCUS_CHANGE: + { + struct yutani_msg_window_focus_change * fc = (void*)m->data; + yutani_window_t * w = hashmap_get(this->hidden->yctx->windows, (void*)fc->wid); + if (w == this->hidden->window) { + w->focused = fc->focused; + this->hidden->redraw_borders = 1; + SDL_PrivateAppActive(0, fc->focused); + } + } + break; case YUTANI_MSG_RESIZE_OFFER: + { + struct yutani_msg_window_resize * wr = (void*)m->data; + yutani_window_t * w = hashmap_get(this->hidden->yctx->windows, (void*)wr->wid); + if (w == this->hidden->window) { + if (this->hidden->triggered_resize != 2) { + this->hidden->triggered_resize = 1; + SDL_PrivateResize(wr->width - this->hidden->x_w, wr->height - this->hidden->x_h); + } + } + } + break; case YUTANI_MSG_WINDOW_MOUSE_EVENT: case YUTANI_MSG_SESSION_END: fprintf(stderr, "[sdl-toaru] Need to implement: %u\n", (unsigned int)m->type); diff --git a/src/video/toaru/SDL_toaruvideo.c b/src/video/toaru/SDL_toaruvideo.c index 385fecd..379baf8 100644 --- a/src/video/toaru/SDL_toaruvideo.c +++ b/src/video/toaru/SDL_toaruvideo.c @@ -163,32 +163,35 @@ SDL_Rect **TOARU_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) SDL_Surface *TOARU_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags) { -#if 0 if ( this->hidden->window) { fprintf(stderr, "Resize request to %d x %d.\n", width, height); if (!this->hidden->triggered_resize) { + yutani_window_t * w = (yutani_window_t *) this->hidden->window; 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"); + yutani_window_resize(this->hidden->yctx, w, width + this->hidden->x_w, height + this->hidden->x_h); + + yutani_msg_t * m = yutani_wait_for(this->hidden->yctx, YUTANI_MSG_RESIZE_OFFER); + struct yutani_msg_window_resize * wr = (void*)m->data; + width = wr->width - this->hidden->x_w; + height = wr->height - this->hidden->x_h; + free(m); } 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); + yutani_window_resize_accept(this->hidden->yctx, this->hidden->window, 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_yutani(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; } + yutani_window_resize_done(this->hidden->yctx, this->hidden->window); } else { -#endif if (flags & SDL_NOFRAME) { fprintf(stderr, "Initializing without borders.\n"); @@ -223,9 +226,7 @@ SDL_Surface *TOARU_SetVideoMode(_THIS, SDL_Surface *current, fprintf(stderr, "Window output initialized...\n"); -#if 0 } -#endif /* Set up the new mode framebuffer */ current->flags = flags;