hschumann2/TempleOS-Source-Code
0847
1 2#help_index "Windows;Task/Delay"3 4public U0 Refresh(I64 cnt=1,Bool force=FALSE)5{//Wait for 30fps WinMgr to start & finish scrn refresh.6//0,FALSE Cnt Sync to WinMgr. (not used)7 //0,TRUE Pump Msgs.8 //1 Cnt Wait and Pump Msgs.9 //2 Cnt Make Sure to do a Full Refresh10 //and Set Cur Pos.11 Bool old_full_refresh,12 old_idle=LBts(&Fs->task_flags,TASKf_IDLE);13 CDoc *old_doc=DocPut;14 I64 update_cnt;15 if (!cnt&&force)16 LBts(&sys_semas[SEMA_JUST_PUMP_MSGS],0);17 while (Bt(&sys_semas[SEMA_REFRESH_IN_PROGRESS],0)) {18 if (force && sys_winmgr_task)19 sys_winmgr_task->wake_jiffy=cnts.jiffies;20 Yield;21 }22 if (cnt>1 && old_doc)23 old_full_refresh=LBts(&old_doc->flags,DOCf_DO_FULL_REFRESH);24 update_cnt=winmgr.updates+cnt;25 while (winmgr.updates<update_cnt) {26 if (force && sys_winmgr_task)27 sys_winmgr_task->wake_jiffy=cnts.jiffies;28 Sleep(1);29 }30 if (old_doc)31 LBEqu(&old_doc->flags,DOCf_DO_FULL_REFRESH,old_full_refresh);32 LBEqu(&Fs->task_flags,TASKf_IDLE,old_idle);33}34 35#help_index "Windows"36 37I64 WinQueIPMsgs(Bool que)38{39 static CD3I64 single_ms={0,0,0};40 F64 time=tS;41 I64 msg_code=0,arg1,arg2,single_arg1,single_arg2;42 CTask *task_focus=sys_focus_task;43 44 if (task_focus && !winmgr.grab_scroll) {45 arg1=ms.pos.x-task_focus->pix_left-task_focus->scroll_x;46 arg2=ms.pos.y-task_focus->pix_top-task_focus->scroll_y;47 single_arg1=single_ms.x-task_focus->pix_left-task_focus->scroll_x;48 single_arg2=single_ms.y-task_focus->pix_top-task_focus->scroll_y;49 if (old_ms.presnap.x!=ms.presnap.x || old_ms.presnap.y!=ms.presnap.y) {50 if (que)51 TaskMsg(task_focus,0,52 MSG_MS_MOVE,arg1,arg2,0);53 msg_code=MSG_MS_MOVE;54 }55//TODO que msg for ms.pos.z?56 if (ms.left_dbl_time) {57 if (time>ms.left_dbl_time) {58 if (ms.left_dbl) {59 if (!ms.left_down_sent) {60 if (que)61 TaskMsg(task_focus,0,62 MSG_MS_L_D_DOWN,arg1,arg2,0);63 ms.left_down_sent=TRUE;64 msg_code=MSG_MS_L_D_DOWN;65 }66 if (!ms.lb) {67 if (que)68 TaskMsg(task_focus,0,69 MSG_MS_L_D_UP,arg1,arg2,0);70 ms.left_dbl_time=0;71 msg_code=MSG_MS_L_D_UP;72 }73 } else {74 if (!ms.left_down_sent) {75 if (que)76 TaskMsg(task_focus,0,77 MSG_MS_L_DOWN,single_arg1,single_arg2,0);78 ms.left_down_sent=TRUE;79 msg_code=MSG_MS_L_DOWN;80 }81 if (!ms.lb) {82 if (que)83 TaskMsg(task_focus,0,84 MSG_MS_L_UP,arg1,arg2,0);85 ms.left_dbl_time=0;86 msg_code=MSG_MS_L_UP;87 }88 }89 } else {90 if (ms.lb && !ms_last.lb) {91 ms.left_dbl_time=time;92 ms.left_dbl=TRUE;93 }94 }95 } else {96 if (TaskValidate(task_focus) &&97 Bt(&task_focus->win_inhibit,WIf_FOCUS_TASK_MS_L_D)) {98 if (ms.lb && !ms_last.lb) {99 if (que)100 TaskMsg(task_focus,0,101 MSG_MS_L_DOWN,arg1,arg2,0);102 msg_code=MSG_MS_L_DOWN;103 } else if (!ms.lb && ms_last.lb) {104 if (que)105 TaskMsg(task_focus,0,106 MSG_MS_L_UP,arg1,arg2,0);107 msg_code=MSG_MS_L_UP;108 }109 } else {110 if (ms.lb && !ms_last.lb) {111 ms.left_dbl=FALSE;112 ms.left_down_sent=FALSE;113 ms.left_dbl_time=time+ms.dbl_time;114 single_ms.x=ms.pos.x;115 single_ms.y=ms.pos.y;116 }117 }118 }119 120 if (ms.right_dbl_time) {121 if (time>ms.right_dbl_time) {122 if (ms.right_dbl) {123 if (!ms.right_down_sent) {124 if (que)125 TaskMsg(task_focus,0,126 MSG_MS_R_D_DOWN,arg1,arg2,0);127 ms.right_down_sent=TRUE;128 msg_code=MSG_MS_R_D_DOWN;129 }130 if (!ms.rb) {131 if (que)132 TaskMsg(task_focus,0,133 MSG_MS_R_D_UP,arg1,arg2,0);134 ms.right_dbl_time=0;135 msg_code=MSG_MS_R_D_UP;136 }137 } else {138 if (!ms.right_down_sent) {139 if (que)140 TaskMsg(task_focus,0,141 MSG_MS_R_DOWN,single_arg1,single_arg2,0);142 ms.right_down_sent=TRUE;143 msg_code=MSG_MS_R_DOWN;144 }145 if (!ms.rb) {146 if (que)147 TaskMsg(task_focus,0,148 MSG_MS_R_UP,arg1,arg2,0);149 ms.right_dbl_time=0;150 msg_code=MSG_MS_R_UP;151 }152 }153 } else {154 if (ms.rb && !ms_last.rb) {155 ms.right_dbl_time=time;156 ms.right_dbl=TRUE;157 }158 }159 } else {160 if (TaskValidate(task_focus) &&161 Bt(&task_focus->win_inhibit,WIf_FOCUS_TASK_MS_R_D)) {162 if (ms.rb && !ms_last.rb) {163 if (que)164 TaskMsg(task_focus,0,165 MSG_MS_R_DOWN,arg1,arg2,0);166 msg_code=MSG_MS_R_DOWN;167 } else if (!ms.rb && ms_last.rb) {168 if (que)169 TaskMsg(task_focus,0,170 MSG_MS_R_UP,arg1,arg2,0);171 msg_code=MSG_MS_R_UP;172 }173 } else {174 if (ms.rb && !ms_last.rb) {175 ms.right_dbl=FALSE;176 ms.right_down_sent=FALSE;177 ms.right_dbl_time=time+ms.dbl_time;178 single_ms.x=ms.pos.x;179 single_ms.y=ms.pos.y;180 }181 }182 }183 184 MemCpy(&ms_last,&ms,sizeof(CMsStateGlbls));185 MemCpy(&old_ms,&ms,sizeof(CMsStateGlbls));186 }187 return msg_code;188}189 190U0 WinCalcIdles()191{192 F64 calc_idle_time;193 I64 i,k,total_jiffies,total_jiffies_delta,idle_pt_hits[MP_PROCESSORS_NUM];194 CCPU *c;195 CWinMgrTimingGlbls *t=winmgr.t;196 197 if ((t->calc_idle_delta_time=198 (calc_idle_time=tS)-t->last_calc_idle_time)>.25) {199 PUSHFD200 CLI201 total_jiffies=cpu_structs[0].total_jiffies;202 for (i=0;i<mp_cnt;i++)203 idle_pt_hits[i]=cpu_structs[i].idle_pt_hits;204 POPFD205 206 total_jiffies_delta=total_jiffies-t->last_total_jiffies;207 for (i=0;i<mp_cnt;i++) {208 c=&cpu_structs[i];209 if (total_jiffies_delta && (k=idle_pt_hits[i]-t->last_idle_pt_hits[i])>=0)210 c->idle_factor=Clamp(ToF64(k)/total_jiffies_delta,0.01,0.99);211 else212 c->idle_factor=0.01;213 t->last_idle_pt_hits[i]=idle_pt_hits[i];214 }215 t->last_total_jiffies=total_jiffies;216 t->last_calc_idle_time=calc_idle_time;217 t->calc_idle_cnt++;218 }219}220 221I64 WinMgrSleep(Bool flush_msgs=FALSE)222{223 I64 timeout_val,msg_code=0;224 CCtrl *c;225 Bool que;226 F64 t,t_delta;227 228 TimeStampFreqCal;229 if ((t_delta=(t=tS)-winmgr.last_refresh_tS)>0.01)230 winmgr.fps=Max(1.0/t_delta,1);231 else232 winmgr.fps=99;233 winmgr.last_refresh_tS=t;234 WinCalcIdles;235 236 if (flush_msgs)237 FifoI64Flush(kbd.scan_code_fifo);238 else if (TaskValidate(sys_focus_task)) {239 KbdMsgsQue;240 241 que=TRUE;242 if (TaskValidate(sys_focus_task) &&243 !Bt(&sys_focus_task->win_inhibit,WIf_FOCUS_TASK_CTRLS)) {244 c=sys_focus_task->next_ctrl;245 while (c!=&sys_focus_task->next_ctrl) {246 if (CtrlInside(c,ms.pos.x,ms.pos.y)) {247 que=FALSE;248 break;249 }250 c=c->next;251 }252 }253 msg_code=WinQueIPMsgs(que);254 } else {255 WinRefocus(sys_focus_task);256 if (!TaskValidate(sys_focus_task))257 FifoI64Flush(kbd.scan_code_fifo);258 }259 if (sys_focus_task)260 LBtr(&sys_focus_task->task_flags,TASKf_HAS_SONG);261 WinMsUpdate;262 263 if (!LBtr(&sys_semas[SEMA_JUST_PUMP_MSGS],0)) {264 timeout_val=cnts.jiffies+JIFFY_FREQ/WINMGR_FPS;265 LBts(&sys_semas[SEMA_REFRESH_IN_PROGRESS],0);266 GrUpdateScrn;267 LBtr(&sys_semas[SEMA_REFRESH_IN_PROGRESS],0);268 269 if (sys_focus_task && !Bt(&sys_focus_task->task_flags,TASKf_HAS_SONG)) {270 Free(music.cur_song);271 music.cur_song=NULL;272 }273 if (music.cur_song) {274 if (!music.cur_song_task)275 music.cur_song_task=Spawn(&CurSongTask,NULL,"Song");276 } else if (music.cur_song_task) {277 Kill(music.cur_song_task);278 music.cur_song_task=NULL;279 }280 winmgr.updates++;281 if (ms_hard.install_attempts) //Don't call before boot mouse install attempt282 KbdMsHndlr(FALSE,TRUE);283 SleepUntil(timeout_val);284 }285 return msg_code;286}287 288CDoc *WinCursorPosSet(CTask *task,I64 msx,I64 msy,Bool set_cursor=TRUE)289{290 CDoc *res=NULL;291 Bool unlock;292 I64 x0,y0;293 if (!task) task=Fs;294 if (WinInside(msx,msy,task)) {295 if ((res=DocDisplay(task)) && res->flags&DOCF_DONT_SHOW)296 res=NULL;297 else if (set_cursor) {298 unlock=DocLock(res);299 if (res->doc_signature!=DOC_SIGNATURE_VAL)300 res=NULL;301 else {302 x0=res->line_start_col;303 y0=res->top_line_num;304 DocRecalc(res,RECALCF_HAS_CURSOR);305 res->x=(msx-task->pix_left-task->scroll_x)/FONT_WIDTH +x0;306 res->y=(msy-task->pix_top -task->scroll_y)/FONT_HEIGHT+y0;307 DocRecalc(res,RECALCt_FIND_CURSOR);308 task->scroll_x=0;309 task->scroll_y=0;310 task->scroll_z=0;311 if (unlock)312 DocUnlock(res);313 }314 }315 WinToTop(task);316 }317 return res;318}319 320Bool WinKeyNavMenu()321{322 I64 i,old_key_cnt;323 CD3I64 old_pos,new_pos;324 CMenu *m;325 CMenuEntry *tmpme;326 CTask *focus=MenuTask;327 if (Bt(kbd.down_bitmap,SC_GUI) && focus && (m=focus->cur_menu)) {328 winmgr.show_menu=TRUE;329 sys_cur_submenu_entry=NULL;330 old_pos.x=ms.pos.x; old_pos.y=ms.pos.y;331 ms.pos.x=new_pos.x=ms.pos.y=new_pos.y=0;332 while (Bt(kbd.down_bitmap,SC_GUI)) {333 old_key_cnt=kbd.cnt;334 if (Bt(kbd.down_bitmap,SC_CURSOR_LEFT)) {335 while (Bt(kbd.down_bitmap,SC_CURSOR_LEFT) && kbd.cnt==old_key_cnt)336 WinMgrSleep(TRUE);337 if (new_pos.x) {338 i=0;339 tmpme=m->sub;340 while (tmpme) {341 if (i+MenuEntryWidth(tmpme)*FONT_WIDTH==new_pos.x) {342 new_pos.x=i;343 break;344 }345 i+=MenuEntryWidth(tmpme)*FONT_WIDTH;346 tmpme=tmpme->next;347 }348 }349 new_pos.y=0;350 } else if (Bt(kbd.down_bitmap,SC_CURSOR_RIGHT)) {351 while (Bt(kbd.down_bitmap,SC_CURSOR_RIGHT) && kbd.cnt==old_key_cnt)352 WinMgrSleep(TRUE);353 i=0;354 tmpme=m->sub;355 while (tmpme) {356 if (i==new_pos.x) {357 if (tmpme->next)358 new_pos.x=i+MenuEntryWidth(tmpme)*FONT_WIDTH;359 break;360 }361 i+=MenuEntryWidth(tmpme)*FONT_WIDTH;362 tmpme=tmpme->next;363 }364 new_pos.y=0;365 } else if (Bt(kbd.down_bitmap,SC_CURSOR_UP)) {366 while (Bt(kbd.down_bitmap,SC_CURSOR_UP) && kbd.cnt==old_key_cnt)367 WinMgrSleep(TRUE);368 new_pos.y-=FONT_HEIGHT;369 } else if (Bt(kbd.down_bitmap,SC_CURSOR_DOWN)) {370 while (Bt(kbd.down_bitmap,SC_CURSOR_DOWN) && kbd.cnt==old_key_cnt)371 WinMgrSleep(TRUE);372 new_pos.y+=FONT_HEIGHT;373 }374 new_pos.x=ClampI64(new_pos.x,0,GR_WIDTH-1);375 new_pos.y=ClampI64(new_pos.y,0,GR_HEIGHT-1);376 ms.pos.x=new_pos.x; ms.pos.y=new_pos.y;377 WinMgrSleep(TRUE);378 if (!sys_cur_submenu_entry)379 ms.pos.y=new_pos.y=0;380 }381 if (sys_cur_submenu_entry)382 TaskMsg(sys_focus_task,0,sys_cur_submenu_entry->msg_code,383 sys_cur_submenu_entry->arg1,sys_cur_submenu_entry->arg2,0);384 winmgr.show_menu=FALSE;385 ms.pos.x=old_pos.x; ms.pos.y=old_pos.y;386 return TRUE;387 }388 return FALSE;389}390 391U0 WinMgrTask(I64)392{393 CTask *task=Fs;394 CDoc *doc;395 CDocEntry *doc_e;396 I64 x,y,z,msg_code,397 my_ms_z=0,left,top,398 old_flags=GetRFlags;399 Bool has_border;400 CCtrl *c;401 WinHorz(0,TEXT_COLS-1);402 WinVert(0,TEXT_ROWS-1);403 LBts(&Fs->display_flags,DISPLAYf_NO_BORDER);404 LBts(&Fs->display_flags,DISPLAYf_SHOW);405 gr.dc->win_task=Fs;406 Fs->win_inhibit&=~WIF_SELF_CTRLS;407 GrSetUpTables;408 WinZBufUpdate;409 LBts(&sys_run_level,RLf_WINMGR);410 while (TRUE) {411 try {412wmt_start:413 if (Bt(&sys_run_level,RLf_ADAM_SERVER))414 TaskKillDying;415 WinMgrSleep;416 417 task=Fs->last_task;418 while (TRUE) {419 CLI420 if (!TaskValidate(task)) {421 SetRFlags(old_flags);422 goto wmt_start;423 }424 TaskDerivedValsUpdate(task,FALSE);425 task=task->last_task;426 SetRFlags(old_flags);427 if (task==Fs)428 break;429 }430 TaskDerivedValsUpdate(Fs,FALSE);431 432 task=Fs->last_task;433 while (TRUE) {434 CLI435 if (!TaskValidate(task)) {436 SetRFlags(old_flags);437 goto wmt_start;438 }439 if (WinInside(ms.pos.x,ms.pos.y,task,FONT_WIDTH)) {440 SetRFlags(old_flags);441 break;442 }443 if (task==Fs) { //Shouldn't happen444 SetRFlags(old_flags);445 goto wmt_start;446 }447 task=task->last_task;448 SetRFlags(old_flags);449 }450 451 if (Bt(&task->display_flags,DISPLAYf_NO_BORDER))452 has_border=FALSE;453 else454 has_border=TRUE;455 456 winmgr.show_menu=FALSE;457 sys_cur_submenu_entry=NULL;458 if (TaskValidate(sys_focus_task) &&459 !Bt(&sys_focus_task->win_inhibit,WIf_FOCUS_TASK_MENU)) {460 if (WinKeyNavMenu)461 goto wmt_start;462 if (task==Fs && 0<=ms.pos.y<FONT_HEIGHT && ms_hard.installed) {463 winmgr.show_menu=TRUE;464 if (ms.lb && !old_ms.lb) {465 winmgr.show_menu=TRUE;466 while (ms.lb)467 WinMgrSleep(TRUE);468 if (sys_cur_submenu_entry)469 TaskMsg(sys_focus_task,0,470 sys_cur_submenu_entry->msg_code,471 sys_cur_submenu_entry->arg1,472 sys_cur_submenu_entry->arg2,0);473 winmgr.show_menu=FALSE;474 old_ms.lb=FALSE;475 goto wmt_start;476 }477 }478 }479 480 //grab scroll481 if (!Bt(&task->win_inhibit,WIf_SELF_GRAB_SCROLL) &&482 (!TaskValidate(sys_focus_task)||483 !Bt(&sys_focus_task->win_inhibit,WIf_FOCUS_TASK_GRAB_SCROLL)) &&484 kbd.scan_code&SCF_CTRL && TaskValidate(task)) {485 winmgr.grab_scroll_closed=FALSE;486 winmgr.grab_scroll=TRUE;487 while (kbd.scan_code&SCF_CTRL && TaskValidate(task) && (!ac.task ||488 !WinInside(ms.pos.x,ms.pos.y,ac.task,FONT_WIDTH))) {489 if (ms.lb) {490 winmgr.grab_scroll_closed=TRUE;491 x=ms.pos.x-task->scroll_x;492 y=ms.pos.y-task->scroll_y;493 z=ms.pos.z-task->scroll_z;494 while (ms.lb && kbd.scan_code&SCF_CTRL && TaskValidate(task)) {495 task->scroll_x=(ms.pos.x-x)&~7;496 task->scroll_y=(ms.pos.y-y)&~7;497 task->scroll_z=ms.pos.z-z;498 WinMgrSleep(TRUE);499 }500 winmgr.grab_scroll_closed=FALSE;501 } else if (ms.rb) {502 task->scroll_x=0;503 task->scroll_y=0;504 task->scroll_z=0;505 WinMgrSleep(TRUE);506 } else507 WinMgrSleep;508 }509 winmgr.grab_scroll=FALSE;510 goto wmt_start;511 } else512 winmgr.grab_scroll=FALSE;513 514 if (!Bt(&task->win_inhibit,WIf_SELF_CTRLS) &&515 (!TaskValidate(sys_focus_task)||516 !Bt(&sys_focus_task->win_inhibit,WIf_FOCUS_TASK_CTRLS))) {517 if (ms.lb && !old_ms.lb) {518 c=task->next_ctrl;519 while (c!=&task->next_ctrl) {520 if (CtrlInside(c,ms.pos.x,ms.pos.y)) {521 left=task->pix_left;522 top =task->pix_top;523 if (c->flags&CTRLF_BORDER) {524 left-=FONT_WIDTH;525 top -=FONT_HEIGHT;526 }527 if (c->flags&CTRLF_CAPTURE_LEFT_MS) {528 while (ms.lb && TaskValidate(task)) {529 if (c->left_click)530 (*c->left_click)(c,ms.pos.x-left,ms.pos.y-top,TRUE);531 WinMgrSleep;532 }533 if (c->left_click)534 (*c->left_click)(c,ms.pos.x-left,ms.pos.y-top,FALSE);535 old_ms.lb=FALSE;536 goto wmt_start;537 } else {538 if (c->left_click)539 (*c->left_click)(c,ms.pos.x-left,ms.pos.y-top,TRUE);540 old_ms.lb=TRUE;541 goto wmt_start;542 }543 }544 c=c->next;545 }546 }547 if (old_ms.lb && !ms.lb) {548 c=task->next_ctrl;549 while (c!=&task->next_ctrl) {550 if (CtrlInside(c,ms.pos.x,ms.pos.y)) {551 left=task->pix_left;552 top =task->pix_top;553 if (c->flags&CTRLF_BORDER) {554 left-=FONT_WIDTH;555 top -=FONT_HEIGHT;556 }557 if (c->left_click)558 (*c->left_click)(c,ms.pos.x-left,ms.pos.y-top,FALSE);559 old_ms.lb=FALSE;560 goto wmt_start;561 }562 c=c->next;563 }564 }565 if (ms.rb && !old_ms.rb) {566 c=task->next_ctrl;567 while (c!=&task->next_ctrl) {568 if (CtrlInside(c,ms.pos.x,ms.pos.y)) {569 left=task->pix_left;570 top =task->pix_top;571 if (c->flags&CTRLF_BORDER) {572 left-=FONT_WIDTH;573 top -=FONT_HEIGHT;574 }575 if (c->flags&CTRLF_CAPTURE_RIGHT_MS) {576 while (ms.rb && TaskValidate(task)) {577 if (c->right_click)578 (*c->right_click)(c,ms.pos.x-left,ms.pos.y-top,TRUE);579 WinMgrSleep;580 }581 if (c->right_click)582 (*c->right_click)(c,ms.pos.x-left,ms.pos.y-top,FALSE);583 old_ms.rb=FALSE;584 goto wmt_start;585 } else {586 if (c->right_click)587 (*c->right_click)(c,ms.pos.x-left,ms.pos.y-top,TRUE);588 old_ms.rb=TRUE;589 goto wmt_start;590 }591 }592 c=c->next;593 }594 }595 if (old_ms.rb && !ms.rb) {596 c=task->next_ctrl;597 while (c!=&task->next_ctrl) {598 if (CtrlInside(c,ms.pos.x,ms.pos.y)) {599 left=task->pix_left;600 top =task->pix_top;601 if (c->flags&CTRLF_BORDER) {602 left-=FONT_WIDTH;603 top -=FONT_HEIGHT;604 }605 if (c->right_click)606 (*c->right_click)(c,ms.pos.x-left,ms.pos.y-top,FALSE);607 old_ms.rb=FALSE;608 goto wmt_start;609 }610 c=c->next;611 }612 }613 if (ms.has_wheel && my_ms_z!=ms.pos.z) {614 if (task==sys_focus_task) {615 c=task->next_ctrl;616 while (c!=&task->next_ctrl) {617 if (c->wheel_chg) {618 (*c->wheel_chg)(c,ms.pos.z-my_ms_z);619 my_ms_z=ms.pos.z;620 goto wmt_start;621 }622 c=c->next;623 }624 my_ms_z=ms.pos.z;625 } else if (!sys_focus_task)626 my_ms_z=ms.pos.z;627 }628 }629 630 if (task==Fs)631 goto wmt_start;632 633 if (!Bt(&task->win_inhibit,WIf_SELF_MS_L)&&634 (!TaskValidate(sys_focus_task)||635 !Bt(&sys_focus_task->win_inhibit,WIf_FOCUS_TASK_MS_L))) {636 if (!old_ms.lb && ms.lb) {637 if (doc=WinCursorPosSet(task,ms.pos.x,ms.pos.y)) {638 DocLock(doc);639 if (doc->doc_signature==DOC_SIGNATURE_VAL) {640 doc_e=doc->cur_entry;641 if (doc_e!=doc) {642 if (doc_e->de_flags & DOCEF_HAS_BORDER)643 doc_e->de_flags|=DOCEF_SOLID_BORDER;644 }645 }646 DocUnlock(doc);647 old_ms.lb=TRUE;648 goto wmt_start;649 }650 }651 }652 if (!Bt(&task->win_inhibit,WIf_SELF_MS_R)&&653 (!TaskValidate(sys_focus_task)||654 !Bt(&sys_focus_task->win_inhibit,WIf_FOCUS_TASK_MS_R))) {655 if (!old_ms.rb && ms.rb) {656 if (WinCursorPosSet(task,ms.pos.x,ms.pos.y)) {657 old_ms.rb=TRUE;658 goto wmt_start;659 }660 }661 }662 if (!Bt(&task->win_inhibit,WIf_SELF_BORDER) && has_border &&663 (!TaskValidate(sys_focus_task)||664 !Bt(&sys_focus_task->win_inhibit,WIf_FOCUS_TASK_BORDER))) {665 if (old_ms.lb && !ms.lb) {666 if (ms.pos_text.y==task->win_top-1) {667 if (task->win_left<=ms.pos_text.x<task->win_left+4) {668 TaskMsg(task,0,MSG_KEY_DOWN,CH_CTRLM,0x43200000432,0);669 old_ms.lb=FALSE;670 goto wmt_start;671 } else if (task->win_right-2<=ms.pos_text.x<=task->win_right) {672 if (DocPut(task))673 TaskMsg(task,0,MSG_KEY_DOWN,CH_SHIFT_ESC,0,0);674 else675 Kill(task,FALSE);676 old_ms.lb=FALSE;677 goto wmt_start;678 }679 }680 }681 }682 if (!Bt(&task->win_inhibit,WIf_SELF_MS_L)&&683 (!TaskValidate(sys_focus_task)||684 !Bt(&sys_focus_task->win_inhibit,WIf_FOCUS_TASK_MS_L))) {685 if (old_ms.lb && !ms.lb) {686 if (doc=WinCursorPosSet(task,ms.pos.x,ms.pos.y,FALSE)) {687 do msg_code=WinMgrSleep;688 while (TaskValidate(task) && (ms.lb || ms.left_dbl_time));689 if (TaskValidate(task)) {690 if (msg_code==MSG_MS_L_UP) {691 if (doc->doc_signature==DOC_SIGNATURE_VAL) {692 DocLock(doc);693 if (TaskValidate(task)) {694 if (doc->doc_signature==DOC_SIGNATURE_VAL) {695 doc_e=doc->cur_entry;696 if (doc_e!=doc) {697 if (doc_e->de_flags & DOCEF_HAS_BORDER)698 doc_e->de_flags&=~DOCEF_SOLID_BORDER;699 if (doc_e->de_flags & (DOCEF_TREE|DOCEF_LST|700 DOCEF_LINK|DOCEF_CHECK_COLLAPSABLE|701 DOCEF_LEFT_CB|DOCEF_LEFT_MACRO|DOCEF_LEFT_EXP))702 TaskMsg(task,0,MSG_KEY_DOWN,CH_SPACE,0,0);703 }704 }705 DocUnlock(doc);706 }707 }708 } else if (msg_code==MSG_MS_L_D_UP)709 TaskMsg(task,0,MSG_KEY_DOWN,CH_ESC,0,0);710 }711 old_ms.lb=FALSE;712 goto wmt_start;713 }714 }715 }716 717 if (!Bt(&task->win_inhibit,WIf_SELF_MS_R)&&718 (!TaskValidate(sys_focus_task)||719 !Bt(&sys_focus_task->win_inhibit,WIf_FOCUS_TASK_MS_R))) {720 if (old_ms.rb && !ms.rb) {721 if (doc=WinCursorPosSet(task,ms.pos.x,ms.pos.y,FALSE)) {722 do msg_code=WinMgrSleep;723 while (TaskValidate(task) && (ms.rb || ms.right_dbl_time));724 if (TaskValidate(task)) {725 if (msg_code==MSG_MS_R_UP) {726 if (doc->doc_signature==DOC_SIGNATURE_VAL) {727 DocLock(doc);728 if (TaskValidate(task)) {729 if (doc->doc_signature==DOC_SIGNATURE_VAL) {730 doc_e=doc->cur_entry;731 if (doc_e!=doc) {732 if (doc_e->de_flags&(DOCEF_LINK|733 DOCEF_RIGHT_CB|DOCEF_RIGHT_MACRO|DOCEF_RIGHT_EXP))734 TaskMsg(task,0,MSG_KEY_DOWN,'\n',0,0);735 }736 }737 DocUnlock(doc);738 }739 }740 } else if (msg_code==MSG_MS_R_D_UP)741 TaskMsg(task,0,MSG_KEY_DOWN,CH_SHIFT_ESC,0,0);742 }743 old_ms.rb=FALSE;744 goto wmt_start;745 }746 }747 }748 749 if (!Bt(&task->win_inhibit,WIf_SELF_BORDER) && has_border &&750 (!TaskValidate(sys_focus_task)||751 !Bt(&sys_focus_task->win_inhibit,WIf_FOCUS_TASK_BORDER))) {752 if (ms.lb && !old_ms.lb) {753 if (task->win_top==ms.pos_text.y+1 &&754 task->win_left-1<=ms.pos_text.x<=task->win_right+1) {755 if (task->win_left<=ms.pos_text.x<task->win_left+4) {756 old_ms.lb=TRUE;757 goto wmt_start;758 }759 if (task->win_right-2<=ms.pos_text.x<=task->win_right) {760 old_ms.lb=TRUE;761 goto wmt_start;762 }763 x=ms.pos_text.x-task->win_left;764 if (ms.lb) {765 WinToTop(task);766 while (ms.lb && TaskValidate(task)) {767 WinHorz(ms.pos_text.x-x,task->win_width-1+ms.pos_text.x-x,task);768 WinVert(ms.pos_text.y+1,task->win_height+ms.pos_text.y,task);769 WinMgrSleep;770 }771 }772 old_ms.lb=FALSE;773 goto wmt_start;774 }775 if (task->win_left==ms.pos_text.x+1 &&776 task->win_top-1<=ms.pos_text.y<=task->win_bottom+1) {777 y=ms.pos_text.y-task->win_top;778 if (ms.lb) {779 WinToTop(task);780 while (ms.lb && TaskValidate(task)) {781 WinHorz(ms.pos_text.x+1,task->win_width+ms.pos_text.x,task);782 WinVert(ms.pos_text.y-y,783 task->win_height-1+ms.pos_text.y-y,task);784 WinMgrSleep;785 }786 }787 old_ms.lb=FALSE;788 goto wmt_start;789 }790 if (task->win_right+1==ms.pos_text.x &&791 task->win_bottom+1==ms.pos_text.y) {792 if (ms.lb) {793 WinToTop(task);794 while (ms.lb && TaskValidate(task)) {795 WinHorz(task->win_left,ms.pos_text.x-1,task);796 WinVert(task->win_top,ms.pos_text.y-1,task);797 WinMgrSleep;798 }799 }800 old_ms.lb=FALSE;801 goto wmt_start;802 }803 if (task->win_bottom==ms.pos_text.y-1 &&804 task->win_left<=ms.pos_text.x<=task->win_right) {805 if (ms.lb) {806 WinToTop(task);807 while (ms.lb && TaskValidate(task)) {808 WinVert(task->win_top,ms.pos_text.y-1,task);809 WinMgrSleep;810 }811 }812 old_ms.lb=FALSE;813 goto wmt_start;814 }815 if (task->win_right==ms.pos_text.x-1 &&816 task->win_top<=ms.pos_text.y<=task->win_bottom) {817 if (ms.lb) {818 WinToTop(task);819 while (ms.lb && TaskValidate(task)) {820 WinHorz(task->win_left,ms.pos_text.x-1,task);821 WinMgrSleep;822 }823 }824 old_ms.lb=FALSE;825 goto wmt_start;826 }827 }828 }829 } catch {830 Beep;831 Fs->catch_except=TRUE;832 task=Fs;833 }834 }835}836 