Subversion Repositories Kolibri OS

Rev

Rev 5665 | Rev 5844 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                              ;;
  3. ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
  4. ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
  5. ;; Distributed under terms of the GNU General Public License    ;;
  6. ;;                                                              ;;
  7. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8.  
  9. $Revision: 5836 $
  10.  
  11. ;==============================================================================
  12. ;///// public functions ///////////////////////////////////////////////////////
  13. ;==============================================================================
  14.  
  15. window.BORDER_SIZE = 5
  16.  
  17. macro FuncTable name, table_name, [label]
  18. {
  19.   common
  20.     align 4
  21.     \label name#.#table_name dword
  22.   forward
  23.     dd name#.#label
  24.   common
  25.     name#.sizeof.#table_name = $ - name#.#table_name
  26. }
  27.  
  28. uglobal
  29.   common_colours rd 48
  30.   draw_limits    RECT
  31. endg
  32.  
  33. align 4
  34. ;------------------------------------------------------------------------------
  35. syscall_draw_window: ;///// system function 0 /////////////////////////////////
  36. ;------------------------------------------------------------------------------
  37. ;? <description>.
  38. ;------------------------------------------------------------------------------
  39.         mov     eax, edx
  40.         shr     eax, 24
  41.         and     al, 0x0f
  42.         cmp     al, 5
  43.         jae     .exit
  44.  
  45.         push    eax
  46.         call    window._.sys_set_window
  47.         pop     eax
  48.  
  49.         or      al, al
  50.         jnz     @f
  51.  
  52.         ; type I - original style
  53.         call    drawwindow_I
  54.         jmp     window._.draw_window_caption.2
  55. ;--------------------------------------
  56. align 4
  57. @@:
  58.         dec     al
  59.         jnz     @f
  60.  
  61.         ; type II - only reserve area, no draw
  62. ;        call    sys_window_mouse
  63. ;        call    [draw_pointer]
  64.         call    __sys_draw_pointer
  65.         jmp     .exit
  66. ;--------------------------------------
  67. align 4
  68. @@:
  69.         dec     al
  70.         jnz     @f
  71.  
  72.         ; type III  - new style
  73.         call    drawwindow_III
  74.         jmp     window._.draw_window_caption.2
  75.  
  76.         ; type IV & V - skinned window (resizable & not)
  77. ;--------------------------------------
  78. align 4
  79. @@:
  80.         mov     eax, [TASK_COUNT]
  81.         movzx   eax, word[WIN_POS + eax * 2]
  82.         cmp     eax, [CURRENT_TASK]
  83.         setz    al
  84.         movzx   eax, al
  85.         push    eax
  86.         call    drawwindow_IV
  87.         jmp     window._.draw_window_caption.2
  88. ;--------------------------------------
  89. align 4
  90. .exit:
  91.         ret
  92. ;------------------------------------------------------------------------------
  93. align 4
  94. ;------------------------------------------------------------------------------
  95. syscall_display_settings: ;///// system function 48 ///////////////////////////
  96. ;------------------------------------------------------------------------------
  97. ;; Redraw screen:
  98. ;< ebx = 0
  99. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  100. ;; Set button style:
  101. ;< ebx = 1
  102. ;< ecx = 0 (flat) or 1 (with gradient)
  103. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  104. ;; Set system color palette:
  105. ;< ebx = 2
  106. ;< ecx = pointer to color table
  107. ;< edx = size of color table
  108. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  109. ;; Get system color palette:
  110. ;< ebx = 3
  111. ;< ecx = pointer to color table buffer
  112. ;< edx = size of color table buffer
  113. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  114. ;; Get skinned caption height:
  115. ;< ebx = 4
  116. ;> eax = height in pixels
  117. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  118. ;; Get screen working area:
  119. ;< ebx = 5
  120. ;> eax = pack[16(left), 16(right)]
  121. ;> ebx = pack[16(top), 16(bottom)]
  122. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  123. ;; Set screen working area:
  124. ;< ebx = 6
  125. ;< ecx = pack[16(left), 16(right)]
  126. ;< edx = pack[16(top), 16(bottom)]
  127. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  128. ;; Get skin margins:
  129. ;< ebx = 7
  130. ;> eax = pack[16(left), 16(right)]
  131. ;> ebx = pack[16(top), 16(bottom)]
  132. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  133. ;; Set skin:
  134. ;< ebx = 8
  135. ;< ecx = pointer to FileInfoBlock struct
  136. ;> eax = FS error code
  137. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  138. ;; Set font smoothing:
  139. ;< ebx = 9
  140. ;< ecx = 0 (off) or !0 (on)
  141. ;------------------------------------------------------------------------------
  142.         cmp     ebx, .sizeof.ftable / 4
  143.         ja      @f
  144.         jmp     [.ftable + ebx * 4]
  145. ;--------------------------------------
  146. align 4
  147. @@:
  148.         ret
  149. ;------------------------------------------------------------------------------
  150. align 4
  151. syscall_display_settings.00:
  152.         xor     eax, eax
  153.         inc     ebx
  154.         cmp     [windowtypechanged], ebx
  155.         jne     .exit
  156.         mov     [windowtypechanged], eax
  157.  
  158.         jmp     syscall_display_settings._.redraw_whole_screen
  159. ;--------------------------------------
  160. align 4
  161. .exit:
  162.         ret
  163. ;------------------------------------------------------------------------------
  164. align 4
  165. syscall_display_settings.01:
  166.         and     ecx, 1
  167.         cmp     ecx, [buttontype]
  168.         je      .exit
  169.         mov     [buttontype], ecx
  170.         mov     [windowtypechanged], ebx
  171. ;--------------------------------------
  172. align 4
  173.   .exit:
  174.         ret
  175. ;------------------------------------------------------------------------------
  176. align 4
  177. syscall_display_settings.02:
  178.         dec     ebx
  179.         mov     esi, ecx
  180.         cmp     edx, 192
  181.         jnae    @f
  182.         mov     edx, 192 ; max size
  183.       @@:
  184.         mov     edi, common_colours
  185.         mov     ecx, edx
  186.         rep movsb
  187.         mov     [windowtypechanged], ebx
  188.         ret
  189. ;------------------------------------------------------------------------------
  190. align 4
  191. syscall_display_settings.03:
  192.         mov     edi, ecx
  193.         cmp     edx, 192
  194.         jnae    @f
  195.         mov     edx, 192 ; max size
  196.       @@:
  197.         mov     esi, common_colours
  198.         mov     ecx, edx
  199.         rep movsb
  200.         ret
  201. ;------------------------------------------------------------------------------
  202. align 4
  203. syscall_display_settings.04:
  204.         mov     eax, [_skinh]
  205.         mov     [esp + 32], eax
  206.         ret
  207. ;------------------------------------------------------------------------------
  208. align 4
  209. syscall_display_settings.05:
  210.         mov     eax, [screen_workarea.left - 2]
  211.         mov     ax, word[screen_workarea.right]
  212.         mov     [esp + 32], eax
  213.         mov     eax, [screen_workarea.top - 2]
  214.         mov     ax, word[screen_workarea.bottom]
  215.         mov     [esp + 20], eax
  216.         ret
  217. ;------------------------------------------------------------------------------
  218. align 4
  219. syscall_display_settings.06:
  220.         xor     esi, esi
  221.  
  222.         mov     edi, [_display.width]
  223.         dec     edi
  224.         mov     eax, ecx
  225.         movsx   ebx, ax
  226.         sar     eax, 16
  227.         cmp     eax, ebx
  228.         jge     .check_horizontal
  229.         inc     esi
  230.         or      eax, eax
  231.         jge     @f
  232.         xor     eax, eax
  233. ;--------------------------------------
  234. align 4
  235. @@:
  236.         mov     [screen_workarea.left], eax
  237.         cmp     ebx, edi
  238.         jle     @f
  239.         mov     ebx, edi
  240. ;--------------------------------------
  241. align 4
  242. @@:
  243.         mov     [screen_workarea.right], ebx
  244. ;--------------------------------------
  245. align 4
  246. .check_horizontal:
  247.         mov     edi, [_display.height]
  248.         dec     edi
  249.         mov     eax, edx
  250.         movsx   ebx, ax
  251.         sar     eax, 16
  252.         cmp     eax, ebx
  253.         jge     .check_if_redraw_needed
  254.         inc     esi
  255.         or      eax, eax
  256.         jge     @f
  257.         xor     eax, eax
  258. ;--------------------------------------
  259. align 4
  260. @@:
  261.         mov     [screen_workarea.top], eax
  262.         cmp     ebx, edi
  263.         jle     @f
  264.         mov     ebx, edi
  265. ;--------------------------------------
  266. align 4
  267. @@:
  268.         mov     [screen_workarea.bottom], ebx
  269. ;--------------------------------------
  270. align 4
  271. .check_if_redraw_needed:
  272.         or      esi, esi
  273.         jz      .exit
  274.  
  275.         call    repos_windows
  276.         jmp     syscall_display_settings._.calculate_whole_screen
  277. ;--------------------------------------
  278. align 4
  279. .exit:
  280.         ret
  281. ;------------------------------------------------------------------------------
  282. align 4
  283. syscall_display_settings.07:
  284.         mov     eax, [_skinmargins + 0]
  285.         mov     [esp + 32], eax
  286.         mov     eax, [_skinmargins + 4]
  287.         mov     [esp + 20], eax
  288.         ret
  289. ;------------------------------------------------------------------------------
  290. align 4
  291. syscall_display_settings.08:
  292.         mov     ebx, ecx
  293.         call    read_skin_file
  294.         mov     [esp + 32], eax
  295.         test    eax, eax
  296.         jnz     .exit
  297.  
  298.         call    syscall_display_settings._.calculate_whole_screen
  299.         jmp     syscall_display_settings._.redraw_whole_screen
  300. ;--------------------------------------
  301. align 4
  302. .exit:
  303.         ret
  304. ;------------------------------------------------------------------------------
  305. align 4
  306. syscall_display_settings.09:
  307.         mov     [fontSmoothing], cl
  308.         ret
  309. ;------------------------------------------------------------------------------
  310. align 4
  311. syscall_display_settings._.calculate_whole_screen:
  312.         xor     eax, eax
  313.         xor     ebx, ebx
  314.         mov     ecx, [_display.width]
  315.         mov     edx, [_display.height]
  316.         dec     ecx
  317.         dec     edx
  318.         jmp     calculatescreen
  319. ;------------------------------------------------------------------------------
  320. align 4
  321. syscall_display_settings._.redraw_whole_screen:
  322.         xor     eax, eax
  323.         mov     [draw_limits.left], eax
  324.         mov     [draw_limits.top], eax
  325.         mov     eax, [_display.width]
  326.         dec     eax
  327.         mov     [draw_limits.right], eax
  328.         mov     eax, [_display.height]
  329.         dec     eax
  330.         mov     [draw_limits.bottom], eax
  331.         mov     eax, window_data
  332.         jmp     redrawscreen
  333. ;------------------------------------------------------------------------------
  334. align 4
  335. ;------------------------------------------------------------------------------
  336. syscall_set_window_shape: ;///// system function 50 ///////////////////////////
  337. ;------------------------------------------------------------------------------
  338. ;; Set window shape address:
  339. ;> ebx = 0
  340. ;> ecx = shape data address
  341. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  342. ;; Set window shape scale:
  343. ;> ebx = 1
  344. ;> ecx = scale power (resulting scale is 2^ebx)
  345. ;------------------------------------------------------------------------------
  346.         mov     edi, [current_slot]
  347.  
  348.         test    ebx, ebx
  349.         jne     .shape_scale
  350.         mov     [edi + APPDATA.wnd_shape], ecx
  351. ;--------------------------------------
  352. align 4
  353. .shape_scale:
  354.         dec     ebx
  355.         jnz     .exit
  356.         mov     [edi + APPDATA.wnd_shape_scale], ecx
  357. ;--------------------------------------
  358. align 4
  359. .exit:
  360.         ret
  361. ;------------------------------------------------------------------------------
  362. align 4
  363. ;------------------------------------------------------------------------------
  364. syscall_move_window: ;///// system function 67 ////////////////////////////////
  365. ;------------------------------------------------------------------------------
  366. ;? <description>
  367. ;------------------------------------------------------------------------------
  368.         mov     edi, [CURRENT_TASK]
  369.         shl     edi, 5
  370.         add     edi, window_data
  371.  
  372.         test    [edi + WDATA.fl_wdrawn], 1
  373.         jz      .exit
  374.  
  375.         test    [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
  376.         jnz     .exit
  377.  
  378.         cmp     ebx, -1
  379.         jne     @f
  380.         mov     ebx, [edi + WDATA.box.left]
  381. ;--------------------------------------
  382. align 4
  383. @@:
  384.         cmp     ecx, -1
  385.         jne     @f
  386.         mov     ecx, [edi + WDATA.box.top]
  387. ;--------------------------------------
  388. align 4
  389. @@:
  390.         cmp     edx, -1
  391.         jne     @f
  392.         mov     edx, [edi + WDATA.box.width]
  393. ;--------------------------------------
  394. align 4
  395. @@:
  396.         cmp     esi, -1
  397.         jne     @f
  398.         mov     esi, [edi + WDATA.box.height]
  399. ;--------------------------------------
  400. align 4
  401. @@:
  402.         push    esi edx ecx ebx
  403.         mov     eax, esp
  404.         mov     bl, [edi + WDATA.fl_wstate]
  405. ;--------------------------------------
  406. align 4
  407. @@:
  408.         cmp     [REDRAW_BACKGROUND], byte 0
  409.         jz      @f
  410.         call    change_task
  411.         jmp     @b
  412. ;--------------------------------------
  413. align 4
  414. @@:
  415.         call    window._.set_window_box
  416.         add     esp, sizeof.BOX
  417.  
  418.         ; NOTE: do we really need this? to be reworked
  419. ;       mov     byte[DONT_DRAW_MOUSE], 0 ; mouse pointer
  420. ;       mov     byte[MOUSE_BACKGROUND], 0 ; no mouse under
  421. ;       mov     byte[MOUSE_DOWN], 0 ; react to mouse up/down
  422.  
  423.         ; NOTE: do we really need this? to be reworked
  424. ;       call    [draw_pointer]
  425. ;--------------------------------------
  426. align 4
  427. .exit:
  428.         ret
  429. ;------------------------------------------------------------------------------
  430. align 4
  431. ;------------------------------------------------------------------------------
  432. syscall_window_settings: ;///// system function 71 /////////////////////////////
  433. ;------------------------------------------------------------------------------
  434. ;? <description>
  435. ;------------------------------------------------------------------------------
  436.         dec     ebx     ; subfunction #1 - set window caption
  437.         jnz     .exit_fail
  438.  
  439.         ; NOTE: only window owner thread can set its caption,
  440.         ;       so there's no parameter for PID/TID
  441.  
  442.         mov     edi, [CURRENT_TASK]
  443.         shl     edi, 5
  444.  
  445.         mov     [edi * 8 + SLOT_BASE + APPDATA.wnd_caption], ecx
  446.         or      [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
  447.  
  448.         call    window._.draw_window_caption
  449.  
  450.         xor     eax, eax ; eax = 0 (success)
  451.         ret
  452.  
  453. ;  .get_window_caption:
  454. ;        dec     eax     ; subfunction #2 - get window caption
  455. ;        jnz     .exit_fail
  456.  
  457.         ; not implemented yet
  458. ;--------------------------------------
  459. align 4
  460. .exit_fail:
  461.         xor     eax, eax
  462.         inc     eax     ; eax = 1 (fail)
  463.         ret
  464. ;------------------------------------------------------------------------------
  465. align 4
  466. ;------------------------------------------------------------------------------
  467. set_window_defaults: ;/////////////////////////////////////////////////////////
  468. ;------------------------------------------------------------------------------
  469. ;? <description>
  470. ;------------------------------------------------------------------------------
  471.         mov     byte [window_data + 0x20 + WDATA.cl_titlebar + 3], 1 ; desktop is not movable
  472.         push    eax ecx
  473.         xor     eax, eax
  474.         mov     ecx, WIN_STACK
  475. ;--------------------------------------
  476. align 4
  477. @@:
  478.         inc     eax
  479.         add     ecx, 2
  480.         ; process no
  481.         mov     [ecx + 0x000], ax
  482.         ; positions in stack
  483.         mov     [ecx + 0x400], ax
  484.         cmp     ecx, WIN_POS - 2
  485.         jne     @b
  486.         pop     ecx eax
  487.         ret
  488. ;------------------------------------------------------------------------------
  489. iglobal
  490. win_zmodi db ZPOS_DESKTOP,\
  491.              ZPOS_ALWAYS_BACK,\
  492.              ZPOS_NORMAL,\
  493.              ZPOS_ALWAYS_TOP
  494. endg
  495. align 4
  496. ;------------------------------------------------------------------------------
  497. calculatescreen: ;/////////////////////////////////////////////////////////////
  498. ;------------------------------------------------------------------------------
  499. ;? Scan all windows from bottom to top, calling `setscreen` for each one
  500. ;? intersecting given screen area
  501. ;------------------------------------------------------------------------------
  502. ;> eax = left
  503. ;> ebx = top
  504. ;> ecx = right
  505. ;> edx = bottom
  506. ;------------------------------------------------------------------------------
  507.         push    esi
  508.         pushfd
  509.         cli
  510.  
  511.         mov     esi, 1
  512.         call    window._.set_screen
  513.  
  514.         push    ebp
  515.  
  516.         mov     ebp, [TASK_COUNT]
  517.         cmp     ebp, 1
  518.         jbe     .exit
  519.  
  520.         push    eax ;for num layout
  521.  
  522.         push    edx ecx ebx eax
  523.  
  524.         mov     dword[esp+14], 0
  525. ;--------------------------------------
  526. align 4
  527. .layout:
  528.         mov     esi, 1          ; = num in window stack
  529.         mov     ebp, [TASK_COUNT]
  530. ;--------------------------------------
  531. align 4
  532. .next_window:
  533.         movzx   edi, word[WIN_POS + esi * 2]
  534.         shl     edi, 5                  ;size of TASKDATA and WDATA = 32 bytes
  535.  
  536.         cmp     [CURRENT_TASK + edi + TASKDATA.state], TSTATE_FREE
  537.         je      .skip_window
  538.  
  539.         add     edi, window_data
  540.         test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
  541.         jnz     .skip_window
  542.  
  543.         mov     eax, [esp+14]
  544.         mov     al, [eax+win_zmodi]
  545.         cmp     [edi + WDATA.z_modif], al
  546.         jne     .skip_window
  547.  
  548.         mov     eax, [edi + WDATA.box.left]
  549.         cmp     eax, [esp + RECT.right]
  550.         jg      .skip_window
  551.         mov     ebx, [edi + WDATA.box.top]
  552.         cmp     ebx, [esp + RECT.bottom]
  553.         jg      .skip_window
  554.         mov     ecx, [edi + WDATA.box.width]
  555.         add     ecx, eax
  556.         cmp     ecx, [esp + RECT.left]
  557.         jl      .skip_window
  558.         mov     edx, [edi + WDATA.box.height]
  559.         add     edx, ebx
  560.         cmp     edx, [esp + RECT.top]
  561.         jl      .skip_window
  562.  
  563.         cmp     eax, [esp + RECT.left]
  564.         jae     @f
  565.         mov     eax, [esp + RECT.left]
  566. ;--------------------------------------
  567. align 4
  568. @@:
  569.         cmp     ebx, [esp + RECT.top]
  570.         jae     @f
  571.         mov     ebx, [esp + RECT.top]
  572. ;--------------------------------------
  573. align 4
  574. @@:
  575.         cmp     ecx, [esp + RECT.right]
  576.         jbe     @f
  577.         mov     ecx, [esp + RECT.right]
  578. ;--------------------------------------
  579. align 4
  580. @@:
  581.         cmp     edx, [esp + RECT.bottom]
  582.         jbe     @f
  583.         mov     edx, [esp + RECT.bottom]
  584. ;--------------------------------------
  585. align 4
  586. @@:
  587.         push    esi
  588.         movzx   esi, word[WIN_POS + esi * 2]
  589.         call    window._.set_screen
  590.         pop     esi
  591. ;--------------------------------------
  592. align 4
  593. .skip_window:
  594.         inc     esi
  595.         dec     ebp
  596.         jnz     .next_window
  597. ;---------------------------------------------
  598.         inc     dword[esp+14]
  599.         cmp     dword[esp+14], ZPOS_ALWAYS_TOP
  600.         jbe     .layout
  601. ;---------------------------------------------
  602.         mov     esi, [TASK_COUNT]
  603.         movzx   edi, word[WIN_POS + esi * 2]
  604.         shl     edi, 5
  605.         add     edi, window_data
  606.  
  607.         pop     eax ebx ecx edx
  608.         pop     ebp     ;del num layout
  609. ;--------------------------------------
  610. align 4
  611. .exit:
  612.         pop     ebp
  613.         inc     [_display.mask_seqno]
  614.         popfd
  615.         pop     esi
  616.         ret
  617. ;------------------------------------------------------------------------------
  618. align 4
  619. ;------------------------------------------------------------------------------
  620. repos_windows: ;///////////////////////////////////////////////////////////////
  621. ;------------------------------------------------------------------------------
  622. ;? <description>
  623. ;------------------------------------------------------------------------------
  624.         mov     ecx, [TASK_COUNT]
  625.         mov     edi, window_data + sizeof.WDATA * 2
  626.         call    force_redraw_background
  627.         dec     ecx
  628.         jle     .exit
  629. ;--------------------------------------
  630. align 4
  631. .next_window:
  632.         mov     [edi + WDATA.fl_redraw], 1
  633.         test    [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
  634.         jnz     .fix_maximized
  635.  
  636.         mov     eax, [edi + WDATA.box.left]
  637.         add     eax, [edi + WDATA.box.width]
  638.         mov     ebx, [_display.width]
  639.         cmp     eax, ebx
  640.         jl      .fix_vertical
  641.         mov     eax, [edi + WDATA.box.width]
  642.         sub     eax, ebx
  643.         jl      @f
  644.         mov     [edi + WDATA.box.width], ebx
  645. ;--------------------------------------
  646. align 4
  647. @@:
  648.         sub     ebx, [edi + WDATA.box.width]
  649.         mov     [edi + WDATA.box.left], ebx
  650. ;--------------------------------------
  651. align 4
  652. .fix_vertical:
  653.         mov     eax, [edi + WDATA.box.top]
  654.         add     eax, [edi + WDATA.box.height]
  655.         mov     ebx, [_display.height]
  656.         cmp     eax, ebx
  657.         jl      .fix_client_box
  658.         mov     eax, [edi + WDATA.box.height]
  659.         sub     eax, ebx
  660.         jl      @f
  661.         mov     [edi + WDATA.box.height], ebx
  662. ;--------------------------------------
  663. align 4
  664. @@:
  665.         sub     ebx, [edi + WDATA.box.height]
  666.         mov     [edi + WDATA.box.top], ebx
  667. ;--------------------------------------
  668. align 4
  669. .fix_client_box:
  670.         call    window._.set_window_clientbox
  671.         add     edi, sizeof.WDATA
  672.         loop    .next_window
  673. ;--------------------------------------
  674. align 4
  675. .exit:
  676.         ret
  677. ;--------------------------------------
  678. align 4
  679. .fix_maximized:
  680.         mov     eax, [screen_workarea.left]
  681.         mov     [edi + WDATA.box.left], eax
  682.         sub     eax, [screen_workarea.right]
  683.         neg     eax
  684.         mov     [edi + WDATA.box.width], eax
  685.         mov     eax, [screen_workarea.top]
  686.         mov     [edi + WDATA.box.top], eax
  687.         test    [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
  688.         jnz     .fix_client_box
  689.         sub     eax, [screen_workarea.bottom]
  690.         neg     eax
  691.         mov     [edi + WDATA.box.height], eax
  692.         jmp     .fix_client_box
  693. ;------------------------------------------------------------------------------
  694. ;align 4
  695. ;------------------------------------------------------------------------------
  696. ;sys_window_mouse: ;////////////////////////////////////////////////////////////
  697. ;------------------------------------------------------------------------------
  698. ;? <description>
  699. ;------------------------------------------------------------------------------
  700.         ; NOTE: commented out since doesn't provide necessary functionality
  701.         ;       anyway, to be reworked
  702. ;       push    eax
  703. ;
  704. ;       mov     eax, [timer_ticks]
  705. ;       cmp     [new_window_starting], eax
  706. ;       jb      .exit
  707. ;
  708. ;       mov     byte[MOUSE_BACKGROUND], 0
  709. ;       mov     byte[DONT_DRAW_MOUSE], 0
  710. ;
  711. ;       mov     [new_window_starting], eax
  712. ;
  713. ; .exit:
  714. ;       pop     eax
  715. ;        ret
  716. ;------------------------------------------------------------------------------
  717. align 4
  718. ;------------------------------------------------------------------------------
  719. draw_rectangle: ;//////////////////////////////////////////////////////////////
  720. ;------------------------------------------------------------------------------
  721. ;> eax = pack[16(left), 16(right)]
  722. ;> ebx = pack[16(top), 16(bottom)]
  723. ;> esi = color
  724. ;       ?? RR GG BB    ; 0x01000000 negation
  725. ;                      ; 0x02000000 used for draw_rectangle without top line
  726. ;                      ;           for example drawwindow_III and drawwindow_IV
  727. ;------------------------------------------------------------------------------
  728.         push    eax ebx ecx edi
  729.  
  730.         xor     edi, edi
  731. ;--------------------------------------
  732. align 4
  733. .flags_set:
  734.         push    ebx
  735.  
  736.         ; set line color
  737.         mov     ecx, esi
  738.         ; draw top border
  739.         rol     ebx, 16
  740.         push    ebx
  741.         rol     ebx, 16
  742.         pop     bx
  743.         test    ecx, 1 shl 25
  744.         jnz     @f
  745.         sub     ecx, 1 shl 25
  746. ;        call    [draw_line]
  747.         call    __sys_draw_line
  748. ;--------------------------------------
  749. align 4
  750. @@:
  751.         ; draw bottom border
  752.         mov     ebx, [esp - 2]
  753.         pop     bx
  754. ;        call    [draw_line]
  755.         call    __sys_draw_line
  756.  
  757.         pop     ebx
  758.         add     ebx, 1 * 65536 - 1
  759.  
  760.         ; draw left border
  761.         rol     eax, 16
  762.         push    eax
  763.         rol     eax, 16
  764.         pop     ax
  765. ;        call    [draw_line]
  766.         call    __sys_draw_line
  767.  
  768.         ; draw right border
  769.         mov     eax, [esp - 2]
  770.         pop     ax
  771. ;        call    [draw_line]
  772.         call    __sys_draw_line
  773.  
  774.         pop     edi ecx ebx eax
  775.         ret
  776. ;--------------------------------------
  777. align 4
  778. .forced:
  779.         push    eax ebx ecx edi
  780.         xor     edi, edi
  781.         inc     edi
  782.         jmp     .flags_set
  783. ;------------------------------------------------------------------------------
  784. align 4
  785. ;------------------------------------------------------------------------------
  786. drawwindow_I_caption: ;////////////////////////////////////////////////////////
  787. ;------------------------------------------------------------------------------
  788. ;? <description>
  789. ;------------------------------------------------------------------------------
  790.         push    [edx + WDATA.cl_titlebar]
  791.         mov     esi, edx
  792.  
  793.         mov     edx, [esi + WDATA.box.top]
  794.         mov     eax, edx
  795.         lea     ebx, [edx + 21]
  796.         inc     edx
  797.         add     eax, [esi + WDATA.box.height]
  798.  
  799.         cmp     ebx, eax
  800.         jbe     @f
  801.         mov     ebx, eax
  802. ;--------------------------------------
  803. align 4
  804. @@:
  805.         push    ebx
  806.  
  807.         xor     edi, edi
  808. ;--------------------------------------
  809. align 4
  810. .next_line:
  811.         mov     ebx, edx
  812.         shl     ebx, 16
  813.         add     ebx, edx
  814.         mov     eax, [esi + WDATA.box.left]
  815.         inc     eax
  816.         shl     eax, 16
  817.         add     eax, [esi + WDATA.box.left]
  818.         add     eax, [esi + WDATA.box.width]
  819.         dec     eax
  820.         mov     ecx, [esi + WDATA.cl_titlebar]
  821.         test    ecx, 0x80000000
  822.         jz      @f
  823.         sub     ecx, 0x00040404
  824.         mov     [esi + WDATA.cl_titlebar], ecx
  825. ;--------------------------------------
  826. align 4
  827. @@:
  828.         and     ecx, 0x00ffffff
  829. ;        call    [draw_line]
  830.         call    __sys_draw_line
  831.         inc     edx
  832.         cmp     edx, [esp]
  833.         jb      .next_line
  834.  
  835.         add     esp, 4
  836.         pop     [esi + WDATA.cl_titlebar]
  837.         ret
  838. ;------------------------------------------------------------------------------
  839. align 4
  840. ;------------------------------------------------------------------------------
  841. drawwindow_I: ;////////////////////////////////////////////////////////////////
  842. ;------------------------------------------------------------------------------
  843. ;? <description>
  844. ;------------------------------------------------------------------------------
  845.         pushad
  846.  
  847.         ; window border
  848.  
  849.         mov     eax, [edx + WDATA.box.left - 2]
  850.         mov     ax, word[edx + WDATA.box.left]
  851.         add     ax, word[edx + WDATA.box.width]
  852.         mov     ebx, [edx + WDATA.box.top - 2]
  853.         mov     bx, word[edx + WDATA.box.top]
  854.         add     bx, word[edx + WDATA.box.height]
  855.  
  856.         mov     esi, [edx + WDATA.cl_frames]
  857.         call    draw_rectangle
  858.  
  859.         ; window caption
  860.  
  861.         call    drawwindow_I_caption
  862.  
  863.         ; window client area
  864.  
  865.         ; do we need to draw it?
  866.         mov     edi, [esi + WDATA.cl_workarea]
  867.         test    edi, 0x40000000
  868.         jnz     .exit
  869.  
  870.         ; does client area have a positive size on screen?
  871.         cmp     [esi + WDATA.box.height], 21
  872.         jle     .exit
  873.  
  874.         ; okay, let's draw it
  875.         mov     eax, 1
  876.         mov     ebx, 21
  877.         mov     ecx, [esi + WDATA.box.width]
  878.         mov     edx, [esi + WDATA.box.height]
  879. ;        call    [drawbar]
  880.         call    vesa20_drawbar
  881. ;--------------------------------------
  882. align 4
  883. .exit:
  884.         popad
  885.         ret
  886. ;------------------------------------------------------------------------------
  887. align 4
  888. ;------------------------------------------------------------------------------
  889. drawwindow_III_caption: ;/////////////////////////////////////////////////////
  890. ;------------------------------------------------------------------------------
  891. ;? <description>
  892. ;------------------------------------------------------------------------------
  893.         mov     ecx, [edx + WDATA.cl_titlebar]
  894.         push    ecx
  895.         mov     esi, edx
  896.         mov     edx, [esi + WDATA.box.top]
  897.         add     edx, 4
  898.         mov     ebx, [esi + WDATA.box.top]
  899.         add     ebx, 20
  900.         mov     eax, [esi + WDATA.box.top]
  901.         add     eax, [esi + WDATA.box.height]
  902.  
  903.         cmp     ebx, eax
  904.         jb      @f
  905.         mov     ebx, eax
  906. ;--------------------------------------
  907. align 4
  908. @@:
  909.         push    ebx
  910.  
  911.         xor     edi, edi
  912. ;--------------------------------------
  913. align 4
  914. .next_line:
  915.         mov     ebx, edx
  916.         shl     ebx, 16
  917.         add     ebx, edx
  918.         mov     eax, [esi + WDATA.box.left]
  919.         shl     eax, 16
  920.         add     eax, [esi + WDATA.box.left]
  921.         add     eax, [esi + WDATA.box.width]
  922.         add     eax, 4 * 65536 - 4
  923.         mov     ecx, [esi + WDATA.cl_titlebar]
  924.         test    ecx, 0x40000000
  925.         jz      @f
  926.         add     ecx, 0x00040404
  927. ;--------------------------------------
  928. align 4
  929. @@:
  930.         test    ecx, 0x80000000
  931.         jz      @f
  932.         sub     ecx, 0x00040404
  933. ;--------------------------------------
  934. align 4
  935. @@:
  936.         mov     [esi + WDATA.cl_titlebar], ecx
  937.         and     ecx, 0x00ffffff
  938. ;        call    [draw_line]
  939.         call    __sys_draw_line
  940.         inc     edx
  941.         cmp     edx, [esp]
  942.         jb      .next_line
  943.  
  944.         add     esp, 4
  945.         pop     [esi + WDATA.cl_titlebar]
  946.         ret
  947. ;------------------------------------------------------------------------------
  948. align 4
  949. ;------------------------------------------------------------------------------
  950. drawwindow_III: ;//////////////////////////////////////////////////////////////
  951. ;------------------------------------------------------------------------------
  952. ;? <description>
  953. ;------------------------------------------------------------------------------
  954.         pushad
  955.  
  956.         ; window border
  957.  
  958.         mov     eax, [edx + WDATA.box.left - 2]
  959.         mov     ax, word[edx + WDATA.box.left]
  960.         add     ax, word[edx + WDATA.box.width]
  961.         mov     ebx, [edx + WDATA.box.top - 2]
  962.         mov     bx, word[edx + WDATA.box.top]
  963.         add     bx, word[edx + WDATA.box.height]
  964.  
  965.         mov     esi, [edx + WDATA.cl_frames]
  966.         shr     esi, 1
  967.         and     esi, 0x007f7f7f
  968.         call    draw_rectangle
  969.  
  970.         push    esi
  971.         mov     ecx, 3
  972.         mov     esi, [edx + WDATA.cl_frames]
  973. ;--------------------------------------
  974. align 4
  975. .next_frame:
  976.         add     eax, 1 * 65536 - 1
  977.         add     ebx, 1 * 65536 - 1
  978.         call    draw_rectangle
  979.         dec     ecx
  980.         jnz     .next_frame
  981.  
  982.         pop     esi
  983.         add     eax, 1 * 65536 - 1
  984.         add     ebx, 1 * 65536 - 1
  985.         call    draw_rectangle
  986.  
  987.         ; window caption
  988.  
  989.         call    drawwindow_III_caption
  990.  
  991.         ; window client area
  992.  
  993.         ; do we need to draw it?
  994.         mov     edi, [esi + WDATA.cl_workarea]
  995.         test    edi, 0x40000000
  996.         jnz     .exit
  997.  
  998.         ; does client area have a positive size on screen?
  999.         mov     edx, [esi + WDATA.box.top]
  1000.         add     edx, 21 + 5
  1001.         mov     ebx, [esi + WDATA.box.top]
  1002.         add     ebx, [esi + WDATA.box.height]
  1003.         cmp     edx, ebx
  1004.         jg      .exit
  1005.  
  1006.         ; okay, let's draw it
  1007.         mov     eax, 5
  1008.         mov     ebx, 20
  1009.         mov     ecx, [esi + WDATA.box.width]
  1010.         mov     edx, [esi + WDATA.box.height]
  1011.         sub     ecx, 4
  1012.         sub     edx, 4
  1013. ;        call    [drawbar]
  1014.         call    vesa20_drawbar
  1015. ;--------------------------------------
  1016. align 4
  1017. .exit:
  1018.         popad
  1019.         ret
  1020. ;------------------------------------------------------------------------------
  1021. align 4
  1022. ;------------------------------------------------------------------------------
  1023. waredraw: ;////////////////////////////////////////////////////////////////////
  1024. ;------------------------------------------------------------------------------
  1025. ;? Activate window, redrawing if necessary
  1026. ;------------------------------------------------------------------------------
  1027.         push    -1
  1028.         mov     eax, [TASK_COUNT]
  1029.         lea     eax, [WIN_POS + eax * 2]
  1030.         cmp     eax, esi
  1031.         pop     eax
  1032.         je      .exit
  1033.  
  1034.         ; is it overlapped by another window now?
  1035.         push    ecx
  1036.         call    window._.check_window_draw
  1037.         test    ecx, ecx
  1038.         pop     ecx
  1039.         jz      .do_not_draw
  1040.  
  1041.         ; yes it is, activate and update screen buffer
  1042.         call    window._.window_activate
  1043.  
  1044.         pushad
  1045.         mov     edi, [TASK_COUNT]
  1046.         movzx   esi, word[WIN_POS + edi * 2]
  1047.         shl     esi, 5
  1048.         add     esi, window_data
  1049.  
  1050.         mov     eax, [esi + WDATA.box.left]
  1051.         mov     ebx, [esi + WDATA.box.top]
  1052.         mov     ecx, [esi + WDATA.box.width]
  1053.         mov     edx, [esi + WDATA.box.height]
  1054.  
  1055.         add     ecx, eax
  1056.         add     edx, ebx
  1057.  
  1058.         mov     edi, [TASK_COUNT]
  1059.         movzx   esi, word[WIN_POS + edi * 2]
  1060.         call    window._.set_screen
  1061.  
  1062.         call    window._.set_top_wnd    ;Fantomer
  1063.  
  1064.         inc     [_display.mask_seqno]
  1065.         popad
  1066.  
  1067.         ; tell application to redraw itself
  1068.         mov     [edi + WDATA.fl_redraw], 1
  1069.         xor     eax, eax
  1070.         jmp     .exit
  1071. ;--------------------------------------
  1072. align 4
  1073. .do_not_draw:
  1074.         ; no it's not, just activate the window
  1075.         call    window._.window_activate
  1076.         xor     eax, eax
  1077.         ret
  1078.  
  1079. ;--------------------------------------
  1080. align 4
  1081. .exit:
  1082.         inc     eax
  1083.         ret
  1084. ;------------------------------------------------------------------------------
  1085. align 4
  1086. ;------------------------------------------------------------------------------
  1087. minimize_all_window:
  1088.         push    ebx ecx edx esi edi
  1089.         pushfd
  1090.         cli
  1091.         xor     edx, edx
  1092.         mov     eax, 2  ; we do not minimize the kernel thread N1
  1093.         mov     ebx, [TASK_COUNT]
  1094. ;--------------------------------------
  1095. align 4
  1096. .loop:
  1097.         movzx   edi, word[WIN_POS + eax * 2]
  1098.         shl     edi, 5
  1099. ; it is a unused slot?
  1100.         cmp     dword [edi+CURRENT_TASK+TASKDATA.state], 9
  1101.         je      @f
  1102. ; it is a hidden thread?
  1103.         lea     esi, [edi*8+SLOT_BASE+APPDATA.app_name]
  1104.         cmp     [esi], byte '@'
  1105.         je      @f
  1106. ; is it already minimized?
  1107.         test    [edi + window_data+WDATA.fl_wstate], WSTATE_MINIMIZED
  1108.         jnz     @f
  1109. ; no it's not, let's do that
  1110.         or      [edi + window_data+WDATA.fl_wstate], WSTATE_MINIMIZED
  1111.         inc     edx
  1112. ;--------------------------------------
  1113. align 4
  1114. @@:
  1115.         inc     eax
  1116.         cmp     eax, ebx
  1117.         jbe     .loop
  1118. ; If nothing has changed
  1119.         test    edx, edx
  1120.         jz      @f
  1121.  
  1122.         push    edx
  1123.         call    syscall_display_settings._.calculate_whole_screen
  1124.         call    syscall_display_settings._.redraw_whole_screen
  1125.         pop     edx
  1126. ;--------------------------------------
  1127. align 4
  1128. @@:
  1129.         mov     eax, edx
  1130.         popfd
  1131.         pop     edi esi edx ecx ebx
  1132.         ret
  1133. ;------------------------------------------------------------------------------
  1134. align 4
  1135. ;------------------------------------------------------------------------------
  1136. minimize_window: ;/////////////////////////////////////////////////////////////
  1137. ;------------------------------------------------------------------------------
  1138. ;> eax = window number on screen
  1139. ;------------------------------------------------------------------------------
  1140. ;# corrupts [dl*]
  1141. ;------------------------------------------------------------------------------
  1142.         push    edi
  1143.         pushfd
  1144.         cli
  1145.  
  1146.         ; is it already minimized?
  1147.         movzx   edi, word[WIN_POS + eax * 2]
  1148.         shl     edi, 5
  1149.         add     edi, window_data
  1150.         test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
  1151.         jnz     .exit
  1152.  
  1153.         push    eax ebx ecx edx esi
  1154.  
  1155.         ; no it's not, let's do that
  1156.         or      [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
  1157. ; If the window width is 0, then the action is not needed.
  1158.         cmp     [edi + WDATA.box.width], dword 0
  1159.         je      @f
  1160. ; If the window height is 0, then the action is not needed.
  1161.         cmp     [edi + WDATA.box.height], dword 0
  1162.         je      @f
  1163.  
  1164.         mov     eax, [edi + WDATA.box.left]
  1165.         mov     [draw_limits.left], eax
  1166.         mov     ecx, eax
  1167.         add     ecx, [edi + WDATA.box.width]
  1168.         mov     [draw_limits.right], ecx
  1169.         mov     ebx, [edi + WDATA.box.top]
  1170.         mov     [draw_limits.top], ebx
  1171.         mov     edx, ebx
  1172.         add     edx, [edi + WDATA.box.height]
  1173.         mov     [draw_limits.bottom], edx
  1174.  
  1175. ;        DEBUGF  1, "K : minimize_window\n"
  1176. ;        DEBUGF  1, "K : dl_left %x\n",[draw_limits.left]
  1177. ;        DEBUGF  1, "K : dl_right %x\n",[draw_limits.right]
  1178. ;        DEBUGF  1, "K : dl_top %x\n",[draw_limits.top]
  1179. ;        DEBUGF  1, "K : dl_bottom %x\n",[draw_limits.bottom]
  1180.         call    calculatescreen
  1181. ;        xor     esi, esi
  1182. ;        xor     eax, eax
  1183.         mov     eax, edi
  1184.         call    redrawscreen
  1185. ;--------------------------------------
  1186. align 4
  1187. @@:
  1188.         pop     esi edx ecx ebx eax
  1189. ;--------------------------------------
  1190. align 4
  1191. .exit:
  1192.         popfd
  1193.         pop     edi
  1194.         ret
  1195. ;------------------------------------------------------------------------------
  1196. align 4
  1197. ;------------------------------------------------------------------------------
  1198. restore_minimized_window: ;////////////////////////////////////////////////////
  1199. ;------------------------------------------------------------------------------
  1200. ;> eax = window number on screen
  1201. ;------------------------------------------------------------------------------
  1202. ;# corrupts [dl*]
  1203. ;------------------------------------------------------------------------------
  1204.         pushad
  1205.         pushfd
  1206.         cli
  1207.  
  1208.         ; is it already restored?
  1209.         movzx   esi, word[WIN_POS + eax * 2]
  1210.         mov     edi, esi
  1211.         shl     edi, 5
  1212.         add     edi, window_data
  1213.         test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
  1214.         jz      .exit
  1215.  
  1216.         ; no it's not, let's do that
  1217.         mov     [edi + WDATA.fl_redraw], 1
  1218.         and     [edi + WDATA.fl_wstate], not WSTATE_MINIMIZED
  1219.         mov     ebp, window._.set_screen
  1220.         cmp     eax, [TASK_COUNT]
  1221.         jz      @f
  1222.         mov     ebp, calculatescreen
  1223. ;--------------------------------------
  1224. align 4
  1225. @@:
  1226.         mov     eax, [edi + WDATA.box.left]
  1227.         mov     ebx, [edi + WDATA.box.top]
  1228.         mov     ecx, [edi + WDATA.box.width]
  1229.         mov     edx, [edi + WDATA.box.height]
  1230.         add     ecx, eax
  1231.         add     edx, ebx
  1232.         call    ebp
  1233.  
  1234.         cmp     ebp, window._.set_screen
  1235.         jne     @f
  1236.         call    window._.set_top_wnd
  1237.     @@:
  1238.         inc     [_display.mask_seqno]
  1239. ;--------------------------------------
  1240. align 4
  1241. .exit:
  1242.         popfd
  1243.         popad
  1244.         ret
  1245. ;------------------------------------------------------------------------------
  1246. align 4
  1247. ; TODO: remove this proc
  1248. ;------------------------------------------------------------------------------
  1249. window_check_events: ;/////////////////////////////////////////////////////////
  1250. ;------------------------------------------------------------------------------
  1251. ;? <description>
  1252. ;------------------------------------------------------------------------------
  1253.         ; do we have window minimize/restore request?
  1254.         cmp     [window_minimize], 0
  1255.         je      .exit
  1256.  
  1257.         ; okay, minimize or restore top-most window and exit
  1258.         mov     eax, [TASK_COUNT]
  1259.         mov     bl, 0
  1260.         xchg    [window_minimize], bl
  1261.         dec     bl
  1262.         jnz     @f
  1263.         call    minimize_window
  1264.         jmp     .exit
  1265. ;--------------------------------------
  1266. align 4
  1267. @@:
  1268.         call    restore_minimized_window
  1269. ;--------------------------------------
  1270. align 4
  1271. .exit:
  1272.         ret
  1273. ;------------------------------------------------------------------------------
  1274. align 4
  1275. ;------------------------------------------------------------------------------
  1276. sys_window_maximize_handler: ;/////////////////////////////////////////////////
  1277. ;------------------------------------------------------------------------------
  1278. ;? <description>
  1279. ;------------------------------------------------------------------------------
  1280. ;> esi = process slot
  1281. ;------------------------------------------------------------------------------
  1282.         mov     edi, esi
  1283.         shl     edi, 5
  1284.         add     edi, window_data
  1285.  
  1286.         ; can window change its height?
  1287.         ; only types 2 and 3 can be resized
  1288.         mov     dl, [edi + WDATA.fl_wstyle]
  1289.         test    dl, 2
  1290.         jz      .exit
  1291.  
  1292.         ; toggle normal/maximized window state
  1293.         mov     bl, [edi + WDATA.fl_wstate]
  1294.         xor     bl, WSTATE_MAXIMIZED
  1295.  
  1296.         ; calculate and set appropriate window bounds
  1297.         test    bl, WSTATE_MAXIMIZED
  1298.         jz      .restore_size
  1299.  
  1300.         mov     eax, [screen_workarea.left]
  1301.         mov     ecx, [screen_workarea.top]
  1302.         push    [screen_workarea.bottom] \
  1303.                 [screen_workarea.right] \
  1304.                 ecx \
  1305.                 eax
  1306.         sub     [esp + BOX.width], eax
  1307.         sub     [esp + BOX.height], ecx
  1308.         mov     eax, esp
  1309.         jmp     .set_box
  1310. ;--------------------------------------
  1311. align 4
  1312. .restore_size:
  1313.         mov     eax, esi
  1314.         shl     eax, 8
  1315.         add     eax, SLOT_BASE + APPDATA.saved_box
  1316.         push    [eax + BOX.height] \
  1317.                 [eax + BOX.width] \
  1318.                 [eax + BOX.top] \
  1319.                 [eax + BOX.left]
  1320.         mov     eax, esp
  1321. ;--------------------------------------
  1322. align 4
  1323. .set_box:
  1324.         test    bl, WSTATE_ROLLEDUP
  1325.         jz      @f
  1326.  
  1327.         xchg    eax, ecx
  1328.         call    window._.get_rolledup_height
  1329.         mov     [ecx + BOX.height], eax
  1330.         xchg    eax, ecx
  1331. ;--------------------------------------
  1332. align 4
  1333. @@:
  1334.         call    window._.set_window_box
  1335.         add     esp, sizeof.BOX
  1336. ;--------------------------------------
  1337. align 4
  1338. .exit:
  1339.         inc     [_display.mask_seqno]
  1340.         ret
  1341. ;------------------------------------------------------------------------------
  1342. align 4
  1343. ;------------------------------------------------------------------------------
  1344. sys_window_rollup_handler: ;///////////////////////////////////////////////////
  1345. ;------------------------------------------------------------------------------
  1346. ;? <description>
  1347. ;------------------------------------------------------------------------------
  1348. ;> esi = process slot
  1349. ;------------------------------------------------------------------------------
  1350.         mov     edx, esi
  1351.         shl     edx, 8
  1352.         add     edx, SLOT_BASE
  1353.  
  1354.         ; toggle normal/rolled up window state
  1355.         mov     bl, [edi + WDATA.fl_wstate]
  1356.         xor     bl, WSTATE_ROLLEDUP
  1357.  
  1358.         ; calculate and set appropriate window bounds
  1359.         test    bl, WSTATE_ROLLEDUP
  1360.         jz      .restore_size
  1361.  
  1362.         call    window._.get_rolledup_height
  1363.         push    eax \
  1364.                 [edi + WDATA.box.width] \
  1365.                 [edi + WDATA.box.top] \
  1366.                 [edi + WDATA.box.left]
  1367.         mov     eax, esp
  1368.         jmp     .set_box
  1369. ;--------------------------------------
  1370. align 4
  1371. .restore_size:
  1372.         test    bl, WSTATE_MAXIMIZED
  1373.         jnz     @f
  1374.         add     esp, -sizeof.BOX
  1375.         lea     eax, [edx + APPDATA.saved_box]
  1376.         jmp     .set_box
  1377. ;--------------------------------------
  1378. align 4
  1379. @@:
  1380.         mov     eax, [screen_workarea.top]
  1381.         push    [screen_workarea.bottom] \
  1382.                 [edi + WDATA.box.width] \
  1383.                 eax \
  1384.                 [edi + WDATA.box.left]
  1385.         sub     [esp + BOX.height], eax
  1386.         mov     eax, esp
  1387. ;--------------------------------------
  1388. align 4
  1389. .set_box:
  1390.         call    window._.set_window_box
  1391.         add     esp, sizeof.BOX
  1392.         ret
  1393. ;------------------------------------------------------------------------------
  1394. align 4
  1395. ;------------------------------------------------------------------------------
  1396. ;sys_window_start_moving_handler: ;/////////////////////////////////////////////
  1397. ;------------------------------------------------------------------------------
  1398. ;? <description>
  1399. ;------------------------------------------------------------------------------
  1400. ;> eax = old (original) window box
  1401. ;> esi = process slot
  1402. ;------------------------------------------------------------------------------
  1403. ;        mov     edi, eax
  1404. ;        call    window._.draw_negative_box
  1405. ;        ret
  1406. ;------------------------------------------------------------------------------
  1407. align 4
  1408. ;------------------------------------------------------------------------------
  1409. sys_window_end_moving_handler: ;///////////////////////////////////////////////
  1410. ;------------------------------------------------------------------------------
  1411. ;? <description>
  1412. ;------------------------------------------------------------------------------
  1413. ;> eax = old (original) window box
  1414. ;> ebx = new (final) window box
  1415. ;> esi = process slot
  1416. ;------------------------------------------------------------------------------
  1417. ;        mov     edi, ebx
  1418. ;        call    window._.end_moving__box
  1419.  
  1420.         mov     edi, ebx
  1421.         call    window._.draw_negative_box
  1422.  
  1423.         mov     edi, esi
  1424.         shl     edi, 5
  1425.         add     edi, window_data
  1426.  
  1427.         mov     eax, ebx
  1428.         mov     bl, [edi + WDATA.fl_wstate]
  1429.         call    window._.set_window_box
  1430.         ret
  1431. ;------------------------------------------------------------------------------
  1432. align 4
  1433. ;------------------------------------------------------------------------------
  1434. sys_window_moving_handler: ;///////////////////////////////////////////////////
  1435. ;------------------------------------------------------------------------------
  1436. ;? <description>
  1437. ;------------------------------------------------------------------------------
  1438. ;> eax = old (from previous call) window box
  1439. ;> ebx = new (current) window box
  1440. ;> esi = process_slot
  1441. ;------------------------------------------------------------------------------
  1442.         mov     edi, eax
  1443.         call    window._.draw_negative_box
  1444.         mov     edi, ebx
  1445.         call    window._.draw_negative_box
  1446.         ret
  1447. ;==============================================================================
  1448. ;///// private functions //////////////////////////////////////////////////////
  1449. ;==============================================================================
  1450.  
  1451. iglobal
  1452.   FuncTable syscall_display_settings, ftable, \
  1453.     00, 01, 02, 03, 04, 05, 06, 07, 08, 09
  1454.  
  1455.   align 4
  1456.   window_topleft dd \
  1457.     1, 21, \ ;type 0
  1458.     0,  0, \ ;type 1
  1459.     5, 20, \ ;type 2
  1460.     5,  ?, \ ;type 3 {set by skin}
  1461.     5,  ?    ;type 4 {set by skin}
  1462. endg
  1463.  
  1464. ;uglobal
  1465.   ; NOTE: commented out since doesn't provide necessary functionality anyway,
  1466.   ;       to be reworked
  1467. ; new_window_starting       dd ?
  1468. ;endg
  1469. ;------------------------------------------------------------------------------
  1470. align 4
  1471. ;------------------------------------------------------------------------------
  1472. window._.invalidate_screen: ;//////////////////////////////////////////////////
  1473. ;------------------------------------------------------------------------------
  1474. ;? <description>
  1475. ;------------------------------------------------------------------------------
  1476. ;> eax = old (original) window box
  1477. ;> ebx = new (final) window box
  1478. ;> edi = pointer to WDATA struct
  1479. ;------------------------------------------------------------------------------
  1480.         push    eax ebx
  1481.  
  1482.         ; TODO: do we really need `draw_limits`?
  1483.         ; Yes, they are used by background drawing code.
  1484.  
  1485. ; we need only to restore the background windows at the old place!
  1486.         mov     ecx, [ebx + BOX.left]
  1487.         mov     [draw_limits.left], ecx
  1488.         add     ecx, [ebx + BOX.width]
  1489.         mov     [draw_limits.right], ecx
  1490.         mov     ecx, [ebx + BOX.top]
  1491.         mov     [draw_limits.top], ecx
  1492.         add     ecx, [ebx + BOX.height]
  1493.         mov     [draw_limits.bottom], ecx
  1494. ; recalculate screen buffer at old position
  1495.         push    ebx
  1496.         mov     edx, [eax + BOX.height]
  1497.         mov     ecx, [eax + BOX.width]
  1498.         mov     ebx, [eax + BOX.top]
  1499.         mov     eax, [eax + BOX.left]
  1500.         add     ecx, eax
  1501.         add     edx, ebx
  1502.         call    calculatescreen
  1503.         pop     eax
  1504. ; recalculate screen buffer at new position
  1505.         mov     edx, [eax + BOX.height]
  1506.         mov     ecx, [eax + BOX.width]
  1507.         mov     ebx, [eax + BOX.top]
  1508.         mov     eax, [eax + BOX.left]
  1509.         add     ecx, eax
  1510.         add     edx, ebx
  1511.         call    calculatescreen
  1512.  
  1513.         mov     eax, edi
  1514.         call    redrawscreen
  1515.  
  1516.         ; tell window to redraw itself
  1517.         mov     [edi + WDATA.fl_redraw], 1
  1518.  
  1519.         pop     ebx eax
  1520.         ret
  1521. ;------------------------------------------------------------------------------
  1522. align 4
  1523. ;------------------------------------------------------------------------------
  1524. window._.set_window_box: ;/////////////////////////////////////////////////////
  1525. ;------------------------------------------------------------------------------
  1526. ;? <description>
  1527. ;------------------------------------------------------------------------------
  1528. ;> eax = pointer to BOX struct
  1529. ;> bl = new window state flags
  1530. ;> edi = pointer to WDATA struct
  1531. ;------------------------------------------------------------------------------
  1532.         push    eax ebx esi
  1533.  
  1534. ; don't do anything if the new box is identical to the old
  1535.         cmp     bl, [edi + WDATA.fl_wstate]
  1536.         jnz     @f
  1537.         mov     esi, eax
  1538.         push    edi
  1539. if WDATA.box
  1540.         add     edi, WDATA.box
  1541. end if
  1542.         mov     ecx, 4
  1543.         repz cmpsd
  1544.         pop     edi
  1545.         jz      .exit
  1546. ;--------------------------------------
  1547. align 4
  1548. @@:
  1549.         add     esp, -sizeof.BOX
  1550.         mov     ebx, esp
  1551. if WDATA.box
  1552.         lea     esi, [edi + WDATA.box]
  1553. else
  1554.         mov     esi, edi ; optimization for WDATA.box = 0
  1555. end if
  1556.         xchg    eax, esi
  1557.         mov     ecx, sizeof.BOX
  1558.         call    memmove
  1559.         xchg    eax, esi
  1560.         xchg    ebx, esi
  1561.         call    memmove
  1562.         mov     eax, ebx
  1563.         mov     ebx, esi
  1564.  
  1565.         call    window._.check_window_position
  1566.         call    window._.set_window_clientbox
  1567.         call    window._.invalidate_screen
  1568.  
  1569.         add     esp, sizeof.BOX
  1570.  
  1571.         mov     cl, [esp + 4]
  1572.         mov     ch, cl
  1573.         xchg    cl, [edi + WDATA.fl_wstate]
  1574.  
  1575.         or      cl, ch
  1576.         test    cl, WSTATE_MAXIMIZED
  1577.         jnz     .exit
  1578.  
  1579.         mov     eax, edi
  1580.         sub     eax, window_data
  1581.         shl     eax, 3
  1582.         add     eax, SLOT_BASE
  1583.  
  1584.         lea     ebx, [edi + WDATA.box]
  1585.         xchg    esp, ebx
  1586.  
  1587.         pop     [eax + APPDATA.saved_box.left] \
  1588.                 [eax + APPDATA.saved_box.top] \
  1589.                 [eax + APPDATA.saved_box.width] \
  1590.                 edx
  1591.  
  1592.         xchg    esp, ebx
  1593.  
  1594.         test    ch, WSTATE_ROLLEDUP
  1595.         jnz     .exit
  1596.  
  1597.         mov     [eax + APPDATA.saved_box.height], edx
  1598. ;--------------------------------------
  1599. align 4
  1600. .exit:
  1601.         pop     esi ebx eax
  1602.         ret
  1603. ;------------------------------------------------------------------------------
  1604. align 4
  1605. ;------------------------------------------------------------------------------
  1606. window._.set_window_clientbox: ;///////////////////////////////////////////////
  1607. ;------------------------------------------------------------------------------
  1608. ;? <description>
  1609. ;------------------------------------------------------------------------------
  1610. ;> edi = pointer to WDATA struct
  1611. ;------------------------------------------------------------------------------
  1612.         push    eax ecx edi
  1613.  
  1614.         mov     eax, [_skinh]
  1615.         mov     [window_topleft + 8 * 3 + 4], eax
  1616.         mov     [window_topleft + 8 * 4 + 4], eax
  1617.  
  1618.         mov     ecx, edi
  1619.         sub     edi, window_data
  1620.         shl     edi, 3
  1621.         test    [ecx + WDATA.fl_wstyle], WSTYLE_CLIENTRELATIVE
  1622.         jz      .whole_window
  1623.  
  1624.         movzx   eax, [ecx + WDATA.fl_wstyle]
  1625.         and     eax, 0x0F
  1626.         mov     eax, [eax * 8 + window_topleft + 0]
  1627.         mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax
  1628.         shl     eax, 1
  1629.         neg     eax
  1630.         add     eax, [ecx + WDATA.box.width]
  1631.         mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax
  1632.  
  1633.         movzx   eax, [ecx + WDATA.fl_wstyle]
  1634.         and     eax, 0x0F
  1635.         push    [eax * 8 + window_topleft + 0]
  1636.         mov     eax, [eax * 8 + window_topleft + 4]
  1637.         mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax
  1638.         neg     eax
  1639.         sub     eax, [esp]
  1640.         add     eax, [ecx + WDATA.box.height]
  1641.         mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax
  1642.         add     esp, 4
  1643.         jmp     .exit
  1644. ;--------------------------------------
  1645. align 4
  1646. .whole_window:
  1647.         xor     eax, eax
  1648.         mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax
  1649.         mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax
  1650.         mov     eax, [ecx + WDATA.box.width]
  1651.         mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax
  1652.         mov     eax, [ecx + WDATA.box.height]
  1653.         mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax
  1654. ;--------------------------------------
  1655. align 4
  1656. .exit:
  1657.         pop     edi ecx eax
  1658.         ret
  1659. ;------------------------------------------------------------------------------
  1660. align 4
  1661. ;------------------------------------------------------------------------------
  1662. window._.sys_set_window: ;/////////////////////////////////////////////////////
  1663. ;------------------------------------------------------------------------------
  1664. ;? <description>
  1665. ;------------------------------------------------------------------------------
  1666. ;< edx = pointer to WDATA struct
  1667. ;------------------------------------------------------------------------------
  1668.         mov     eax, [CURRENT_TASK]
  1669.         shl     eax, 5
  1670.         add     eax, window_data
  1671.  
  1672.         ; save window colors
  1673.         mov     [eax + WDATA.cl_workarea], edx
  1674.         mov     [eax + WDATA.cl_titlebar], esi
  1675.         mov     [eax + WDATA.cl_frames], edi
  1676.  
  1677.         mov     edi, eax
  1678.  
  1679.         ; was it already defined before?
  1680.         test    [edi + WDATA.fl_wdrawn], 1
  1681.         jnz     .set_client_box
  1682.         or      [edi + WDATA.fl_wdrawn], 1
  1683. ; After first draw_window we need redraw mouse necessarily!
  1684. ; Otherwise the user can see cursor specified by f.37.5 from another window.
  1685. ; He will be really unhappy! He is terrible in rage - usually he throws stones!
  1686.         mov     [redrawmouse_unconditional], 1
  1687.         call    wakeup_osloop
  1688.         ; NOTE: commented out since doesn't provide necessary functionality
  1689.         ;       anyway, to be reworked
  1690. ;       mov     eax, [timer_ticks] ; [0xfdf0]
  1691. ;       add     eax, 100
  1692. ;       mov     [new_window_starting], eax
  1693.  
  1694.         ; no it wasn't, performing initial window definition
  1695.         movzx   eax, bx
  1696.         mov     [edi + WDATA.box.width], eax
  1697.         movzx   eax, cx
  1698.         mov     [edi + WDATA.box.height], eax
  1699.         sar     ebx, 16
  1700.         sar     ecx, 16
  1701.         mov     [edi + WDATA.box.left], ebx
  1702.         mov     [edi + WDATA.box.top], ecx
  1703.  
  1704.         call    window._.check_window_position
  1705.  
  1706.         push    ecx edi
  1707.  
  1708.         mov     cl, [edi + WDATA.fl_wstyle]
  1709.         mov     eax, [edi + WDATA.cl_frames]
  1710.  
  1711.         sub     edi, window_data
  1712.         shl     edi, 3
  1713.         add     edi, SLOT_BASE
  1714.  
  1715.         and     cl, 0x0F
  1716.         cmp     cl, 3
  1717.         je      @f
  1718.         cmp     cl, 4
  1719.         je      @f
  1720.  
  1721.         xor     eax, eax
  1722. ;--------------------------------------
  1723. align 4
  1724. @@:
  1725.         mov     [edi + APPDATA.wnd_caption], eax
  1726.  
  1727.         mov     esi, [esp]
  1728.         add     edi, APPDATA.saved_box
  1729.         movsd
  1730.         movsd
  1731.         movsd
  1732.         movsd
  1733.  
  1734.         pop     edi ecx
  1735.  
  1736.         mov     esi, [CURRENT_TASK]
  1737.         movzx   esi, word[WIN_STACK + esi * 2]
  1738.         lea     esi, [WIN_POS + esi * 2]
  1739.         call    waredraw
  1740.  
  1741.         mov     eax, [edi + WDATA.box.left]
  1742.         mov     ebx, [edi + WDATA.box.top]
  1743.         mov     ecx, [edi + WDATA.box.width]
  1744.         mov     edx, [edi + WDATA.box.height]
  1745.         add     ecx, eax
  1746.         add     edx, ebx
  1747.         call    calculatescreen
  1748.  
  1749.         mov     byte[KEY_COUNT], 0           ; empty keyboard buffer
  1750.         mov     byte[BTN_COUNT], 0           ; empty button buffer
  1751. ;--------------------------------------
  1752. align 4
  1753. .set_client_box:
  1754.         ; update window client box coordinates
  1755.         call    window._.set_window_clientbox
  1756.  
  1757.         ; reset window redraw flag and exit
  1758.         mov     [edi + WDATA.fl_redraw], 0
  1759.         mov     edx, edi
  1760.         ret
  1761. ;------------------------------------------------------------------------------
  1762. align 4
  1763. ;------------------------------------------------------------------------------
  1764. window._.check_window_position: ;//////////////////////////////////////////////
  1765. ;------------------------------------------------------------------------------
  1766. ;? Check if window is inside screen area
  1767. ;------------------------------------------------------------------------------
  1768. ;> edi = pointer to WDATA
  1769. ;------------------------------------------------------------------------------
  1770.         push    eax ebx ecx edx esi
  1771.  
  1772.         mov     eax, [edi + WDATA.box.left]
  1773.         mov     ebx, [edi + WDATA.box.top]
  1774.         mov     ecx, [edi + WDATA.box.width]
  1775.         mov     edx, [edi + WDATA.box.height]
  1776.  
  1777.         mov     esi, [_display.width]
  1778.         cmp     ecx, esi
  1779.         jae     .fix_width_high
  1780. ;--------------------------------------
  1781. align 4
  1782. .check_left:
  1783.         or      eax, eax
  1784.         jl      .fix_left_low
  1785.         add     eax, ecx
  1786.         cmp     eax, esi
  1787.         jge     .fix_left_high
  1788. ;--------------------------------------
  1789. align 4
  1790. .check_height:
  1791.         mov     esi, [_display.height]
  1792.         cmp     edx, esi
  1793.         jae     .fix_height_high
  1794. ;--------------------------------------
  1795. align 4
  1796. .check_top:
  1797.         or      ebx, ebx
  1798.         jl      .fix_top_low
  1799.         add     ebx, edx
  1800.         cmp     ebx, esi
  1801.         jge     .fix_top_high
  1802. ;--------------------------------------
  1803. align 4
  1804. .exit:
  1805.         pop     esi edx ecx ebx eax
  1806.         ret
  1807. ;--------------------------------------
  1808. align 4
  1809. .fix_width_high:
  1810.         mov     ecx, esi
  1811.         mov     [edi + WDATA.box.width], esi
  1812.         jmp     .check_left
  1813. ;--------------------------------------
  1814. align 4
  1815. .fix_left_low:
  1816.         xor     eax, eax
  1817.         mov     [edi + WDATA.box.left], eax
  1818.         jmp     .check_height
  1819. ;--------------------------------------
  1820. align 4
  1821. .fix_left_high:
  1822.         mov     eax, esi
  1823.         sub     eax, ecx
  1824.         mov     [edi + WDATA.box.left], eax
  1825.         jmp     .check_height
  1826. ;--------------------------------------
  1827. align 4
  1828. .fix_height_high:
  1829.         mov     edx, esi
  1830.         mov     [edi + WDATA.box.height], esi
  1831.         jmp     .check_top
  1832. ;--------------------------------------
  1833. align 4
  1834. .fix_top_low:
  1835.         xor     ebx, ebx
  1836.         mov     [edi + WDATA.box.top], ebx
  1837.         jmp     .exit
  1838. ;--------------------------------------
  1839. align 4
  1840. .fix_top_high:
  1841.         mov     ebx, esi
  1842.         sub     ebx, edx
  1843.         mov     [edi + WDATA.box.top], ebx
  1844.         jmp     .exit
  1845. ;------------------------------------------------------------------------------
  1846. align 4
  1847. ;------------------------------------------------------------------------------
  1848. window._.get_titlebar_height: ;////////////////////////////////////////////////
  1849. ;------------------------------------------------------------------------------
  1850. ;? <description>
  1851. ;------------------------------------------------------------------------------
  1852. ;> edi = pointer to WDATA
  1853. ;------------------------------------------------------------------------------
  1854.         mov     al, [edi + WDATA.fl_wstyle]
  1855.         and     al, 0x0f
  1856.         cmp     al, 0x03
  1857.         jne     @f
  1858.         mov     eax, [_skinh]
  1859.         ret
  1860. ;--------------------------------------
  1861. align 4
  1862. @@:
  1863.         mov     eax, 21
  1864.         ret
  1865. ;------------------------------------------------------------------------------
  1866. align 4
  1867. ;------------------------------------------------------------------------------
  1868. window._.get_rolledup_height: ;////////////////////////////////////////////////
  1869. ;------------------------------------------------------------------------------
  1870. ;? <description>
  1871. ;------------------------------------------------------------------------------
  1872. ;> edi = pointer to WDATA
  1873. ;------------------------------------------------------------------------------
  1874.         mov     al, [edi + WDATA.fl_wstyle]
  1875.         and     al, 0x0f
  1876.         cmp     al, 0x03
  1877.         jb      @f
  1878.         mov     eax, [_skinh]
  1879.         add     eax, 3
  1880.         ret
  1881. ;--------------------------------------
  1882. align 4
  1883. @@:
  1884.         or      al, al
  1885.         jnz     @f
  1886.         mov     eax, 21
  1887.         ret
  1888. ;--------------------------------------
  1889. align 4
  1890. @@:
  1891.         mov     eax, 21 + 2
  1892.         ret
  1893. ;------------------------------------------------------------------------------
  1894. align 4
  1895. ;------------------------------------------------------------------------------
  1896. window._.set_screen: ;/////////////////////////////////////////////////////////
  1897. ;------------------------------------------------------------------------------
  1898. ;? Reserve window area in screen buffer
  1899. ;------------------------------------------------------------------------------
  1900. ;> eax = left
  1901. ;> ebx = top
  1902. ;> ecx = right
  1903. ;> edx = bottom
  1904. ;> esi = process number
  1905. ;------------------------------------------------------------------------------
  1906. virtual at esp
  1907.   ff_x     dd ?
  1908.   ff_y     dd ?
  1909.   ff_width dd ?
  1910.   ff_xsz   dd ?
  1911.   ff_ysz   dd ?
  1912.   ff_scale dd ?
  1913. end virtual
  1914.  
  1915.         pushad
  1916.  
  1917.         cmp     esi, 1
  1918.         jz      .check_for_shaped_window
  1919.         mov     edi, esi
  1920.         shl     edi, 5
  1921.         cmp     [window_data + edi + WDATA.box.width], 0
  1922.         jnz     .check_for_shaped_window
  1923.         cmp     [window_data + edi + WDATA.box.height], 0
  1924.         jz      .exit
  1925. ;--------------------------------------
  1926. align 4
  1927. .check_for_shaped_window:
  1928.         mov     edi, esi
  1929.         shl     edi, 8
  1930.         add     edi, SLOT_BASE
  1931.         cmp     [edi + APPDATA.wnd_shape], 0
  1932.         jne     .shaped_window
  1933.  
  1934.         ; get x&y size
  1935.         sub     ecx, eax
  1936.         sub     edx, ebx
  1937.         inc     ecx
  1938.         inc     edx
  1939.  
  1940.         ; get WinMap start
  1941.         push    esi
  1942.         mov     esi, [_display.width]
  1943.         mov     edi, [d_width_calc_area + ebx*4]
  1944.  
  1945.         add     edi, eax
  1946.         add     edi, [_display.win_map]
  1947.         pop     eax
  1948.         mov     ah, al
  1949.         push    ax
  1950.         shl     eax, 16
  1951.         pop     ax
  1952. ;--------------------------------------
  1953. align 4
  1954. .next_line:
  1955.         push    ecx
  1956.         shr     ecx, 2
  1957.         rep stosd
  1958.         mov     ecx, [esp]
  1959.         and     ecx, 3
  1960.         rep stosb
  1961.         pop     ecx
  1962.         add     edi, esi
  1963.         sub     edi, ecx
  1964.         dec     edx
  1965.         jnz     .next_line
  1966.  
  1967.         jmp     .exit
  1968. ;--------------------------------------
  1969. align 4
  1970. .shaped_window:
  1971.         ;  for (y=0; y <= x_size; y++)
  1972.         ;      for (x=0; x <= x_size; x++)
  1973.         ;          if (shape[coord(x,y,scale)]==1)
  1974.         ;             set_pixel(x, y, process_number);
  1975.  
  1976.         sub     ecx, eax
  1977.         sub     edx, ebx
  1978.         inc     ecx
  1979.         inc     edx
  1980.  
  1981.         push    [edi + APPDATA.wnd_shape_scale]  ; push scale first -> for loop
  1982.  
  1983.         ; get WinMap start  -> ebp
  1984.         push    eax
  1985.         mov     eax, [d_width_calc_area + ebx*4]
  1986.  
  1987.         add     eax, [esp]
  1988.         add     eax, [_display.win_map]
  1989.         mov     ebp, eax
  1990.  
  1991.         mov     edi, [edi + APPDATA.wnd_shape]
  1992.         pop     eax
  1993.  
  1994.         ; eax = x_start
  1995.         ; ebx = y_start
  1996.         ; ecx = x_size
  1997.         ; edx = y_size
  1998.         ; esi = process_number
  1999.         ; edi = &shape
  2000.         ;       [scale]
  2001.         push    edx ecx ; for loop - x,y size
  2002.  
  2003.         mov     ecx, esi
  2004.         shl     ecx, 5
  2005.         mov     edx, [window_data + ecx + WDATA.box.top]
  2006.         push    [window_data + ecx + WDATA.box.width]           ; for loop - width
  2007.         mov     ecx, [window_data + ecx + WDATA.box.left]
  2008.         sub     ebx, edx
  2009.         sub     eax, ecx
  2010.         push    ebx eax ; for loop - x,y
  2011.  
  2012.         add     [ff_xsz], eax
  2013.         add     [ff_ysz], ebx
  2014.  
  2015.         mov     ebx, [ff_y]
  2016. ;--------------------------------------
  2017. align 4
  2018. .ff_new_y:
  2019.         mov     edx, [ff_x]
  2020. ;--------------------------------------
  2021. align 4
  2022. .ff_new_x:
  2023.         ; -- body --
  2024.         mov     ecx, [ff_scale]
  2025.         mov     eax, [ff_width]
  2026.         inc     eax
  2027.         shr     eax, cl
  2028.         push    ebx edx
  2029.         shr     ebx, cl
  2030.         shr     edx, cl
  2031.         imul    eax, ebx
  2032.         add     eax, edx
  2033.         pop     edx ebx
  2034.         add     eax, edi
  2035.         call    .read_byte
  2036.         test    al, al
  2037.         jz      @f
  2038.         mov     eax, esi
  2039.         mov     [ebp], al
  2040.         ; -- end body --
  2041. ;--------------------------------------
  2042. align 4
  2043. @@:
  2044.         inc     ebp
  2045.         inc     edx
  2046.         cmp     edx, [ff_xsz]
  2047.         jb      .ff_new_x
  2048.  
  2049.         sub     ebp, [ff_xsz]
  2050.         add     ebp, [ff_x]
  2051.         add     ebp, [_display.width]  ; screen.x
  2052.         inc     ebx
  2053.         cmp     ebx, [ff_ysz]
  2054.         jb      .ff_new_y
  2055.  
  2056.         add     esp, 24
  2057. ;--------------------------------------
  2058. align 4
  2059. .exit:
  2060.         popad
  2061.         inc     [_display.mask_seqno]
  2062.         ret
  2063. ;--------------------------------------
  2064. align 4
  2065. .read_byte:
  2066.         ; eax - address
  2067.         ; esi - slot
  2068.         push    eax ecx edx esi
  2069.         xchg    eax, esi
  2070.         lea     ecx, [esp + 12]
  2071.         mov     edx, 1
  2072.         call    read_process_memory
  2073.         pop     esi edx ecx eax
  2074.         ret
  2075. ;------------------------------------------------------------------------------
  2076. align 4
  2077. ;------------------------------------------------------------------------------
  2078. window._.window_activate: ;////////////////////////////////////////////////////
  2079. ;------------------------------------------------------------------------------
  2080. ;? Activate window
  2081. ;------------------------------------------------------------------------------
  2082. ;> esi = pointer to WIN_POS+ window data
  2083. ;------------------------------------------------------------------------------
  2084.         push    eax ebx
  2085.  
  2086.         ; if type of current active window is 3 or 4, it must be redrawn
  2087.         mov     ebx, [TASK_COUNT]
  2088.  
  2089. ;       DEBUGF  1, "K : TASK_COUNT (0x%x)\n", ebx
  2090.  
  2091.         movzx   ebx, word[WIN_POS + ebx * 2]
  2092.         shl     ebx, 5
  2093.         add     eax, window_data
  2094.         mov     al, [window_data + ebx + WDATA.fl_wstyle]
  2095.         and     al, 0x0f
  2096.         cmp     al, 0x03
  2097.         je      .set_window_redraw_flag
  2098.         cmp     al, 0x04
  2099.         jne     .move_others_down
  2100. ;--------------------------------------
  2101. align 4
  2102. .set_window_redraw_flag:
  2103.         mov     [window_data + ebx + WDATA.fl_redraw], 1
  2104. ;--------------------------------------
  2105. align 4
  2106. .move_others_down:
  2107.         ; ax <- process no
  2108.         movzx   ebx, word[esi]
  2109.         ; ax <- position in window stack
  2110.         movzx   ebx, word[WIN_STACK + ebx * 2]
  2111.  
  2112.         ; drop others
  2113.         xor     eax, eax
  2114. ;--------------------------------------
  2115. align 4
  2116. .next_stack_window:
  2117.         cmp     eax, [TASK_COUNT]
  2118.         jae     .move_self_up
  2119.         inc     eax
  2120.  
  2121. ;       push    ebx
  2122. ;       xor     ebx,ebx
  2123. ;       mov     bx,[WIN_STACK + eax * 2]
  2124. ;       DEBUGF  1, "K : DEC WIN_STACK (0x%x)\n",ebx
  2125. ;       pop     ebx
  2126.  
  2127.         cmp     [WIN_STACK + eax * 2], bx
  2128.         jbe     .next_stack_window
  2129.         dec     word[WIN_STACK + eax * 2]
  2130.         jmp     .next_stack_window
  2131. ;--------------------------------------
  2132. align 4
  2133. .move_self_up:
  2134.         movzx   ebx, word[esi]
  2135.         ; number of processes
  2136.         mov     ax, [TASK_COUNT]
  2137.         ; this is the last (and the upper)
  2138.         mov     [WIN_STACK + ebx * 2], ax
  2139.  
  2140.         ; update on screen - window stack
  2141.         xor     eax, eax
  2142. ;--------------------------------------
  2143. align 4
  2144. .next_window_pos:
  2145.         cmp     eax, [TASK_COUNT]
  2146.         jae     .reset_vars
  2147.         inc     eax
  2148.         movzx   ebx, word[WIN_STACK + eax * 2]
  2149.         mov     [WIN_POS + ebx * 2], ax
  2150.         jmp     .next_window_pos
  2151. ;--------------------------------------
  2152. align 4
  2153. .reset_vars:
  2154.         mov     byte[KEY_COUNT], 0
  2155.         mov     byte[BTN_COUNT], 0
  2156.         mov     word[MOUSE_SCROLL_H], 0
  2157.         mov     word[MOUSE_SCROLL_V], 0
  2158.  
  2159.         pop     ebx eax
  2160.         ret
  2161. ;------------------------------------------------------------------------------
  2162. window._.window_deactivate: ;////////////////////////////////////////////////////
  2163. ;------------------------------------------------------------------------------
  2164. ;? Deactivate window
  2165. ;------------------------------------------------------------------------------
  2166. ;> esi = pointer to WIN_POS+ window data
  2167. ;------------------------------------------------------------------------------
  2168.         push    eax ebx
  2169. ;--------------------------------------
  2170. align 4
  2171. .move_others_up:
  2172.         ; ax <- process no
  2173.         movzx   ebx, word[esi]
  2174.         ; ax <- position in window stack
  2175.         movzx   ebx, word[WIN_STACK + ebx * 2]
  2176.         ; up others
  2177.         xor     eax, eax
  2178. ;--------------------------------------
  2179. align 4
  2180. .next_stack_window:
  2181.         cmp     eax, [TASK_COUNT]
  2182.         jae     .move_self_down
  2183.         inc     eax
  2184.         cmp     [WIN_STACK + eax * 2], bx
  2185.         jae     .next_stack_window
  2186.         inc     word[WIN_STACK + eax * 2]
  2187.         jmp     .next_stack_window
  2188. ;--------------------------------------
  2189. align 4
  2190. .move_self_down:
  2191.         movzx   ebx, word[esi]
  2192.         ; this is the last (and the low)
  2193.         mov     [WIN_STACK + ebx * 2], word 1
  2194.         ; update on screen - window stack
  2195.         xor     eax, eax
  2196. ;--------------------------------------
  2197. align 4
  2198. .next_window_pos:
  2199.         cmp     eax, [TASK_COUNT]
  2200.         jae     .reset_vars
  2201.         inc     eax
  2202.         movzx   ebx, word[WIN_STACK + eax * 2]
  2203.         mov     [WIN_POS + ebx * 2], ax
  2204.         jmp     .next_window_pos
  2205. ;--------------------------------------
  2206. align 4
  2207. .reset_vars:
  2208.         mov     byte[KEY_COUNT], 0
  2209.         mov     byte[BTN_COUNT], 0
  2210.         mov     word[MOUSE_SCROLL_H], 0
  2211.         mov     word[MOUSE_SCROLL_V], 0
  2212.         pop     ebx eax
  2213.         ret
  2214. ;------------------------------------------------------------------------------
  2215. align 4
  2216. ;------------------------------------------------------------------------------
  2217. window._.check_window_draw: ;//////////////////////////////////////////////////
  2218. ;------------------------------------------------------------------------------
  2219. ;? Check if window is necessary to draw
  2220. ;------------------------------------------------------------------------------
  2221. ;> edi = pointer to WDATA
  2222. ;------------------------------------------------------------------------------
  2223.         mov     cl, [edi + WDATA.fl_wstyle]
  2224.         and     cl, 0x0f
  2225.         cmp     cl, 3
  2226.         je      .exit.redraw      ; window type 3
  2227.         cmp     cl, 4
  2228.         je      .exit.redraw      ; window type 4
  2229.  
  2230.         push    eax ebx edx esi
  2231.  
  2232.         mov     eax, edi
  2233.         sub     eax, window_data
  2234.         shr     eax, 5
  2235.  
  2236.         movzx   eax, word[WIN_STACK + eax * 2]  ; get value of the curr process
  2237.         lea     esi, [WIN_POS + eax * 2]        ; get address of this process at 0xC400
  2238. ;--------------------------------------
  2239. align 4
  2240. .next_window:
  2241.         add     esi, 2
  2242.  
  2243.         mov     eax, [TASK_COUNT]
  2244.         lea     eax, word[WIN_POS + eax * 2] ; number of the upper window
  2245.  
  2246.         cmp     esi, eax
  2247.         ja      .exit.no_redraw
  2248.  
  2249.         movzx   edx, word[esi]
  2250.         shl     edx, 5
  2251.         cmp     [CURRENT_TASK + edx + TASKDATA.state], TSTATE_FREE
  2252.         je      .next_window
  2253.  
  2254.         mov     eax, [edi + WDATA.box.top]
  2255.         mov     ebx, [edi + WDATA.box.height]
  2256.         add     ebx, eax
  2257.  
  2258.         mov     ecx, [window_data + edx + WDATA.box.top]
  2259.         cmp     ecx, ebx
  2260.         jge     .next_window
  2261.         add     ecx, [window_data + edx + WDATA.box.height]
  2262.         cmp     eax, ecx
  2263.         jge     .next_window
  2264.  
  2265.         mov     eax, [edi + WDATA.box.left]
  2266.         mov     ebx, [edi + WDATA.box.width]
  2267.         add     ebx, eax
  2268.  
  2269.         mov     ecx, [window_data + edx + WDATA.box.left]
  2270.         cmp     ecx, ebx
  2271.         jge     .next_window
  2272.         add     ecx, [window_data + edx + WDATA.box.width]
  2273.         cmp     eax, ecx
  2274.         jge     .next_window
  2275.  
  2276.         pop     esi edx ebx eax
  2277. ;--------------------------------------
  2278. align 4
  2279. .exit.redraw:
  2280.         xor     ecx, ecx
  2281.         inc     ecx
  2282.         ret
  2283. ;--------------------------------------
  2284. align 4
  2285. .exit.no_redraw:
  2286.         pop     esi edx ebx eax
  2287.         xor     ecx, ecx
  2288.         ret
  2289. ;------------------------------------------------------------------------------
  2290. align 4
  2291. ;------------------------------------------------------------------------------
  2292. window._.draw_window_caption: ;////////////////////////////////////////////////
  2293. ;------------------------------------------------------------------------------
  2294. ;? <description>
  2295. ;------------------------------------------------------------------------------
  2296.         xor     eax, eax
  2297.         mov     edx, [TASK_COUNT]
  2298.         movzx   edx, word[WIN_POS + edx * 2]
  2299.         cmp     edx, [CURRENT_TASK]
  2300.         jne     @f
  2301.         inc     eax
  2302. ;--------------------------------------
  2303. align 4
  2304. @@:
  2305.         mov     edx, [CURRENT_TASK]
  2306.         shl     edx, 5
  2307.         add     edx, window_data
  2308.         movzx   ebx, [edx + WDATA.fl_wstyle]
  2309.         and     bl, 0x0F
  2310.         cmp     bl, 3
  2311.         je      .draw_caption_style_3
  2312.         cmp     bl, 4
  2313.         je      .draw_caption_style_3
  2314.  
  2315.         jmp     .not_style_3
  2316. ;--------------------------------------
  2317. align 4
  2318. .draw_caption_style_3:
  2319.         push    edx
  2320.         call    drawwindow_IV_caption
  2321.         add     esp, 4
  2322.         jmp     .2
  2323. ;--------------------------------------
  2324. align 4
  2325. .not_style_3:
  2326.         cmp     bl, 2
  2327.         jne     .not_style_2
  2328.  
  2329.         call    drawwindow_III_caption
  2330.         jmp     .2
  2331. ;--------------------------------------
  2332. align 4
  2333. .not_style_2:
  2334.         cmp     bl, 0
  2335.         jne     .2
  2336.  
  2337.         call    drawwindow_I_caption
  2338. ;--------------------------------------
  2339. align 4
  2340. .2:
  2341.         mov     edi, [CURRENT_TASK]
  2342.         shl     edi, 5
  2343.         test    [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
  2344.         jz      .exit
  2345.         mov     edx, [edi * 8 + SLOT_BASE + APPDATA.wnd_caption]
  2346.         or      edx, edx
  2347.         jz      .exit
  2348.  
  2349.         movzx   eax, [edi + window_data + WDATA.fl_wstyle]
  2350.         and     al, 0x0F
  2351.         cmp     al, 3
  2352.         je      .skinned
  2353.         cmp     al, 4
  2354.         je      .skinned
  2355.  
  2356.         jmp     .not_skinned
  2357. ;--------------------------------------
  2358. align 4
  2359. .skinned:
  2360.         mov     ebp, [edi + window_data + WDATA.box.left - 2]
  2361.         mov     bp, word[edi + window_data + WDATA.box.top]
  2362.         movzx   eax, word[edi + window_data + WDATA.box.width]
  2363.         sub     ax, [_skinmargins.left]
  2364.         sub     ax, [_skinmargins.right]
  2365.         push    edx
  2366.         cwde
  2367.         cdq
  2368.         mov     ebx, 6
  2369.         idiv    ebx
  2370.         pop     edx
  2371.         or      eax, eax
  2372.         js      .exit
  2373.  
  2374.         mov     esi, eax
  2375.         mov     ebx, dword[_skinmargins.left - 2]
  2376.         mov     bx, word[_skinh]
  2377.         sub     bx, [_skinmargins.bottom]
  2378.         sub     bx, [_skinmargins.top]
  2379.         sar     bx, 1
  2380.         adc     bx, 0
  2381.         add     bx, [_skinmargins.top]
  2382.         add     bx, -3
  2383.         add     ebx, ebp
  2384.         jmp     .dodraw
  2385. ;--------------------------------------
  2386. align 4
  2387. .not_skinned:
  2388.         cmp     al, 1
  2389.         je      .exit
  2390.  
  2391.         mov     ebp, [edi + window_data + WDATA.box.left - 2]
  2392.         mov     bp, word[edi + window_data + WDATA.box.top]
  2393.         movzx   eax, word[edi + window_data + WDATA.box.width]
  2394.         sub     eax, 16
  2395.         push    edx
  2396.         cwde
  2397.         cdq
  2398.         mov     ebx, 6
  2399.         idiv    ebx
  2400.         pop     edx
  2401.         or      eax, eax
  2402.         js      .exit
  2403.  
  2404.         mov     esi, eax
  2405.         mov     ebx, 0x00080007
  2406.         add     ebx, ebp
  2407. ;--------------------------------------
  2408. align 4
  2409. .dodraw:
  2410.         mov     ecx, [common_colours + 16]
  2411.         or      ecx, 0x80000000
  2412.         xor     edi, edi
  2413.         call    dtext_asciiz_esi
  2414. ;--------------------------------------
  2415. align 4
  2416. .exit:
  2417. ;        call    [draw_pointer]
  2418.         call    __sys_draw_pointer
  2419.         ret
  2420. ;------------------------------------------------------------------------------
  2421. align 4
  2422. ;------------------------------------------------------------------------------
  2423. window._.draw_negative_box: ;//////////////////////////////////////////////////
  2424. ;------------------------------------------------------------------------------
  2425. ;? Draw negative box
  2426. ;------------------------------------------------------------------------------
  2427. ;> edi = pointer to BOX struct
  2428. ;------------------------------------------------------------------------------
  2429.         push    eax ebx esi
  2430.         mov     esi, 0x01000000
  2431. ;--------------------------------------
  2432. align 4
  2433. .1:
  2434.         mov     eax, [edi + BOX.left - 2]
  2435.         mov     ax, word[edi + BOX.left]
  2436.         add     ax, word[edi + BOX.width]
  2437.         mov     ebx, [edi + BOX.top - 2]
  2438.         mov     bx, word[edi + BOX.top]
  2439.         add     bx, word[edi + BOX.height]
  2440.         call    draw_rectangle.forced
  2441.         pop     esi ebx eax
  2442.         ret
  2443. ;------------------------------------------------------------------------------
  2444. ;align 4
  2445. ;------------------------------------------------------------------------------
  2446. ;window._.end_moving__box: ;//////////////////////////////////////////////////
  2447. ;------------------------------------------------------------------------------
  2448. ;? Draw positive box
  2449. ;------------------------------------------------------------------------------
  2450. ;> edi = pointer to BOX struct
  2451. ;------------------------------------------------------------------------------
  2452. ;        push    eax ebx esi
  2453. ;        xor     esi, esi
  2454. ;        jmp     window._.draw_negative_box.1
  2455. ;------------------------------------------------------------------------------
  2456. align 4
  2457. ;------------------------------------------------------------------------------
  2458. window._.get_rect: ;/////////////////////////////////////////////////////
  2459. ;------------------------------------------------------------------------------
  2460. ;? <description>  void __fastcall get_window_rect(struct RECT* rc);
  2461. ;------------------------------------------------------------------------------
  2462. ;> ecx = pointer to RECT
  2463. ;------------------------------------------------------------------------------
  2464.         mov     eax, [TASK_BASE]
  2465.  
  2466.         mov     edx, [eax-twdw + WDATA.box.left]
  2467.         mov     [ecx+RECT.left], edx
  2468.  
  2469.         add     edx, [eax-twdw + WDATA.box.width]
  2470.         mov     [ecx+RECT.right], edx
  2471.  
  2472.         mov     edx, [eax-twdw + WDATA.box.top]
  2473.         mov     [ecx+RECT.top], edx
  2474.  
  2475.         add     edx, [eax-twdw + WDATA.box.height]
  2476.         mov     [ecx+RECT.bottom], edx
  2477.         ret
  2478. ;------------------------------------------------------------------------------
  2479. align 4
  2480. ;------------------------------------------------------------------------------
  2481. window._.set_top_wnd: ;////////////////////////////////////////////////////////
  2482. ;------------------------------------------------------------------------------
  2483. ;? updates all windows one above the window
  2484. ;------------------------------------------------------------------------------
  2485. ;> eax = left
  2486. ;> ebx = top
  2487. ;> ecx = right
  2488. ;> edx = bottom
  2489. ;> esi = process number
  2490. ;! corrupted edi
  2491. ;------------------------------------------------------------------------------
  2492.         movzx   edi, word[WIN_POS + esi * 2]
  2493.         shl     edi, 5
  2494.         cmp     [edi + window_data + WDATA.z_modif], ZPOS_ALWAYS_TOP
  2495.         jne     @f
  2496.         ret
  2497.       @@:
  2498.  
  2499.         push    esi
  2500.         pushfd
  2501.         cli
  2502.  
  2503.         push    ebp
  2504.         mov     ebp, [TASK_COUNT]
  2505.         cmp     ebp, 1
  2506.         jbe     .exit
  2507.  
  2508.         push    eax ;for num layout
  2509.         push    edx ecx ebx eax
  2510.  
  2511.         movzx   eax, byte [edi + window_data + WDATA.z_modif]
  2512.         inc     eax
  2513.         mov     dword[esp+14], eax
  2514. ;--------------------------------------
  2515. align 4
  2516. .layout:
  2517.         mov     esi, 1        ; = num in window stack
  2518.         mov     ebp, [TASK_COUNT]
  2519. ;--------------------------------------
  2520. align 4
  2521. .next_window:
  2522.         movzx   edi, word[WIN_POS + esi * 2]
  2523.         shl     edi, 5                  ;size of TASKDATA and WDATA = 32 bytes
  2524.  
  2525.         cmp     [CURRENT_TASK + edi + TASKDATA.state], TSTATE_FREE
  2526.         je      .skip_window
  2527.  
  2528.         add     edi, window_data
  2529.         test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
  2530.         jnz     .skip_window
  2531.  
  2532.         mov     eax, [esp+14]
  2533.         mov     al, [eax+win_zmodi]
  2534.         cmp     [edi + WDATA.z_modif], al
  2535.         jne     .skip_window
  2536.  
  2537.         mov     eax, [edi + WDATA.box.left]
  2538.         cmp     eax, [esp + RECT.right]
  2539.         jg      .skip_window
  2540.         mov     ebx, [edi + WDATA.box.top]
  2541.         cmp     ebx, [esp + RECT.bottom]
  2542.         jg      .skip_window
  2543.         mov     ecx, [edi + WDATA.box.width]
  2544.         add     ecx, eax
  2545.         cmp     ecx, [esp + RECT.left]
  2546.         jl      .skip_window
  2547.         mov     edx, [edi + WDATA.box.height]
  2548.         add     edx, ebx
  2549.         cmp     edx, [esp + RECT.top]
  2550.         jl      .skip_window
  2551.  
  2552.         cmp     eax, [esp + RECT.left]
  2553.         jae     @f
  2554.         mov     eax, [esp + RECT.left]
  2555. ;--------------------------------------
  2556. align 4
  2557. @@:
  2558.         cmp     ebx, [esp + RECT.top]
  2559.         jae     @f
  2560.         mov     ebx, [esp + RECT.top]
  2561. ;--------------------------------------
  2562. align 4
  2563. @@:
  2564.         cmp     ecx, [esp + RECT.right]
  2565.         jbe     @f
  2566.         mov     ecx, [esp + RECT.right]
  2567. ;--------------------------------------
  2568. align 4
  2569. @@:
  2570.         cmp     edx, [esp + RECT.bottom]
  2571.         jbe     @f
  2572.         mov     edx, [esp + RECT.bottom]
  2573. ;--------------------------------------
  2574. align 4
  2575. @@:
  2576.         push    esi
  2577.         movzx   esi, word[WIN_POS + esi * 2]
  2578.         call    window._.set_screen
  2579.         pop     esi
  2580.  
  2581.         mov     [edi + WDATA.fl_redraw], 1      ;set redraw flag
  2582. ;--------------------------------------
  2583. align 4
  2584. .skip_window:
  2585.         inc     esi
  2586.         dec     ebp
  2587.         jnz     .next_window
  2588. ;--------------------------------------
  2589.         inc     dword[esp+14]
  2590.         cmp     dword[esp+14], ZPOS_ALWAYS_TOP
  2591.         jbe     .layout
  2592. ;-------------------------------------
  2593.  
  2594.         pop     eax ebx ecx edx
  2595.         pop     ebp     ;del num layout
  2596. ;-------------------------------------
  2597. align 4
  2598. .exit:
  2599.  
  2600.         pop     ebp
  2601.         popfd
  2602.         pop     esi
  2603.  
  2604.         ret
  2605.  
  2606.  
  2607.  
  2608.