|
|
@@ -3309,61 +3309,57 @@ impl WindowManager { |
| 3309 |
3309 |
return Ok(()); |
| 3310 |
3310 |
} |
| 3311 |
3311 |
|
|
3312 |
+ use crate::size_hints::{flags::*, offset::*}; |
|
3313 |
+ |
| 3312 |
3314 |
let read_u32 = |offset: usize| -> u32 { |
| 3313 |
3315 |
let bytes = &size_hints.value[offset * 4..(offset + 1) * 4]; |
| 3314 |
3316 |
u32::from_ne_bytes([bytes[0], bytes[1], bytes[2], bytes[3]]) |
| 3315 |
3317 |
}; |
| 3316 |
3318 |
|
| 3317 |
|
- let flags = read_u32(0); |
| 3318 |
|
- |
| 3319 |
|
- const P_MIN_SIZE: u32 = 1 << 4; |
| 3320 |
|
- const P_MAX_SIZE: u32 = 1 << 5; |
| 3321 |
|
- const P_RESIZE_INC: u32 = 1 << 6; |
| 3322 |
|
- const P_ASPECT: u32 = 1 << 7; |
| 3323 |
|
- const P_BASE_SIZE: u32 = 1 << 8; |
|
3319 |
+ let flags = read_u32(FLAGS); |
| 3324 |
3320 |
|
| 3325 |
3321 |
if let Some(client) = self.clients.get_mut(&window) { |
| 3326 |
3322 |
if flags & P_BASE_SIZE != 0 { |
| 3327 |
|
- client.base_width = read_u32(15) as i32; |
| 3328 |
|
- client.base_height = read_u32(16) as i32; |
|
3323 |
+ client.base_width = read_u32(BASE_WIDTH) as i32; |
|
3324 |
+ client.base_height = read_u32(BASE_HEIGHT) as i32; |
| 3329 |
3325 |
} else if flags & P_MIN_SIZE != 0 { |
| 3330 |
|
- client.base_width = read_u32(5) as i32; |
| 3331 |
|
- client.base_height = read_u32(6) as i32; |
|
3326 |
+ client.base_width = read_u32(MIN_WIDTH) as i32; |
|
3327 |
+ client.base_height = read_u32(MIN_HEIGHT) as i32; |
| 3332 |
3328 |
} else { |
| 3333 |
3329 |
client.base_width = 0; |
| 3334 |
3330 |
client.base_height = 0; |
| 3335 |
3331 |
} |
| 3336 |
3332 |
|
| 3337 |
3333 |
if flags & P_RESIZE_INC != 0 { |
| 3338 |
|
- client.increment_width = read_u32(9) as i32; |
| 3339 |
|
- client.increment_height = read_u32(10) as i32; |
|
3334 |
+ client.increment_width = read_u32(WIDTH_INC) as i32; |
|
3335 |
+ client.increment_height = read_u32(HEIGHT_INC) as i32; |
| 3340 |
3336 |
} else { |
| 3341 |
3337 |
client.increment_width = 0; |
| 3342 |
3338 |
client.increment_height = 0; |
| 3343 |
3339 |
} |
| 3344 |
3340 |
|
| 3345 |
3341 |
if flags & P_MAX_SIZE != 0 { |
| 3346 |
|
- client.max_width = read_u32(7) as i32; |
| 3347 |
|
- client.max_height = read_u32(8) as i32; |
|
3342 |
+ client.max_width = read_u32(MAX_WIDTH) as i32; |
|
3343 |
+ client.max_height = read_u32(MAX_HEIGHT) as i32; |
| 3348 |
3344 |
} else { |
| 3349 |
3345 |
client.max_width = 0; |
| 3350 |
3346 |
client.max_height = 0; |
| 3351 |
3347 |
} |
| 3352 |
3348 |
|
| 3353 |
3349 |
if flags & P_MIN_SIZE != 0 { |
| 3354 |
|
- client.min_width = read_u32(5) as i32; |
| 3355 |
|
- client.min_height = read_u32(6) as i32; |
|
3350 |
+ client.min_width = read_u32(MIN_WIDTH) as i32; |
|
3351 |
+ client.min_height = read_u32(MIN_HEIGHT) as i32; |
| 3356 |
3352 |
} else if flags & P_BASE_SIZE != 0 { |
| 3357 |
|
- client.min_width = read_u32(15) as i32; |
| 3358 |
|
- client.min_height = read_u32(16) as i32; |
|
3353 |
+ client.min_width = read_u32(BASE_WIDTH) as i32; |
|
3354 |
+ client.min_height = read_u32(BASE_HEIGHT) as i32; |
| 3359 |
3355 |
} else { |
| 3360 |
3356 |
client.min_width = 0; |
| 3361 |
3357 |
client.min_height = 0; |
| 3362 |
3358 |
} |
| 3363 |
3359 |
|
| 3364 |
3360 |
if flags & P_ASPECT != 0 { |
| 3365 |
|
- client.min_aspect = (read_u32(12) as f32) / (read_u32(11) as f32).max(1.0); |
| 3366 |
|
- client.max_aspect = (read_u32(13) as f32) / (read_u32(14) as f32).max(1.0); |
|
3361 |
+ client.min_aspect = (read_u32(MIN_ASPECT_Y) as f32) / (read_u32(MIN_ASPECT_X) as f32).max(1.0); |
|
3362 |
+ client.max_aspect = (read_u32(MAX_ASPECT_X) as f32) / (read_u32(MAX_ASPECT_Y) as f32).max(1.0); |
| 3367 |
3363 |
} else { |
| 3368 |
3364 |
client.min_aspect = 0.0; |
| 3369 |
3365 |
client.max_aspect = 0.0; |