Subversion Repositories Kolibri OS

Rev

Rev 5351 | Rev 5851 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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