Skip to content

Commit

Permalink
UPDATE_FVWM_SCREEN: respect StartsOnDesk style
Browse files Browse the repository at this point in the history
Previously, when StartsOnDesk was used, although the desk was correctly
set, the desk would never change thereafter, once the window was moved.

This was because the UPDATE_FVWM_SCREEN macro assumed it could always
update the window, but never took into account that when moving
monitors, the desk also needed to be changed.

But this can't blindly happen in all cases, as on initla mapping of the
window, the UPDATE_FVWM_SCREEN macro would have overriden the
StartsOnDesk style.

This change introduces a flag to track this as well as reducing the
number of assigments which weren't needed when updating the screen.
Also removed an extraneous assignment.

Helps #86
  • Loading branch information
ThomasAdam committed May 23, 2020
1 parent d9e5b8f commit ab5e55a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
1 change: 1 addition & 0 deletions fvwm/fvwm.h
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ typedef struct style_flags
unsigned has_initial_map_command_string : 1;
unsigned has_title_format_string : 1;
unsigned has_icon_title_format_string : 1;
unsigned initial_placement_done : 1;
} style_flags;

typedef struct style_id_t
Expand Down
5 changes: 2 additions & 3 deletions fvwm/placement.c
Original file line number Diff line number Diff line change
Expand Up @@ -1556,8 +1556,6 @@ static int __place_get_nowm_pos(
attr_g->y = final_g.y;
}

UPDATE_FVWM_SCREEN(fw);

return 0;
}

Expand Down Expand Up @@ -1904,7 +1902,8 @@ static int __place_window(
((!Restarting && Scr.flags.are_windows_captured))) {
struct monitor *mnew = FindScreenOfXY(attr_g->x, attr_g->y);
fw->m = mnew;
fw->Desk = mnew->virtual_scr.CurrentDesk;
do_move_window_to_desk(fw, mnew->virtual_scr.CurrentDesk);
pstyle->flags.initial_placement_done = 1;
}

reason->pos.x = attr_g->x;
Expand Down
33 changes: 25 additions & 8 deletions fvwm/screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
#ifndef _SCREEN_
#define _SCREEN_

#include "config.h"

#include "fvwm/update.h"
#include "fvwm/style.h"

#include "libs/flist.h"
#include "libs/Bindings.h"

Expand Down Expand Up @@ -469,14 +474,26 @@ typedef struct ScreenInfo
} last_added_item;
} ScreenInfo;

#define UPDATE_FVWM_SCREEN(fw) \
do { \
rectangle g; \
struct monitor *mnew; \
get_unshaded_geometry((fw), &g); \
mnew = FindScreenOfXY((fw)->g.frame.x, (fw)->g.frame.y); \
(fw)->m_prev = (fw)->m; \
(fw)->m = mnew; \
#define UPDATE_FVWM_SCREEN(fw) \
do { \
rectangle g; \
struct monitor *mnew; \
window_style style; \
\
lookup_style((fw), &style); \
get_unshaded_geometry((fw), &g); \
mnew = FindScreenOfXY((fw)->g.frame.x, (fw)->g.frame.y); \
/* Avoid unnecessary updates. */ \
if (mnew == (fw)->m) \
break; \
/* Don't override StartsOnDesk style which sets this. */ \
if (!SUSE_START_ON_DESK(&style.flags) && \
!style.flags.initial_placement_done) \
break; \
(fw)->m_prev = (fw)->m; \
(fw)->m = mnew; \
(fw)->Desk = mnew->virtual_scr.CurrentDesk; \
BroadcastConfig(M_CONFIGURE_WINDOW, (fw)); \
} while(0)

/* A macro to to simplify he "ewmh desktop code" */
Expand Down

0 comments on commit ab5e55a

Please sign in to comment.