On Sat, Oct 09, 2010 at 01:40:29PM +0100, Thomas Adam wrote: > On Sat, Oct 09, 2010 at 02:28:11PM +0200, Dominik Vogt wrote: > > The attached patch mostly fixes the problem. However, there is one > > thing left to think about: > > Ah -- you're too fast for me. :) I've a similar patch to yours sat here.
I've attached the complete patch for review. Uh, it has been almost 20 month since I made any patch. 8-O > > 2. Override the window's gravity with the window shade direction, > > i.e. NW becomes NE on a window shaded to the right and SW on a > > window shaded to the bottom etc. > > ==> The window may have moved to a funny place after unshading, > > for example partially off screen. > > But doesn't this happen at the moment, anyway? It dows. Well, "funny" may depend on what you expect. > > I think I prefer solution 2 because although the window might end > > up in a different position than it would have if it had been > > resized without being shaded, this may be the least surprising > > solution for the user as unshading is a process with a result that > > is easy to understand. > > > > However, I'd like to hear some more opinions. > > I'll go with 2. See attached patch. Ciao Dominik ^_^ ^_^ -- Dominik Vogt
Index: ChangeLog =================================================================== RCS file: /home/cvs/fvwm/fvwm/ChangeLog,v retrieving revision 1.3132 diff -u -u -r1.3132 ChangeLog --- ChangeLog 16 Sep 2010 14:19:51 -0000 1.3132 +++ ChangeLog 9 Oct 2010 14:32:07 -0000 @@ -1,3 +1,17 @@ +2010-10-09 Dominik Vogt <dominik(dot)vogt(at)gmx(dot)de> + + * fvwm/events.c (__handle_cr_on_client): + fix resize of shaded windows with a shade direction that does not match + the window gravity + + * libs/gravity.h: + * libs/gravity.c (__gravity_override_one_axis): + (gravity_override_dir): + new helper functions + + * libs/gravity.c (gravity_combine_xy_dir): + fixed calculation with only one axis set + 2010-09-16 Sergey Vlasov <[email protected]> * fvwm/move_resize.c (GetOnePositionArgument): Fix parsing of commands like 'Move 50-50w 50-50w'. Index: NEWS =================================================================== RCS file: /home/cvs/fvwm/fvwm/NEWS,v retrieving revision 1.817 diff -u -u -r1.817 NEWS --- NEWS 16 Aug 2010 14:43:07 -0000 1.817 +++ NEWS 9 Oct 2010 14:32:09 -0000 @@ -9,8 +9,12 @@ * Bug fixes: - - Fix width of FvwmTaskBar to fit on screen properly by using the correct - module information to determine the border size. + - Fix width of FvwmTaskBar to fit on screen properly by using + the correct module information to determine the border size. + - Fix resizing shaded windows with a shade direction that does + not match the window's gravity. Shaded windows might have + jumped to strange positions when being resized by the + application. ------------------------------------------------------------------- @@ -26,7 +30,8 @@ conditional commands if they're already delimited by commas. - Correctly report a window's height and width if the window has incomplete resize increment set. - - Maintain any State hints on a window when used with WindowStyle. + - Maintain any State hints on a window when used with + WindowStyle. - FvwmIconMan now correctly handles sticky windows. ------------------------------------------------------------------- @@ -75,7 +80,7 @@ any currently mapped windows. - Fix flickering/incorrect location of the GeometryWindow with Xinerama/TwinView when resizing windows. - + ------------------------------------------------------------------- Changes in beta release 2.5.28 (20-Sep-2009) Index: fvwm/events.c =================================================================== RCS file: /home/cvs/fvwm/fvwm/fvwm/events.c,v retrieving revision 1.567 diff -u -u -r1.567 events.c --- fvwm/events.c 4 Jan 2010 12:00:38 -0000 1.567 +++ fvwm/events.c 9 Oct 2010 14:32:14 -0000 @@ -926,6 +926,7 @@ int *ret_do_send_event, XConfigureRequestEvent cre, const evh_args_t *ea, FvwmWindow *fw, Bool force, int force_gravity) { + rectangle current_g; rectangle new_g; rectangle d_g; size_rect constr_dim; @@ -1048,6 +1049,21 @@ { gravity = fw->hints.win_gravity; } + if (IS_SHADED(fw)) + { + direction_t gravity_dir; + + get_unshaded_geometry(fw, ¤t_g); + /* the shade direction overrides the windo's gravity */ + gravity_dir = gravity_grav_to_dir(gravity); + gravity_dir = gravity_override_dir( + gravity_dir, SHADED_DIR(fw)); + gravity = gravity_dir_to_grav(gravity_dir); + } + else + { + current_g = fw->g.frame; + } if (!(cre.value_mask & (CWX | CWY))) { /* nothing */ @@ -1066,13 +1082,13 @@ { ref_x = cre.x - ((grav_x + 1) * b.total_size.width) / 2; - d_g.x = ref_x - fw->g.frame.x; + d_g.x = ref_x - current_g.x; } if (cre.value_mask & CWY) { ref_y = cre.y - ((grav_y + 1) * b.total_size.height) / 2; - d_g.y = ref_y - fw->g.frame.y; + d_g.y = ref_y - current_g.y; } } else /* ..._USE_GRAV or ..._AUTO */ @@ -1080,20 +1096,21 @@ /* default: traditional cr handling */ if (cre.value_mask & CWX) { - d_g.x = cre.x - fw->g.frame.x - b.top_left.width; + d_g.x = cre.x - current_g.x - b.top_left.width; } if (cre.value_mask & CWY) { - d_g.y = cre.y - fw->g.frame.y - b.top_left.height; + d_g.y = cre.y - current_g.y - b.top_left.height; } } + if (cre.value_mask & CWHeight) { if (cre.height < (WINDOW_FREAKED_OUT_SIZE - b.total_size.height)) { d_g.height = cre.height - - (fw->g.frame.height - b.total_size.height); + (current_g.height - b.total_size.height); } else { @@ -1112,7 +1129,7 @@ if (cre.width < (WINDOW_FREAKED_OUT_SIZE - b.total_size.width)) { d_g.width = cre.width - - (fw->g.frame.width - b.total_size.width); + (current_g.width - b.total_size.width); } else { @@ -1127,12 +1144,7 @@ * the same as the requested client window width; the inner height is * the same as the requested client window height plus any title bar * slop. */ - new_g = fw->g.frame; - if (IS_SHADED(fw)) - { - new_g.width = fw->g.normal.width; - new_g.height = fw->g.normal.height; - } + new_g = current_g; oldnew_dim.width = new_g.width + d_g.width; oldnew_dim.height = new_g.height + d_g.height; constr_dim.width = oldnew_dim.width; @@ -1144,12 +1156,12 @@ d_g.height += (constr_dim.height - oldnew_dim.height); if ((cre.value_mask & CWX) && d_g.width) { - new_g.x = fw->g.frame.x + d_g.x; - new_g.width = fw->g.frame.width + d_g.width; + new_g.x = current_g.x + d_g.x; + new_g.width = current_g.width + d_g.width; } else if ((cre.value_mask & CWX) && !d_g.width) { - new_g.x = fw->g.frame.x + d_g.x; + new_g.x = current_g.x + d_g.x; } else if (!(cre.value_mask & CWX) && d_g.width) { @@ -1157,21 +1169,21 @@ } if ((cre.value_mask & CWY) && d_g.height) { - new_g.y = fw->g.frame.y + d_g.y; - new_g.height = fw->g.frame.height + d_g.height; + new_g.y = current_g.y + d_g.y; + new_g.height = current_g.height + d_g.height; } else if ((cre.value_mask & CWY) && !d_g.height) { - new_g.y = fw->g.frame.y + d_g.y; + new_g.y = current_g.y + d_g.y; } else if (!(cre.value_mask & CWY) && d_g.height) { gravity_resize(gravity, &new_g, 0, d_g.height); } - if (new_g.x == fw->g.frame.x && new_g.y == fw->g.frame.y && - new_g.width == fw->g.frame.width && - new_g.height == fw->g.frame.height) + if (new_g.x == current_g.x && new_g.y == current_g.y && + new_g.width == current_g.width && + new_g.height == current_g.height) { /* Window will not be moved or resized; send a synthetic * ConfigureNotify. */ @@ -1182,6 +1194,7 @@ { if (IS_SHADED(fw)) { + fw->g.normal = new_g; get_shaded_geometry(fw, &new_g, &new_g); } frame_setup_window_app_request( Index: libs/gravity.c =================================================================== RCS file: /home/cvs/fvwm/fvwm/libs/gravity.c,v retrieving revision 1.19 diff -u -u -r1.19 gravity.c --- libs/gravity.c 27 Jan 2007 11:33:16 -0000 1.19 +++ libs/gravity.c 9 Oct 2010 14:32:14 -0000 @@ -305,10 +305,12 @@ { switch (dir_x) { + case DIR_W: case DIR_NW: case DIR_SW: dir_x = DIR_W; break; + case DIR_E: case DIR_NE: case DIR_SE: dir_x = DIR_E; @@ -319,10 +321,12 @@ } switch (dir_y) { + case DIR_N: case DIR_NW: case DIR_NE: dir_y = DIR_N; break; + case DIR_S: case DIR_SW: case DIR_SE: dir_y = DIR_S; @@ -390,6 +394,42 @@ } } +static inline int __gravity_override_one_axis(int dir_orig, int dir_mod) +{ + int ret_dir; + + if (dir_mod == DIR_NONE) + { + ret_dir = dir_orig; + } + else + { + ret_dir = dir_mod; + } + + return ret_dir; +} + +int gravity_override_dir( + int dir_orig, int dir_mod) +{ + int ret_dir; + int ret_x; + int ret_y; + int orig_x; + int orig_y; + int mod_x; + int mod_y; + + gravity_split_xy_dir(&orig_x, &orig_y, dir_orig); + gravity_split_xy_dir(&mod_x, &mod_y, dir_mod); + ret_x = __gravity_override_one_axis(orig_x, mod_x); + ret_y = __gravity_override_one_axis(orig_y, mod_y); + ret_dir = gravity_combine_xy_dir(ret_x, ret_y); + + return ret_dir; +} + int gravity_dir_to_sign_one_axis( direction_t dir) { Index: libs/gravity.h =================================================================== RCS file: /home/cvs/fvwm/fvwm/libs/gravity.h,v retrieving revision 1.15 diff -u -u -r1.15 gravity.h --- libs/gravity.h 13 Jan 2007 13:16:34 -0000 1.15 +++ libs/gravity.h 9 Oct 2010 14:32:14 -0000 @@ -76,6 +76,8 @@ int dir_x, int dir_y); void gravity_split_xy_dir( int *ret_dir_x, int *ret_dir_y, int in_dir); +int gravity_override_dir( + int dir_orig, int dir_mod); int gravity_dir_to_sign_one_axis( direction_t dir); direction_t gravity_parse_dir_argument(
