diff options
Diffstat (limited to 'src/console/ptyc_console_poller.c')
-rw-r--r-- | src/console/ptyc_console_poller.c | 80 |
1 files changed, 78 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; } |