Skip to content

Commit

Permalink
Fix applets sometimes not updating
Browse files Browse the repository at this point in the history
when maximizing an unmaximized active window
  • Loading branch information
gabrielfin authored and flexiondotorg committed Jun 1, 2019
1 parent 0cc3a55 commit d6742f9
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
14 changes: 13 additions & 1 deletion window-buttons-applet/window-buttons-applet.vala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace WindowButtonsApplet{
}

private Wnck.Window* window = null;
private Wnck.Window *active_window = null;

public GLib.Settings gsettings = new GLib.Settings("org.mate.window-applets.window-buttons");
public GLib.Settings marco_gsettings = new GLib.Settings("org.mate.Marco.general");
Expand Down Expand Up @@ -81,13 +82,19 @@ namespace WindowButtonsApplet{

public void reload(){

// Disconnect signals from old window
if(window != null){
window->actions_changed.disconnect(reload);
window->state_changed.disconnect(reload);
}

if(active_window != null)
active_window->state_changed.disconnect(reload);


window = get_current_window();

// Watch for changes to new controlled window
if(window != null){
window->actions_changed.connect(reload);
window->state_changed.connect(reload);
Expand All @@ -100,6 +107,11 @@ namespace WindowButtonsApplet{
MAXIMIZE.set_visible(false);
}

// When active window is not the controlled window (because it is unmaximized),
// we need to watch its state as well
active_window = Wnck.Screen.get_default().get_active_window();
if(active_window != null && active_window != window)
active_window->state_changed.connect(reload);
}

public void change_layout(){
Expand Down Expand Up @@ -205,7 +217,7 @@ namespace WindowButtonsApplet{
break;
case "active-maximized":
win = Wnck.Screen.get_default().get_active_window();
if(!win->is_maximized())
if(win != null && !win->is_maximized())
win = null;
break;
case "topmost-maximized":
Expand Down
19 changes: 15 additions & 4 deletions window-menu-applet/window-menu-applet.vala
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,42 @@ namespace WindowMenuApplet{

WindowWidgets.WindowMenuButton button;
Wnck.Window *window;
Wnck.Window *active_window;

GLib.Settings gsettings;

public void reload(){
string behaviour = gsettings.get_string("behaviour");

// Disconnect signals from old window
if(window != null){
window->icon_changed.disconnect(button.icon_set);
window->actions_changed.disconnect(button.menu_set);
window->state_changed.disconnect(reload);
}

if(active_window != null)
active_window->state_changed.disconnect(reload);


window = get_current_window();

button.window = window;

button.icon_set();
button.menu_set();

// Watch for changes to new controlled window
if(window != null){
window->icon_changed.connect(button.icon_set);
window->actions_changed.connect(button.menu_set);
if(behaviour == "topmost-maximized")
window->state_changed.connect(reload);
window->state_changed.connect(reload);
}

// When active window is not the controlled window (because it is unmaximized),
// we need to watch its state as well
active_window = Wnck.Screen.get_default().get_active_window();
if(active_window != null && active_window != window)
active_window->state_changed.connect(reload);
}

public void change_orient(MatePanel.Applet applet){
Expand Down Expand Up @@ -66,7 +77,7 @@ namespace WindowMenuApplet{
break;
case "active-maximized":
win = Wnck.Screen.get_default().get_active_window();
if(!win->is_maximized())
if(win != null && !win->is_maximized())
win = null;
break;
case "topmost-maximized":
Expand Down
22 changes: 17 additions & 5 deletions window-title-applet/window-title-applet.vala
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,38 @@ namespace WindowTitleApplet{

Gtk.Label title;
Wnck.Window *window;
Wnck.Window *active_window;

GLib.Settings gsettings;

public void reload(){
string behaviour = gsettings.get_string("behaviour");


// Disconnect signals from old window
if(window != null){
window->name_changed.disconnect(update);
window->state_changed.disconnect(reload);
}

if(active_window != null)
active_window->state_changed.disconnect(reload);


window = get_current_window();

update();


// Watch for changes to new controlled window
if(window != null){
window->name_changed.connect(update);
if(behaviour == "topmost-maximized")
window->state_changed.connect(reload);
window->state_changed.connect(reload);
}

// When active window is not the controlled window (because it is unmaximized),
// we need to watch its state as well
active_window = Wnck.Screen.get_default().get_active_window();
if(active_window != null && active_window != window)
active_window->state_changed.connect(reload);
}

public void update(){
Expand All @@ -48,7 +60,7 @@ namespace WindowTitleApplet{
break;
case "active-maximized":
win = Wnck.Screen.get_default().get_active_window();
if(!win->is_maximized())
if(win != null && !win->is_maximized())
win = null;
break;
case "topmost-maximized":
Expand Down

0 comments on commit d6742f9

Please sign in to comment.