Skip to content

Implement inserting new monitors#3

Closed
wb9688 wants to merge 5 commits intolxde:masterfrom
wb9688:insert-new-monitor
Closed

Implement inserting new monitors#3
wb9688 wants to merge 5 commits intolxde:masterfrom
wb9688:insert-new-monitor

Conversation

@wb9688
Copy link
Copy Markdown

@wb9688 wb9688 commented Feb 2, 2021

This fixes that when you enable another monitor while PCManFM's desktop manager is running, it will properly load the desktop for that monitor you just enabled.

These patches made by @mtasaka come from https://src.fedoraproject.org/rpms/pcmanfm/tree/master

mtasaka and others added 5 commits February 2, 2021 16:39
This is preparation for implementing action when monitor is added.
Because we want to remove / add FmDesktop pointers, using list instead of static array is easier to manage.
idle_config_save must be reset on fm_desktop_manager_finalize
Implement the action when the number of monitors may have changed as the funtion on_n_monitor_may_changed, which does:
- check the number of the current monitors
- check the number of monitors registered pcmanfm internal lists_desktop_per_screen[] variable
- if the number of monitors actually increased, do
  - initialize and register new FmDesktop element
  - also show desktop icons

Also g_signal_connent() screen pointer with on_n_monitor_may_changed function.

To implement this, add a supplement function gdk_display_get_screen_num to get screen number from
dpy and screen pointer.
In connect_model(), when fm_folder_model_new(folder, FALSE) is invoked, in libfm/src/gtk/fm-folder-model.c ,
*  a new FmFolderModel object *model is created,
*  and fm_folder_model_set_folder(model, folder) is called internally.
*  When folder is already loaded, fm_folder_model_set_folder() calls _fm_folder_model_add_file() internally for each file in "Desktop" directory, which calls fm_folder_model_file_created().
*  fm_folder_model_file_created() calls _fm_folder_model_insert_item(), and
*  _fm_folder_model_insert_item() calls gtk_tree_model_row_inserted() (for each file in "Desktop" directory), which emits "row-inserted" signal to the created model.

What is the problem here is that this signal is needed for calling on_row_inserted() callback function (in pcmanfm/src/desktop.c),
*  which calls fm_folder_model_set_item_userdata().
*  This fm_folder_model_set_item_userdata() call is needed for load_items(), as it tries to call the line:
```
   item = fm_folder_model_get_item_userdata(desktop->model, &it);
```
   and then it tries to access item->fi.

So with current connect_model() implementation, when folder is already called, on_row_inserted callback function (for "row-inserted" signal) is never called. This causes fm_folder_model_get_item_userdata() return value (in load_itemr) NULL, and it makes segfault when accessing item->fi like https://bugzilla.redhat.com/show_bug.cgi?id=1827445 or so.

So before setting folder for model by fm_folder_model_set_folder(), connecting model to signal from folder is needed beforehand.
@LStranger
Copy link
Copy Markdown
Member

This seemed as an issue but I have to think it over again, something still seems odd. Let make it into 1.4.0 instead.

@LStranger
Copy link
Copy Markdown
Member

It seems all that numbering stuff became a complete mess when we come to plugged/unplugged monitors.
Let use plain list of available configs and use not number of it for monitor identification but gdk_screen_get_monitor_plug_name() and gdk_monitor_get_model() and use saved layout for exact monitor type.

@LStranger
Copy link
Copy Markdown
Member

I've created a solution which should fix the problem without the mess with lists of lists. Will test it next week then will create a pull request for your review. Draft is here - code became cleaner a bit, some code dropped and not so much of code added.

@wb9688
Copy link
Copy Markdown
Author

wb9688 commented Mar 5, 2021

I'm closing this in favor of the new solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants