mate-desktop / mate-applets

Applets for use with the MATE panel
http://www.mate-desktop.org
GNU General Public License v2.0
79 stars 67 forks source link

Stickynotes autodetect if they are on front. #627

Closed fabianfiorotto closed 1 year ago

fabianfiorotto commented 2 years ago

This is a bug that has annoyed me for years (Since Gnome2). I've tried to find something about it but I couldn't.

Expected behaviour

When the icon in the status bar is clicked and the sticky notes aren't in the front they should pup up to the front.

Actual behaviour

It seems like the sticky notes have an internal state that tells them if they are in front or in the back instead of checking the state in the window system. So when I click on the icon nothing happens and if I click once again a new blank stick note is created.

Steps to reproduce the behavior

  1. Create a sticky note
  2. Open a new window of any other program (eg a browser)
  3. Click on the sticky note icon
  4. Click once again.

MATE general version

MATE 1.26.0

Linux Distribution

Linux Mint 20.3 Una de 64 bits

I don't spect that this bug is fixed soon I just want to open a place to discuss it and find a possible solution to work on it.

zhuyaliang commented 2 years ago

There are only two states for a sticky note: pop-up or fold,Switch the status by clicking the buttonbianqian,Double click to create a blank note

fabianfiorotto commented 2 years ago

@zhuyaliang where is that state stored?

zhuyaliang commented 2 years ago

This is the workflow of the code

  if (event->type == GDK_2BUTTON_PRESS) {
        popup_add_note (applet, NULL);
        return TRUE;
    }
    else if (event->button == 1) {
        stickynote_toggle_notes_visible ();
        return TRUE;
    }

stickynote_toggle_notes_visible (void)
{
    stickynote_show_notes (!stickynotes->visible);
}
stickynote_show_notes (gboolean visible)
{   
    stickynote_set_visible (note, visible);
}
stickynote_set_visible (StickyNote *note,
                        gboolean    visible)
{
    if (visible) {
        gtk_window_present (GTK_WINDOW (note->w_window));
    } else {
        gtk_window_iconify (GTK_WINDOW (note->w_window));
    }
}

When the new application overwrites the Stickynotes, the Stickynotes will be minimized when you click the Stickynotes. Click Stickynotes again, and the Stickynotes will appear on all applicatio

fabianfiorotto commented 2 years ago

According to what I see in the code the function stickynote_show_notes is called only in 4 places.

  1. When you click on the icon (toggle).
  2. When you click on the "hide notes" option in the contextual menu (hide).
  3. When you press a key and the icon is focused (show)
  4. When you click on the desktop (hide).

I don't know much about how this is coded but it doesn't look like there is an event listener or something like that that is fired when a new window is opened.

fabianfiorotto commented 2 years ago

An easy solution for this is adding an option in the config to make the icon always show the notes instead of toggling them. I never use the icon to hide the notes I don't know if someone does.

zhuyaliang commented 2 years ago

Adding a custom gsettings is a good idea. Everyone's operating habits are different.I will complete this function when I have plenty of time