diff options
-rw-r--r-- | src/console/ptyc_console_poller.c | 80 | ||||
-rw-r--r-- | src/internal/ptycon_bridge_impl.h | 1 |
2 files changed, 79 insertions, 2 deletions
diff --git a/src/console/ptyc_console_poller.c b/src/console/ptyc_console_poller.c index 1c029cb..7f63197 100644 --- a/src/console/ptyc_console_poller.c +++ b/src/console/ptyc_console_poller.c @@ -14,6 +14,82 @@ int __stdcall ptyc_console_poller(struct ptyc_driver_ctx_impl * ictx) { - (void)ictx; - return ntapi->tt_wait_for_dummy_event(); + int32_t status; + int32_t iostatus; + struct ptyc_term_ctx * tctx; + nt_tty_sigctl_info ctlinfo; + void * hwnd; + void * hevent; + nt_timeout timeout; + nt_iosb iosb; + gdi_rect orect; + gdi_rect crect; + int diff; + + tctx = &ictx->tctx; + + if (!(hwnd = ntcon->get_console_window())) + return NT_STATUS_INTERNAL_ERROR; + + if ((status = ntapi->tt_create_private_event( + &hevent, + NT_NOTIFICATION_EVENT, + NT_EVENT_NOT_SIGNALED))) + return status; + + if (!(gdi->get_client_rect( + hwnd, + &orect))) + return NT_STATUS_INTERNAL_ERROR; + + timeout.quad = (-1) * 10 * 1000 * 50; + + do { + status = ntapi->zw_wait_for_single_object( + hevent, + NT_SYNC_ALERTABLE, + &timeout); + + if (!(gdi->get_client_rect( + hwnd, + &crect))) + return NT_STATUS_INTERNAL_ERROR; + + diff = (crect.right-crect.left !=orect.right-orect.left) + || (crect.bottom-crect.top !=orect.bottom-orect.top); + + if (diff) { + orect.left = crect.left; + orect.right = crect.right; + orect.top = crect.top; + orect.bottom = crect.bottom; + + if (!(ntcon->get_console_screen_buffer_info( + tctx->hout, + &tctx->screen_info))) + return NT_STATUS_INTERNAL_ERROR; + + ntapi->tt_aligned_block_memset( + &ctlinfo,0,sizeof(ctlinfo)); + + ctlinfo.winsize.ws_col = tctx->screen_info.window.right + - tctx->screen_info.window.left + + 1; + + ctlinfo.winsize.ws_row = tctx->screen_info.window.bottom + - tctx->screen_info.window.top + + 1; + + if ((iostatus = ntapi->pty_ioctl( + ictx->cctx.hptm, + 0,0,0, + &iosb, + TTY_TIOCSWINSZ, + &ctlinfo,sizeof(ctlinfo), + &ctlinfo,sizeof(ctlinfo)))) + return iostatus; + } + } while (status == NT_STATUS_TIMEOUT); + + return NT_STATUS_INTERNAL_ERROR; } diff --git a/src/internal/ptycon_bridge_impl.h b/src/internal/ptycon_bridge_impl.h index 7f882da..0432cde 100644 --- a/src/internal/ptycon_bridge_impl.h +++ b/src/internal/ptycon_bridge_impl.h @@ -55,6 +55,7 @@ struct ptyc_term_ctx { uint16_t background; nt_coord screen_size; nt_coord window_size; + nt_console_screen_buffer_info screen_info; struct ptyc_term_data data; struct ptyc_term_input input; }; |