Rev 1391 | Rev 1532 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1391 | Rev 1531 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2010. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2010. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
7 | 7 | ||
8 | $Revision: -1 $ |
8 | $Revision$ |
9 | 9 | ||
10 | include 'mousepointer.inc' |
10 | include 'mousepointer.inc' |
11 | 11 | ||
12 | ;============================================================================== |
12 | ;============================================================================== |
13 | ;///// public functions /////////////////////////////////////////////////////// |
13 | ;///// public functions /////////////////////////////////////////////////////// |
14 | ;============================================================================== |
14 | ;============================================================================== |
15 | 15 | ||
16 | mouse.LEFT_BUTTON_FLAG = 0001b |
16 | mouse.LEFT_BUTTON_FLAG = 0001b |
17 | mouse.RIGHT_BUTTON_FLAG = 0010b |
17 | mouse.RIGHT_BUTTON_FLAG = 0010b |
18 | mouse.MIDDLE_BUTTON_FLAG = 0100b |
18 | mouse.MIDDLE_BUTTON_FLAG = 0100b |
19 | 19 | ||
20 | mouse.BUTTONS_MASK = \ |
20 | mouse.BUTTONS_MASK = \ |
21 | mouse.LEFT_BUTTON_FLAG or \ |
21 | mouse.LEFT_BUTTON_FLAG or \ |
22 | mouse.RIGHT_BUTTON_FLAG or \ |
22 | mouse.RIGHT_BUTTON_FLAG or \ |
23 | mouse.MIDDLE_BUTTON_FLAG |
23 | mouse.MIDDLE_BUTTON_FLAG |
24 | 24 | ||
25 | mouse.WINDOW_RESIZE_N_FLAG = 000001b |
25 | mouse.WINDOW_RESIZE_N_FLAG = 000001b |
26 | mouse.WINDOW_RESIZE_W_FLAG = 000010b |
26 | mouse.WINDOW_RESIZE_W_FLAG = 000010b |
27 | mouse.WINDOW_RESIZE_S_FLAG = 000100b |
27 | mouse.WINDOW_RESIZE_S_FLAG = 000100b |
28 | mouse.WINDOW_RESIZE_E_FLAG = 001000b |
28 | mouse.WINDOW_RESIZE_E_FLAG = 001000b |
29 | mouse.WINDOW_MOVE_FLAG = 010000b |
29 | mouse.WINDOW_MOVE_FLAG = 010000b |
30 | 30 | ||
31 | mouse.WINDOW_RESIZE_SW_FLAG = \ |
31 | mouse.WINDOW_RESIZE_SW_FLAG = \ |
32 | mouse.WINDOW_RESIZE_S_FLAG or \ |
32 | mouse.WINDOW_RESIZE_S_FLAG or \ |
33 | mouse.WINDOW_RESIZE_W_FLAG |
33 | mouse.WINDOW_RESIZE_W_FLAG |
34 | mouse.WINDOW_RESIZE_SE_FLAG = \ |
34 | mouse.WINDOW_RESIZE_SE_FLAG = \ |
35 | mouse.WINDOW_RESIZE_S_FLAG or \ |
35 | mouse.WINDOW_RESIZE_S_FLAG or \ |
36 | mouse.WINDOW_RESIZE_E_FLAG |
36 | mouse.WINDOW_RESIZE_E_FLAG |
37 | 37 | ||
38 | align 4 |
38 | align 4 |
39 | ;------------------------------------------------------------------------------ |
39 | ;------------------------------------------------------------------------------ |
40 | mouse_check_events: ;////////////////////////////////////////////////////////// |
40 | mouse_check_events: ;////////////////////////////////////////////////////////// |
41 | ;------------------------------------------------------------------------------ |
41 | ;------------------------------------------------------------------------------ |
42 | ;? Check if mouse buttons state or cursor position has changed and call |
42 | ;? Check if mouse buttons state or cursor position has changed and call |
43 | ;? appropriate handlers |
43 | ;? appropriate handlers |
44 | ;------------------------------------------------------------------------------ |
44 | ;------------------------------------------------------------------------------ |
45 | push eax ebx |
45 | push eax ebx |
46 | 46 | ||
47 | mov al, [BTN_DOWN] |
47 | mov al, [BTN_DOWN] |
48 | mov bl, [mouse.state.buttons] |
48 | mov bl, [mouse.state.buttons] |
49 | and al, mouse.BUTTONS_MASK |
49 | and al, mouse.BUTTONS_MASK |
50 | mov cl, al |
50 | mov cl, al |
51 | xchg cl, [mouse.state.buttons] |
51 | xchg cl, [mouse.state.buttons] |
52 | xor bl, al |
52 | xor bl, al |
53 | push eax ebx |
53 | push eax ebx |
54 | 54 | ||
55 | ; did any mouse button changed its state? |
55 | ; did any mouse button changed its state? |
56 | or bl, bl |
56 | or bl, bl |
57 | jz .check_position |
57 | jz .check_position |
58 | 58 | ||
59 | ; yes it did, is that the first button of all pressed down? |
59 | ; yes it did, is that the first button of all pressed down? |
60 | or cl, cl |
60 | or cl, cl |
61 | jnz .check_buttons_released |
61 | jnz .check_buttons_released |
62 | 62 | ||
63 | ; yes it is, activate window user is pointing at, if needed |
63 | ; yes it is, activate window user is pointing at, if needed |
64 | call mouse._.activate_sys_window_under_cursor |
64 | call mouse._.activate_sys_window_under_cursor |
65 | 65 | ||
66 | ; NOTE: this code wouldn't be necessary if we knew window did |
66 | ; NOTE: this code wouldn't be necessary if we knew window did |
67 | ; already redraw itself after call above |
67 | ; already redraw itself after call above |
68 | or eax, eax |
68 | or eax, eax |
69 | jz @f |
69 | jz @f |
70 | 70 | ||
71 | and [mouse.state.buttons], 0 |
71 | and [mouse.state.buttons], 0 |
72 | jmp .exit |
72 | jmp .exit |
73 | 73 | ||
74 | ; is there any system button under cursor? |
74 | ; is there any system button under cursor? |
75 | @@: call mouse._.find_sys_button_under_cursor |
75 | @@: call mouse._.find_sys_button_under_cursor |
76 | or eax, eax |
76 | or eax, eax |
77 | jz .check_buttons_released |
77 | jz .check_buttons_released |
78 | 78 | ||
79 | ; yes there is, activate it and exit |
79 | ; yes there is, activate it and exit |
80 | mov [mouse.active_sys_button.pbid], eax |
80 | mov [mouse.active_sys_button.pbid], eax |
81 | mov [mouse.active_sys_button.coord], ebx |
81 | mov [mouse.active_sys_button.coord], ebx |
82 | mov cl, [mouse.state.buttons] |
82 | mov cl, [mouse.state.buttons] |
83 | mov [mouse.active_sys_button.buttons], cl |
83 | mov [mouse.active_sys_button.buttons], cl |
84 | call sys_button_activate_handler |
84 | call sys_button_activate_handler |
85 | jmp .exit |
85 | jmp .exit |
86 | 86 | ||
87 | .check_buttons_released: |
87 | .check_buttons_released: |
88 | cmp [mouse.state.buttons], 0 |
88 | cmp [mouse.state.buttons], 0 |
89 | jnz .buttons_changed |
89 | jnz .buttons_changed |
90 | 90 | ||
91 | ; did we press some button earlier? |
91 | ; did we press some button earlier? |
92 | cmp [mouse.active_sys_button.pbid], 0 |
92 | cmp [mouse.active_sys_button.pbid], 0 |
93 | je .buttons_changed |
93 | je .buttons_changed |
94 | 94 | ||
95 | ; yes we did, deactivate it |
95 | ; yes we did, deactivate it |
96 | xor eax, eax |
96 | xor eax, eax |
97 | xchg eax, [mouse.active_sys_button.pbid] |
97 | xchg eax, [mouse.active_sys_button.pbid] |
98 | mov ebx, [mouse.active_sys_button.coord] |
98 | mov ebx, [mouse.active_sys_button.coord] |
99 | mov cl, [mouse.active_sys_button.buttons] |
99 | mov cl, [mouse.active_sys_button.buttons] |
100 | push eax ebx |
100 | push eax ebx |
101 | call sys_button_deactivate_handler |
101 | call sys_button_deactivate_handler |
102 | pop edx ecx |
102 | pop edx ecx |
103 | 103 | ||
104 | ; is the button under cursor the one we deactivated? |
104 | ; is the button under cursor the one we deactivated? |
105 | call mouse._.find_sys_button_under_cursor |
105 | call mouse._.find_sys_button_under_cursor |
106 | cmp eax, ecx |
106 | cmp eax, ecx |
107 | jne .exit |
107 | jne .exit |
108 | cmp ebx, edx |
108 | cmp ebx, edx |
109 | jne .exit |
109 | jne .exit |
110 | 110 | ||
111 | ; yes it is, perform associated action |
111 | ; yes it is, perform associated action |
112 | mov cl, [mouse.active_sys_button.buttons] |
112 | mov cl, [mouse.active_sys_button.buttons] |
113 | call sys_button_perform_handler |
113 | call sys_button_perform_handler |
114 | jmp .exit |
114 | jmp .exit |
115 | 115 | ||
116 | .buttons_changed: |
116 | .buttons_changed: |
117 | test byte[esp], mouse.LEFT_BUTTON_FLAG |
117 | test byte[esp], mouse.LEFT_BUTTON_FLAG |
118 | jz @f |
118 | jz @f |
119 | mov eax, [esp + 4] |
119 | mov eax, [esp + 4] |
120 | call .call_left_button_handler |
120 | call .call_left_button_handler |
121 | 121 | ||
122 | @@: test byte[esp], mouse.RIGHT_BUTTON_FLAG |
122 | @@: test byte[esp], mouse.RIGHT_BUTTON_FLAG |
123 | jz @f |
123 | jz @f |
124 | mov eax, [esp + 4] |
124 | mov eax, [esp + 4] |
125 | call .call_right_button_handler |
125 | call .call_right_button_handler |
126 | 126 | ||
127 | @@: test byte[esp], mouse.MIDDLE_BUTTON_FLAG |
127 | @@: test byte[esp], mouse.MIDDLE_BUTTON_FLAG |
128 | jz .check_position |
128 | jz .check_position |
129 | mov eax, [esp + 4] |
129 | mov eax, [esp + 4] |
130 | call .call_middle_button_handler |
130 | call .call_middle_button_handler |
131 | 131 | ||
132 | .check_position: |
132 | .check_position: |
133 | movzx eax, word[MOUSE_X] |
133 | movzx eax, word[MOUSE_X] |
134 | movzx ebx, word[MOUSE_Y] |
134 | movzx ebx, word[MOUSE_Y] |
135 | cmp eax, [mouse.state.pos.x] |
135 | cmp eax, [mouse.state.pos.x] |
136 | jne .position_changed |
136 | jne .position_changed |
137 | cmp ebx, [mouse.state.pos.y] |
137 | cmp ebx, [mouse.state.pos.y] |
138 | je .exit |
138 | je .exit |
139 | 139 | ||
140 | .position_changed: |
140 | .position_changed: |
141 | xchg eax, [mouse.state.pos.x] |
141 | xchg eax, [mouse.state.pos.x] |
142 | xchg ebx, [mouse.state.pos.y] |
142 | xchg ebx, [mouse.state.pos.y] |
143 | 143 | ||
144 | call mouse._.move_handler |
144 | call mouse._.move_handler |
145 | 145 | ||
146 | .exit: |
146 | .exit: |
147 | add esp, 8 |
147 | add esp, 8 |
148 | pop ebx eax |
148 | pop ebx eax |
149 | ret |
149 | ret |
150 | 150 | ||
151 | .call_left_button_handler: |
151 | .call_left_button_handler: |
152 | test eax, mouse.LEFT_BUTTON_FLAG |
152 | test eax, mouse.LEFT_BUTTON_FLAG |
153 | jnz mouse._.left_button_press_handler |
153 | jnz mouse._.left_button_press_handler |
154 | jmp mouse._.left_button_release_handler |
154 | jmp mouse._.left_button_release_handler |
155 | 155 | ||
156 | .call_right_button_handler: |
156 | .call_right_button_handler: |
157 | test eax, mouse.RIGHT_BUTTON_FLAG |
157 | test eax, mouse.RIGHT_BUTTON_FLAG |
158 | jnz mouse._.right_button_press_handler |
158 | jnz mouse._.right_button_press_handler |
159 | jmp mouse._.right_button_release_handler |
159 | jmp mouse._.right_button_release_handler |
160 | 160 | ||
161 | .call_middle_button_handler: |
161 | .call_middle_button_handler: |
162 | test eax, mouse.MIDDLE_BUTTON_FLAG |
162 | test eax, mouse.MIDDLE_BUTTON_FLAG |
163 | jnz mouse._.middle_button_press_handler |
163 | jnz mouse._.middle_button_press_handler |
164 | jmp mouse._.middle_button_release_handler |
164 | jmp mouse._.middle_button_release_handler |
165 | 165 | ||
166 | ;============================================================================== |
166 | ;============================================================================== |
167 | ;///// private functions ////////////////////////////////////////////////////// |
167 | ;///// private functions ////////////////////////////////////////////////////// |
168 | ;============================================================================== |
168 | ;============================================================================== |
169 | 169 | ||
170 | uglobal |
170 | uglobal |
171 | mouse.state: |
171 | mouse.state: |
172 | .pos POINT |
172 | .pos POINT |
173 | .buttons db ? |
173 | .buttons db ? |
174 | 174 | ||
175 | ; NOTE: since there's no unique and lifetime-constant button identifiers, |
175 | ; NOTE: since there's no unique and lifetime-constant button identifiers, |
176 | ; we're using two dwords to identify each of them: |
176 | ; we're using two dwords to identify each of them: |
177 | ; * pbid - process slot (high 8 bits) and button id (low 24 bits) pack |
177 | ; * pbid - process slot (high 8 bits) and button id (low 24 bits) pack |
178 | ; * coord - left (high 16 bits) and top (low 16 bits) coordinates pack |
178 | ; * coord - left (high 16 bits) and top (low 16 bits) coordinates pack |
179 | align 4 |
179 | align 4 |
180 | mouse.active_sys_button: |
180 | mouse.active_sys_button: |
181 | .pbid dd ? |
181 | .pbid dd ? |
182 | .coord dd ? |
182 | .coord dd ? |
183 | .buttons db ? |
183 | .buttons db ? |
184 | 184 | ||
185 | align 4 |
185 | align 4 |
186 | mouse.active_sys_window: |
186 | mouse.active_sys_window: |
187 | .pslot dd ? |
187 | .pslot dd ? |
188 | .old_box BOX |
188 | .old_box BOX |
189 | .new_box BOX |
189 | .new_box BOX |
190 | .delta POINT |
190 | .delta POINT |
191 | .last_ticks dd ? |
191 | .last_ticks dd ? |
192 | .action db ? |
192 | .action db ? |
193 | endg |
193 | endg |
194 | 194 | ||
195 | align 4 |
195 | align 4 |
196 | ;------------------------------------------------------------------------------ |
196 | ;------------------------------------------------------------------------------ |
197 | mouse._.left_button_press_handler: ;/////////////////////////////////////////// |
197 | mouse._.left_button_press_handler: ;/////////////////////////////////////////// |
198 | ;------------------------------------------------------------------------------ |
198 | ;------------------------------------------------------------------------------ |
199 | ;? Called when left mouse button has been pressed down |
199 | ;? Called when left mouse button has been pressed down |
200 | ;------------------------------------------------------------------------------ |
200 | ;------------------------------------------------------------------------------ |
201 | test [mouse.state.buttons], not mouse.LEFT_BUTTON_FLAG |
201 | test [mouse.state.buttons], not mouse.LEFT_BUTTON_FLAG |
202 | jnz .exit |
202 | jnz .exit |
203 | 203 | ||
204 | call mouse._.find_sys_window_under_cursor |
204 | call mouse._.find_sys_window_under_cursor |
205 | call mouse._.check_sys_window_actions |
205 | call mouse._.check_sys_window_actions |
206 | mov [mouse.active_sys_window.action], al |
206 | mov [mouse.active_sys_window.action], al |
207 | or eax, eax |
207 | or eax, eax |
208 | jz .exit |
208 | jz .exit |
209 | 209 | ||
210 | xchg eax, edx |
210 | xchg eax, edx |
211 | test dl, mouse.WINDOW_MOVE_FLAG |
211 | test dl, mouse.WINDOW_MOVE_FLAG |
212 | jz @f |
212 | jz @f |
213 | 213 | ||
214 | mov eax, [timer_ticks] |
214 | mov eax, [timer_ticks] |
215 | mov ebx, eax |
215 | mov ebx, eax |
216 | xchg ebx, [mouse.active_sys_window.last_ticks] |
216 | xchg ebx, [mouse.active_sys_window.last_ticks] |
217 | sub eax, ebx |
217 | sub eax, ebx |
218 | cmp eax, 50 |
218 | cmp eax, 50 |
219 | jg @f |
219 | jg @f |
220 | 220 | ||
221 | mov [mouse.active_sys_window.last_ticks], 0 |
221 | mov [mouse.active_sys_window.last_ticks], 0 |
222 | call sys_window_maximize_handler |
222 | call sys_window_maximize_handler |
223 | jmp .exit |
223 | jmp .exit |
224 | 224 | ||
225 | @@: test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED |
225 | @@: test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED |
226 | jnz .exit |
226 | jnz .exit |
227 | mov [mouse.active_sys_window.pslot], esi |
227 | mov [mouse.active_sys_window.pslot], esi |
228 | lea eax, [edi + WDATA.box] |
228 | lea eax, [edi + WDATA.box] |
229 | mov ebx, mouse.active_sys_window.old_box |
229 | mov ebx, mouse.active_sys_window.old_box |
230 | mov ecx, BOX.sizeof |
230 | mov ecx, BOX.sizeof |
231 | call memmove |
231 | call memmove |
232 | mov ebx, mouse.active_sys_window.new_box |
232 | mov ebx, mouse.active_sys_window.new_box |
233 | call memmove |
233 | call memmove |
234 | test edx, mouse.WINDOW_MOVE_FLAG |
234 | test edx, mouse.WINDOW_MOVE_FLAG |
235 | jz @f |
235 | jz @f |
236 | 236 | ||
237 | call .calculate_n_delta |
237 | call .calculate_n_delta |
238 | call .calculate_w_delta |
238 | call .calculate_w_delta |
239 | jmp .call_window_handler |
239 | jmp .call_window_handler |
240 | 240 | ||
241 | @@: test dl, mouse.WINDOW_RESIZE_W_FLAG |
241 | @@: test dl, mouse.WINDOW_RESIZE_W_FLAG |
242 | jz @f |
242 | jz @f |
243 | call .calculate_w_delta |
243 | call .calculate_w_delta |
244 | 244 | ||
245 | @@: test dl, mouse.WINDOW_RESIZE_S_FLAG |
245 | @@: test dl, mouse.WINDOW_RESIZE_S_FLAG |
246 | jz @f |
246 | jz @f |
247 | call .calculate_s_delta |
247 | call .calculate_s_delta |
248 | 248 | ||
249 | @@: test dl, mouse.WINDOW_RESIZE_E_FLAG |
249 | @@: test dl, mouse.WINDOW_RESIZE_E_FLAG |
250 | jz .call_window_handler |
250 | jz .call_window_handler |
251 | call .calculate_e_delta |
251 | call .calculate_e_delta |
252 | 252 | ||
253 | .call_window_handler: |
253 | .call_window_handler: |
254 | mov eax, mouse.active_sys_window.old_box |
254 | mov eax, mouse.active_sys_window.old_box |
255 | call sys_window_start_moving_handler |
255 | call sys_window_start_moving_handler |
256 | 256 | ||
257 | .exit: |
257 | .exit: |
258 | ret |
258 | ret |
259 | 259 | ||
260 | .calculate_n_delta: |
260 | .calculate_n_delta: |
261 | mov eax, [mouse.state.pos.y] |
261 | mov eax, [mouse.state.pos.y] |
262 | sub eax, [mouse.active_sys_window.old_box.top] |
262 | sub eax, [mouse.active_sys_window.old_box.top] |
263 | mov [mouse.active_sys_window.delta.y], eax |
263 | mov [mouse.active_sys_window.delta.y], eax |
264 | ret |
264 | ret |
265 | 265 | ||
266 | .calculate_w_delta: |
266 | .calculate_w_delta: |
267 | mov eax, [mouse.state.pos.x] |
267 | mov eax, [mouse.state.pos.x] |
268 | sub eax, [mouse.active_sys_window.old_box.left] |
268 | sub eax, [mouse.active_sys_window.old_box.left] |
269 | mov [mouse.active_sys_window.delta.x], eax |
269 | mov [mouse.active_sys_window.delta.x], eax |
270 | ret |
270 | ret |
271 | 271 | ||
272 | .calculate_s_delta: |
272 | .calculate_s_delta: |
273 | mov eax, [mouse.active_sys_window.old_box.top] |
273 | mov eax, [mouse.active_sys_window.old_box.top] |
274 | add eax, [mouse.active_sys_window.old_box.height] |
274 | add eax, [mouse.active_sys_window.old_box.height] |
275 | sub eax, [mouse.state.pos.y] |
275 | sub eax, [mouse.state.pos.y] |
276 | mov [mouse.active_sys_window.delta.y], eax |
276 | mov [mouse.active_sys_window.delta.y], eax |
277 | ret |
277 | ret |
278 | 278 | ||
279 | .calculate_e_delta: |
279 | .calculate_e_delta: |
280 | mov eax, [mouse.active_sys_window.old_box.left] |
280 | mov eax, [mouse.active_sys_window.old_box.left] |
281 | add eax, [mouse.active_sys_window.old_box.width] |
281 | add eax, [mouse.active_sys_window.old_box.width] |
282 | sub eax, [mouse.state.pos.x] |
282 | sub eax, [mouse.state.pos.x] |
283 | mov [mouse.active_sys_window.delta.x], eax |
283 | mov [mouse.active_sys_window.delta.x], eax |
284 | ret |
284 | ret |
285 | 285 | ||
286 | align 4 |
286 | align 4 |
287 | ;------------------------------------------------------------------------------ |
287 | ;------------------------------------------------------------------------------ |
288 | mouse._.left_button_release_handler: ;///////////////////////////////////////// |
288 | mouse._.left_button_release_handler: ;///////////////////////////////////////// |
289 | ;------------------------------------------------------------------------------ |
289 | ;------------------------------------------------------------------------------ |
290 | ;? Called when left mouse button has been released |
290 | ;? Called when left mouse button has been released |
291 | ;------------------------------------------------------------------------------ |
291 | ;------------------------------------------------------------------------------ |
292 | xor esi, esi |
292 | xor esi, esi |
293 | xchg esi, [mouse.active_sys_window.pslot] |
293 | xchg esi, [mouse.active_sys_window.pslot] |
294 | or esi, esi |
294 | or esi, esi |
295 | jz .exit |
295 | jz .exit |
296 | 296 | ||
297 | mov eax, esi |
297 | mov eax, esi |
298 | shl eax, 5 |
298 | shl eax, 5 |
299 | add eax, window_data + WDATA.box |
299 | add eax, window_data + WDATA.box |
300 | mov ebx, mouse.active_sys_window.old_box |
300 | mov ebx, mouse.active_sys_window.old_box |
301 | mov ecx, BOX.sizeof |
301 | mov ecx, BOX.sizeof |
302 | call memmove |
302 | call memmove |
303 | 303 | ||
304 | mov eax, mouse.active_sys_window.old_box |
304 | mov eax, mouse.active_sys_window.old_box |
305 | mov ebx, mouse.active_sys_window.new_box |
305 | mov ebx, mouse.active_sys_window.new_box |
306 | call sys_window_end_moving_handler |
306 | call sys_window_end_moving_handler |
307 | 307 | ||
308 | .exit: |
308 | .exit: |
309 | ret |
309 | ret |
310 | 310 | ||
311 | align 4 |
311 | align 4 |
312 | ;------------------------------------------------------------------------------ |
312 | ;------------------------------------------------------------------------------ |
313 | mouse._.right_button_press_handler: ;////////////////////////////////////////// |
313 | mouse._.right_button_press_handler: ;////////////////////////////////////////// |
314 | ;------------------------------------------------------------------------------ |
314 | ;------------------------------------------------------------------------------ |
315 | ;? Called when right mouse button has been pressed down |
315 | ;? Called when right mouse button has been pressed down |
316 | ;------------------------------------------------------------------------------ |
316 | ;------------------------------------------------------------------------------ |
317 | test [mouse.state.buttons], not mouse.RIGHT_BUTTON_FLAG |
317 | test [mouse.state.buttons], not mouse.RIGHT_BUTTON_FLAG |
318 | jnz .exit |
318 | jnz .exit |
319 | 319 | ||
320 | call mouse._.find_sys_window_under_cursor |
320 | call mouse._.find_sys_window_under_cursor |
321 | call mouse._.check_sys_window_actions |
321 | call mouse._.check_sys_window_actions |
322 | test al, mouse.WINDOW_MOVE_FLAG |
322 | test al, mouse.WINDOW_MOVE_FLAG |
323 | jz .exit |
323 | jz .exit |
324 | 324 | ||
325 | call sys_window_rollup_handler |
325 | call sys_window_rollup_handler |
326 | 326 | ||
327 | .exit: |
327 | .exit: |
328 | ret |
328 | ret |
329 | 329 | ||
330 | align 4 |
330 | align 4 |
331 | ;------------------------------------------------------------------------------ |
331 | ;------------------------------------------------------------------------------ |
332 | mouse._.right_button_release_handler: ;//////////////////////////////////////// |
332 | mouse._.right_button_release_handler: ;//////////////////////////////////////// |
333 | ;------------------------------------------------------------------------------ |
333 | ;------------------------------------------------------------------------------ |
334 | ;? Called when right mouse button has been released |
334 | ;? Called when right mouse button has been released |
335 | ;------------------------------------------------------------------------------ |
335 | ;------------------------------------------------------------------------------ |
336 | ret |
336 | ret |
337 | 337 | ||
338 | align 4 |
338 | align 4 |
339 | ;------------------------------------------------------------------------------ |
339 | ;------------------------------------------------------------------------------ |
340 | mouse._.middle_button_press_handler: ;///////////////////////////////////////// |
340 | mouse._.middle_button_press_handler: ;///////////////////////////////////////// |
341 | ;------------------------------------------------------------------------------ |
341 | ;------------------------------------------------------------------------------ |
342 | ;? Called when middle mouse button has been pressed down |
342 | ;? Called when middle mouse button has been pressed down |
343 | ;------------------------------------------------------------------------------ |
343 | ;------------------------------------------------------------------------------ |
344 | ret |
344 | ret |
345 | 345 | ||
346 | align 4 |
346 | align 4 |
347 | ;------------------------------------------------------------------------------ |
347 | ;------------------------------------------------------------------------------ |
348 | mouse._.middle_button_release_handler: ;/////////////////////////////////////// |
348 | mouse._.middle_button_release_handler: ;/////////////////////////////////////// |
349 | ;------------------------------------------------------------------------------ |
349 | ;------------------------------------------------------------------------------ |
350 | ;? Called when middle mouse button has been released |
350 | ;? Called when middle mouse button has been released |
351 | ;------------------------------------------------------------------------------ |
351 | ;------------------------------------------------------------------------------ |
352 | ret |
352 | ret |
353 | 353 | ||
354 | align 4 |
354 | align 4 |
355 | ;------------------------------------------------------------------------------ |
355 | ;------------------------------------------------------------------------------ |
356 | mouse._.move_handler: ;//////////////////////////////////////////////////////// |
356 | mouse._.move_handler: ;//////////////////////////////////////////////////////// |
357 | ;------------------------------------------------------------------------------ |
357 | ;------------------------------------------------------------------------------ |
358 | ;? Called when cursor has been moved |
358 | ;? Called when cursor has been moved |
359 | ;------------------------------------------------------------------------------ |
359 | ;------------------------------------------------------------------------------ |
360 | ;> eax = old x coord |
360 | ;> eax = old x coord |
361 | ;> ebx = old y coord |
361 | ;> ebx = old y coord |
362 | ;------------------------------------------------------------------------------ |
362 | ;------------------------------------------------------------------------------ |
363 | cmp [mouse.active_sys_button.pbid], 0 |
363 | cmp [mouse.active_sys_button.pbid], 0 |
364 | jnz .exit |
364 | jnz .exit |
365 | 365 | ||
366 | mov esi, [mouse.active_sys_window.pslot] |
366 | mov esi, [mouse.active_sys_window.pslot] |
367 | or esi, esi |
367 | or esi, esi |
368 | jz .exit |
368 | jz .exit |
369 | 369 | ||
370 | mov eax, mouse.active_sys_window.new_box |
370 | mov eax, mouse.active_sys_window.new_box |
371 | mov ebx, mouse.active_sys_window.old_box |
371 | mov ebx, mouse.active_sys_window.old_box |
372 | mov ecx, BOX.sizeof |
372 | mov ecx, BOX.sizeof |
373 | call memmove |
373 | call memmove |
374 | 374 | ||
375 | mov dl, [mouse.active_sys_window.action] |
375 | mov dl, [mouse.active_sys_window.action] |
376 | test dl, mouse.WINDOW_MOVE_FLAG |
376 | test dl, mouse.WINDOW_MOVE_FLAG |
377 | jz .check_resize_w |
377 | jz .check_resize_w |
378 | 378 | ||
379 | mov eax, [mouse.state.pos.x] |
379 | mov eax, [mouse.state.pos.x] |
380 | sub eax, [mouse.active_sys_window.delta.x] |
380 | sub eax, [mouse.active_sys_window.delta.x] |
381 | mov [mouse.active_sys_window.new_box.left], eax |
381 | mov [mouse.active_sys_window.new_box.left], eax |
382 | mov eax, [mouse.state.pos.y] |
382 | mov eax, [mouse.state.pos.y] |
383 | sub eax, [mouse.active_sys_window.delta.y] |
383 | sub eax, [mouse.active_sys_window.delta.y] |
384 | mov [mouse.active_sys_window.new_box.top], eax |
384 | mov [mouse.active_sys_window.new_box.top], eax |
385 | 385 | ||
386 | mov eax, [mouse.active_sys_window.new_box.left] |
386 | mov eax, [mouse.active_sys_window.new_box.left] |
387 | or eax, eax |
387 | or eax, eax |
388 | jge @f |
388 | jge @f |
389 | xor eax, eax |
389 | xor eax, eax |
390 | mov [mouse.active_sys_window.new_box.left], eax |
390 | mov [mouse.active_sys_window.new_box.left], eax |
391 | @@: add eax, [mouse.active_sys_window.new_box.width] |
391 | @@: add eax, [mouse.active_sys_window.new_box.width] |
392 | cmp eax, [Screen_Max_X] |
392 | cmp eax, [Screen_Max_X] |
393 | jl @f |
393 | jl @f |
394 | sub eax, [Screen_Max_X] |
394 | sub eax, [Screen_Max_X] |
395 | sub [mouse.active_sys_window.new_box.left], eax |
395 | sub [mouse.active_sys_window.new_box.left], eax |
396 | @@: mov eax, [mouse.active_sys_window.new_box.top] |
396 | @@: mov eax, [mouse.active_sys_window.new_box.top] |
397 | or eax, eax |
397 | or eax, eax |
398 | jge @f |
398 | jge @f |
399 | xor eax, eax |
399 | xor eax, eax |
400 | mov [mouse.active_sys_window.new_box.top], eax |
400 | mov [mouse.active_sys_window.new_box.top], eax |
401 | @@: add eax, [mouse.active_sys_window.new_box.height] |
401 | @@: add eax, [mouse.active_sys_window.new_box.height] |
402 | cmp eax, [Screen_Max_Y] |
402 | cmp eax, [Screen_Max_Y] |
403 | jle .call_window_handler |
403 | jle .call_window_handler |
404 | sub eax, [Screen_Max_Y] |
404 | sub eax, [Screen_Max_Y] |
405 | sub [mouse.active_sys_window.new_box.top], eax |
405 | sub [mouse.active_sys_window.new_box.top], eax |
406 | jmp .call_window_handler |
406 | jmp .call_window_handler |
407 | 407 | ||
408 | .check_resize_w: |
408 | .check_resize_w: |
409 | test dl, mouse.WINDOW_RESIZE_W_FLAG |
409 | test dl, mouse.WINDOW_RESIZE_W_FLAG |
410 | jz .check_resize_s |
410 | jz .check_resize_s |
411 | 411 | ||
412 | mov eax, [mouse.state.pos.x] |
412 | mov eax, [mouse.state.pos.x] |
413 | sub eax, [mouse.active_sys_window.delta.x] |
413 | sub eax, [mouse.active_sys_window.delta.x] |
414 | mov [mouse.active_sys_window.new_box.left], eax |
414 | mov [mouse.active_sys_window.new_box.left], eax |
415 | sub eax, [mouse.active_sys_window.old_box.left] |
415 | sub eax, [mouse.active_sys_window.old_box.left] |
416 | sub [mouse.active_sys_window.new_box.width], eax |
416 | sub [mouse.active_sys_window.new_box.width], eax |
417 | 417 | ||
418 | mov eax, [mouse.active_sys_window.new_box.width] |
418 | mov eax, [mouse.active_sys_window.new_box.width] |
419 | sub eax, 127 |
419 | sub eax, 127 |
420 | jge @f |
420 | jge @f |
421 | add [mouse.active_sys_window.new_box.left], eax |
421 | add [mouse.active_sys_window.new_box.left], eax |
422 | mov [mouse.active_sys_window.new_box.width], 127 |
422 | mov [mouse.active_sys_window.new_box.width], 127 |
423 | @@: mov eax, [mouse.active_sys_window.new_box.left] |
423 | @@: mov eax, [mouse.active_sys_window.new_box.left] |
424 | or eax, eax |
424 | or eax, eax |
425 | jge .check_resize_s |
425 | jge .check_resize_s |
426 | add [mouse.active_sys_window.new_box.width], eax |
426 | add [mouse.active_sys_window.new_box.width], eax |
427 | xor eax, eax |
427 | xor eax, eax |
428 | mov [mouse.active_sys_window.new_box.left], eax |
428 | mov [mouse.active_sys_window.new_box.left], eax |
429 | 429 | ||
430 | .check_resize_s: |
430 | .check_resize_s: |
431 | test dl, mouse.WINDOW_RESIZE_S_FLAG |
431 | test dl, mouse.WINDOW_RESIZE_S_FLAG |
432 | jz .check_resize_e |
432 | jz .check_resize_e |
433 | 433 | ||
434 | mov eax, [mouse.state.pos.y] |
434 | mov eax, [mouse.state.pos.y] |
435 | add eax, [mouse.active_sys_window.delta.y] |
435 | add eax, [mouse.active_sys_window.delta.y] |
436 | sub eax, [mouse.active_sys_window.old_box.top] |
436 | sub eax, [mouse.active_sys_window.old_box.top] |
437 | mov [mouse.active_sys_window.new_box.height], eax |
437 | mov [mouse.active_sys_window.new_box.height], eax |
438 | 438 | ||
439 | push eax |
439 | push eax |
440 | mov edi, esi |
440 | mov edi, esi |
441 | shl edi, 5 |
441 | shl edi, 5 |
442 | add edi, window_data |
442 | add edi, window_data |
443 | call window._.get_rolledup_height |
443 | call window._.get_rolledup_height |
444 | mov ecx, eax |
444 | mov ecx, eax |
445 | pop eax |
445 | pop eax |
446 | mov eax, [mouse.active_sys_window.new_box.height] |
446 | mov eax, [mouse.active_sys_window.new_box.height] |
447 | cmp eax, ecx |
447 | cmp eax, ecx |
448 | jge @f |
448 | jge @f |
449 | mov eax, ecx |
449 | mov eax, ecx |
450 | mov [mouse.active_sys_window.new_box.height], eax |
450 | mov [mouse.active_sys_window.new_box.height], eax |
451 | @@: add eax, [mouse.active_sys_window.new_box.top] |
451 | @@: add eax, [mouse.active_sys_window.new_box.top] |
452 | cmp eax, [Screen_Max_Y] |
452 | cmp eax, [Screen_Max_Y] |
453 | jle .check_resize_e |
453 | jle .check_resize_e |
454 | sub eax, [Screen_Max_Y] |
454 | sub eax, [Screen_Max_Y] |
455 | neg eax |
455 | neg eax |
456 | add [mouse.active_sys_window.new_box.height], eax |
456 | add [mouse.active_sys_window.new_box.height], eax |
457 | mov ecx, [Screen_Max_Y] |
457 | mov ecx, [Screen_Max_Y] |
458 | cmp ecx, eax |
458 | cmp ecx, eax |
459 | jge .check_resize_e |
459 | jge .check_resize_e |
460 | mov [mouse.active_sys_window.new_box.height], ecx |
460 | mov [mouse.active_sys_window.new_box.height], ecx |
461 | 461 | ||
462 | .check_resize_e: |
462 | .check_resize_e: |
463 | test dl, mouse.WINDOW_RESIZE_E_FLAG |
463 | test dl, mouse.WINDOW_RESIZE_E_FLAG |
464 | jz .call_window_handler |
464 | jz .call_window_handler |
465 | 465 | ||
466 | mov eax, [mouse.state.pos.x] |
466 | mov eax, [mouse.state.pos.x] |
467 | add eax, [mouse.active_sys_window.delta.x] |
467 | add eax, [mouse.active_sys_window.delta.x] |
468 | sub eax, [mouse.active_sys_window.old_box.left] |
468 | sub eax, [mouse.active_sys_window.old_box.left] |
469 | mov [mouse.active_sys_window.new_box.width], eax |
469 | mov [mouse.active_sys_window.new_box.width], eax |
470 | 470 | ||
471 | mov eax, [mouse.active_sys_window.new_box.width] |
471 | mov eax, [mouse.active_sys_window.new_box.width] |
472 | cmp eax, 127 |
472 | cmp eax, 127 |
473 | jge @f |
473 | jge @f |
474 | mov eax, 127 |
474 | mov eax, 127 |
475 | mov [mouse.active_sys_window.new_box.width], eax |
475 | mov [mouse.active_sys_window.new_box.width], eax |
476 | @@: add eax, [mouse.active_sys_window.new_box.left] |
476 | @@: add eax, [mouse.active_sys_window.new_box.left] |
477 | cmp eax, [Screen_Max_X] |
477 | cmp eax, [Screen_Max_X] |
478 | jle .call_window_handler |
478 | jle .call_window_handler |
479 | sub eax, [Screen_Max_X] |
479 | sub eax, [Screen_Max_X] |
480 | neg eax |
480 | neg eax |
481 | add [mouse.active_sys_window.new_box.width], eax |
481 | add [mouse.active_sys_window.new_box.width], eax |
482 | mov ecx, [Screen_Max_X] |
482 | mov ecx, [Screen_Max_X] |
483 | cmp ecx, eax |
483 | cmp ecx, eax |
484 | jge .call_window_handler |
484 | jge .call_window_handler |
485 | mov [mouse.active_sys_window.new_box.width], ecx |
485 | mov [mouse.active_sys_window.new_box.width], ecx |
486 | 486 | ||
487 | .call_window_handler: |
487 | .call_window_handler: |
488 | mov eax, mouse.active_sys_window.old_box |
488 | mov eax, mouse.active_sys_window.old_box |
489 | mov ebx, mouse.active_sys_window.new_box |
489 | mov ebx, mouse.active_sys_window.new_box |
490 | 490 | ||
491 | push esi |
491 | push esi |
492 | mov esi, mouse.active_sys_window.old_box |
492 | mov esi, mouse.active_sys_window.old_box |
493 | mov edi, mouse.active_sys_window.new_box |
493 | mov edi, mouse.active_sys_window.new_box |
494 | mov ecx, BOX.sizeof / 4 |
494 | mov ecx, BOX.sizeof / 4 |
495 | repe |
495 | repe |
496 | cmpsd |
496 | cmpsd |
497 | pop esi |
497 | pop esi |
498 | je .exit |
498 | je .exit |
499 | 499 | ||
500 | mov [mouse.active_sys_window.last_ticks], 0 |
500 | mov [mouse.active_sys_window.last_ticks], 0 |
501 | call sys_window_moving_handler |
501 | call sys_window_moving_handler |
502 | 502 | ||
503 | .exit: |
503 | .exit: |
504 | ret |
504 | ret |
505 | 505 | ||
506 | align 4 |
506 | align 4 |
507 | ;------------------------------------------------------------------------------ |
507 | ;------------------------------------------------------------------------------ |
508 | mouse._.find_sys_window_under_cursor: ;//////////////////////////////////////// |
508 | mouse._.find_sys_window_under_cursor: ;//////////////////////////////////////// |
509 | ;------------------------------------------------------------------------------ |
509 | ;------------------------------------------------------------------------------ |
510 | ;? Find system window object which is currently visible on screen and has |
510 | ;? Find system window object which is currently visible on screen and has |
511 | ;? mouse cursor within its bounds |
511 | ;? mouse cursor within its bounds |
512 | ;------------------------------------------------------------------------------ |
512 | ;------------------------------------------------------------------------------ |
513 | ;< esi = process slot |
513 | ;< esi = process slot |
514 | ;< edi = pointer to WDATA struct |
514 | ;< edi = pointer to WDATA struct |
515 | ;------------------------------------------------------------------------------ |
515 | ;------------------------------------------------------------------------------ |
516 | mov esi, [Screen_Max_X] |
516 | mov esi, [Screen_Max_X] |
517 | inc esi |
517 | inc esi |
518 | imul esi, [mouse.state.pos.y] |
518 | imul esi, [mouse.state.pos.y] |
519 | add esi, [_WinMapAddress] |
519 | add esi, [_WinMapAddress] |
520 | add esi, [mouse.state.pos.x] |
520 | add esi, [mouse.state.pos.x] |
521 | movzx esi, byte[esi] |
521 | movzx esi, byte[esi] |
522 | mov edi, esi |
522 | mov edi, esi |
523 | shl edi, 5 |
523 | shl edi, 5 |
524 | add edi, window_data |
524 | add edi, window_data |
525 | ret |
525 | ret |
526 | 526 | ||
527 | align 4 |
527 | align 4 |
528 | ;------------------------------------------------------------------------------ |
528 | ;------------------------------------------------------------------------------ |
529 | mouse._.activate_sys_window_under_cursor: ;//////////////////////////////////// |
529 | mouse._.activate_sys_window_under_cursor: ;//////////////////////////////////// |
530 | ;------------------------------------------------------------------------------ |
530 | ;------------------------------------------------------------------------------ |
531 | ;? |
531 | ;? |
532 | ;------------------------------------------------------------------------------ |
532 | ;------------------------------------------------------------------------------ |
533 | ; activate and redraw window under cursor (if necessary) |
533 | ; activate and redraw window under cursor (if necessary) |
534 | call mouse._.find_sys_window_under_cursor |
534 | call mouse._.find_sys_window_under_cursor |
535 | movzx esi, word[WIN_STACK + esi * 2] |
535 | movzx esi, word[WIN_STACK + esi * 2] |
536 | lea esi, [WIN_POS + esi * 2] |
536 | lea esi, [WIN_POS + esi * 2] |
537 | jmp waredraw |
537 | jmp waredraw |
538 | 538 | ||
539 | align 4 |
539 | align 4 |
540 | ;------------------------------------------------------------------------------ |
540 | ;------------------------------------------------------------------------------ |
541 | mouse._.find_sys_button_under_cursor: ;//////////////////////////////////////// |
541 | mouse._.find_sys_button_under_cursor: ;//////////////////////////////////////// |
542 | ;------------------------------------------------------------------------------ |
542 | ;------------------------------------------------------------------------------ |
543 | ;? Find system button object which is currently visible on screen and has |
543 | ;? Find system button object which is currently visible on screen and has |
544 | ;? mouse cursor within its bounds |
544 | ;? mouse cursor within its bounds |
545 | ;------------------------------------------------------------------------------ |
545 | ;------------------------------------------------------------------------------ |
546 | ;< eax = pack[8(process slot), 24(button id)] or 0 |
546 | ;< eax = pack[8(process slot), 24(button id)] or 0 |
547 | ;< ebx = pack[16(button x coord), 16(button y coord)] |
547 | ;< ebx = pack[16(button x coord), 16(button y coord)] |
548 | ;------------------------------------------------------------------------------ |
548 | ;------------------------------------------------------------------------------ |
549 | push ecx edx esi edi |
549 | push ecx edx esi edi |
550 | 550 | ||
551 | call mouse._.find_sys_window_under_cursor |
551 | call mouse._.find_sys_window_under_cursor |
552 | mov edx, esi |
552 | mov edx, esi |
553 | 553 | ||
554 | ; check if any process button contains cursor |
554 | ; check if any process button contains cursor |
555 | mov eax, [BTN_ADDR] |
555 | mov eax, [BTN_ADDR] |
556 | mov ecx, [eax] |
556 | mov ecx, [eax] |
557 | imul esi, ecx, SYS_BUTTON.sizeof |
557 | imul esi, ecx, SYS_BUTTON.sizeof |
558 | add esi, eax |
558 | add esi, eax |
559 | inc ecx |
559 | inc ecx |
560 | add esi, SYS_BUTTON.sizeof |
560 | add esi, SYS_BUTTON.sizeof |
561 | 561 | ||
562 | .next_button: |
562 | .next_button: |
563 | dec ecx |
563 | dec ecx |
564 | jz .not_found |
564 | jz .not_found |
565 | 565 | ||
566 | add esi, -SYS_BUTTON.sizeof |
566 | add esi, -SYS_BUTTON.sizeof |
567 | 567 | ||
568 | ; does it belong to our process? |
568 | ; does it belong to our process? |
569 | cmp dx, [esi + SYS_BUTTON.pslot] |
569 | cmp dx, [esi + SYS_BUTTON.pslot] |
570 | jne .next_button |
570 | jne .next_button |
571 | 571 | ||
572 | ; does it contain cursor coordinates? |
572 | ; does it contain cursor coordinates? |
573 | mov eax, [mouse.state.pos.x] |
573 | mov eax, [mouse.state.pos.x] |
574 | sub eax, [edi + WDATA.box.left] |
574 | sub eax, [edi + WDATA.box.left] |
575 | sub ax, [esi + SYS_BUTTON.left] |
575 | sub ax, [esi + SYS_BUTTON.left] |
576 | jl .next_button |
576 | jl .next_button |
577 | sub ax, [esi + SYS_BUTTON.width] |
577 | sub ax, [esi + SYS_BUTTON.width] |
578 | jge .next_button |
578 | jge .next_button |
579 | mov eax, [mouse.state.pos.y] |
579 | mov eax, [mouse.state.pos.y] |
580 | sub eax, [edi + WDATA.box.top] |
580 | sub eax, [edi + WDATA.box.top] |
581 | sub ax, [esi + SYS_BUTTON.top] |
581 | sub ax, [esi + SYS_BUTTON.top] |
582 | jl .next_button |
582 | jl .next_button |
583 | sub ax, [esi + SYS_BUTTON.height] |
583 | sub ax, [esi + SYS_BUTTON.height] |
584 | jge .next_button |
584 | jge .next_button |
585 | 585 | ||
586 | ; okay, return it |
586 | ; okay, return it |
587 | shl edx, 24 |
587 | shl edx, 24 |
588 | mov eax, dword[esi + SYS_BUTTON.id_hi - 2] |
588 | mov eax, dword[esi + SYS_BUTTON.id_hi - 2] |
589 | mov ax, [esi + SYS_BUTTON.id_lo] |
589 | mov ax, [esi + SYS_BUTTON.id_lo] |
590 | and eax, 0x0ffffff |
590 | and eax, 0x0ffffff |
591 | or eax, edx |
591 | or eax, edx |
592 | mov ebx, dword[esi + SYS_BUTTON.left - 2] |
592 | mov ebx, dword[esi + SYS_BUTTON.left - 2] |
593 | mov bx, [esi + SYS_BUTTON.top] |
593 | mov bx, [esi + SYS_BUTTON.top] |
594 | jmp .exit |
594 | jmp .exit |
595 | 595 | ||
596 | .not_found: |
596 | .not_found: |
597 | xor eax, eax |
597 | xor eax, eax |
598 | xor ebx, ebx |
598 | xor ebx, ebx |
599 | 599 | ||
600 | .exit: |
600 | .exit: |
601 | pop edi esi edx ecx |
601 | pop edi esi edx ecx |
602 | ret |
602 | ret |
603 | 603 | ||
604 | align 4 |
604 | align 4 |
605 | ;------------------------------------------------------------------------------ |
605 | ;------------------------------------------------------------------------------ |
606 | mouse._.check_sys_window_actions: ;//////////////////////////////////////////// |
606 | mouse._.check_sys_window_actions: ;//////////////////////////////////////////// |
607 | ;------------------------------------------------------------------------------ |
607 | ;------------------------------------------------------------------------------ |
608 | ;? |
608 | ;? |
609 | ;------------------------------------------------------------------------------ |
609 | ;------------------------------------------------------------------------------ |
610 | ;< eax = action flags or 0 |
610 | ;< eax = action flags or 0 |
611 | ;------------------------------------------------------------------------------ |
611 | ;------------------------------------------------------------------------------ |
612 | ; is window movable? |
612 | ; is window movable? |
613 | test byte[edi + WDATA.cl_titlebar + 3], 0x01 |
613 | test byte[edi + WDATA.cl_titlebar + 3], 0x01 |
614 | jnz .no_action |
614 | jnz .no_action |
615 | 615 | ||
616 | mov eax, [mouse.state.pos.x] |
616 | mov eax, [mouse.state.pos.x] |
617 | mov ebx, [mouse.state.pos.y] |
617 | mov ebx, [mouse.state.pos.y] |
618 | sub eax, [edi + WDATA.box.left] |
618 | sub eax, [edi + WDATA.box.left] |
619 | sub ebx, [edi + WDATA.box.top] |
619 | sub ebx, [edi + WDATA.box.top] |
620 | 620 | ||
621 | ; is there a window titlebar under cursor? |
621 | ; is there a window titlebar under cursor? |
622 | push eax |
622 | push eax |
623 | call window._.get_titlebar_height |
623 | call window._.get_titlebar_height |
624 | cmp ebx, eax |
624 | cmp ebx, eax |
625 | pop eax |
625 | pop eax |
626 | jl .move_action |
626 | jl .move_action |
627 | 627 | ||
628 | ; no there isn't, can it be resized then? |
628 | ; no there isn't, can it be resized then? |
629 | mov dl, [edi + WDATA.fl_wstyle] |
629 | mov dl, [edi + WDATA.fl_wstyle] |
630 | and dl, 0x0f |
630 | and dl, 0x0f |
631 | ; NOTE: dangerous optimization, revise if window types changed; |
631 | ; NOTE: dangerous optimization, revise if window types changed; |
632 | ; this currently implies only types 2 and 3 could be resized |
632 | ; this currently implies only types 2 and 3 could be resized |
633 | test dl, 2 |
633 | test dl, 2 |
634 | jz .no_action |
634 | jz .no_action |
635 | 635 | ||
636 | mov ecx, [edi + WDATA.box.width] |
636 | mov ecx, [edi + WDATA.box.width] |
637 | add ecx, -window.BORDER_SIZE |
637 | add ecx, -window.BORDER_SIZE |
638 | mov edx, [edi + WDATA.box.height] |
638 | mov edx, [edi + WDATA.box.height] |
639 | add edx, -window.BORDER_SIZE |
639 | add edx, -window.BORDER_SIZE |
640 | 640 | ||
641 | ; is it rolled up? |
641 | ; is it rolled up? |
642 | test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP |
642 | test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP |
643 | jnz .resize_w_or_e_action |
643 | jnz .resize_w_or_e_action |
644 | 644 | ||
645 | cmp eax, window.BORDER_SIZE |
645 | cmp eax, window.BORDER_SIZE |
646 | jl .resize_w_action |
646 | jl .resize_w_action |
647 | cmp eax, ecx |
647 | cmp eax, ecx |
648 | jg .resize_e_action |
648 | jg .resize_e_action |
649 | cmp ebx, edx |
649 | cmp ebx, edx |
650 | jle .no_action |
650 | jle .no_action |
651 | 651 | ||
652 | .resize_s_action: |
652 | .resize_s_action: |
653 | cmp eax, window.BORDER_SIZE + 10 |
653 | cmp eax, window.BORDER_SIZE + 10 |
654 | jl .resize_sw_action |
654 | jl .resize_sw_action |
655 | add ecx, -10 |
655 | add ecx, -10 |
656 | cmp eax, ecx |
656 | cmp eax, ecx |
657 | jge .resize_se_action |
657 | jge .resize_se_action |
658 | mov eax, mouse.WINDOW_RESIZE_S_FLAG |
658 | mov eax, mouse.WINDOW_RESIZE_S_FLAG |
659 | jmp .exit |
659 | jmp .exit |
660 | 660 | ||
661 | .resize_w_or_e_action: |
661 | .resize_w_or_e_action: |
662 | cmp eax, window.BORDER_SIZE + 10 |
662 | cmp eax, window.BORDER_SIZE + 10 |
663 | jl .resize_w_action.direct |
663 | jl .resize_w_action.direct |
664 | add ecx, -10 |
664 | add ecx, -10 |
665 | cmp eax, ecx |
665 | cmp eax, ecx |
666 | jg .resize_e_action.direct |
666 | jg .resize_e_action.direct |
667 | jmp .no_action |
667 | jmp .no_action |
668 | 668 | ||
669 | .resize_w_action: |
669 | .resize_w_action: |
670 | add edx, -10 |
670 | add edx, -10 |
671 | cmp ebx, edx |
671 | cmp ebx, edx |
672 | jge .resize_sw_action |
672 | jge .resize_sw_action |
673 | .resize_w_action.direct: |
673 | .resize_w_action.direct: |
674 | mov eax, mouse.WINDOW_RESIZE_W_FLAG |
674 | mov eax, mouse.WINDOW_RESIZE_W_FLAG |
675 | jmp .exit |
675 | jmp .exit |
676 | 676 | ||
677 | .resize_e_action: |
677 | .resize_e_action: |
678 | add edx, -10 |
678 | add edx, -10 |
679 | cmp ebx, edx |
679 | cmp ebx, edx |
680 | jge .resize_se_action |
680 | jge .resize_se_action |
681 | .resize_e_action.direct: |
681 | .resize_e_action.direct: |
682 | mov eax, mouse.WINDOW_RESIZE_E_FLAG |
682 | mov eax, mouse.WINDOW_RESIZE_E_FLAG |
683 | jmp .exit |
683 | jmp .exit |
684 | 684 | ||
685 | .resize_sw_action: |
685 | .resize_sw_action: |
686 | mov eax, mouse.WINDOW_RESIZE_SW_FLAG |
686 | mov eax, mouse.WINDOW_RESIZE_SW_FLAG |
687 | jmp .exit |
687 | jmp .exit |
688 | 688 | ||
689 | .resize_se_action: |
689 | .resize_se_action: |
690 | mov eax, mouse.WINDOW_RESIZE_SE_FLAG |
690 | mov eax, mouse.WINDOW_RESIZE_SE_FLAG |
691 | jmp .exit |
691 | jmp .exit |
692 | 692 | ||
693 | .move_action: |
693 | .move_action: |
694 | mov eax, mouse.WINDOW_MOVE_FLAG |
694 | mov eax, mouse.WINDOW_MOVE_FLAG |
695 | jmp .exit |
695 | jmp .exit |
696 | 696 | ||
697 | .no_action: |
697 | .no_action: |
698 | xor eax, eax |
698 | xor eax, eax |
699 | 699 | ||
700 | .exit: |
700 | .exit: |
701 | ret>>>>> |
701 | ret>>>>> |