diff options
Diffstat (limited to 'applets/wncklet')
-rw-r--r-- | applets/wncklet/Makefile.am | 2 | ||||
-rw-r--r-- | applets/wncklet/showdesktop.c | 8 | ||||
-rw-r--r-- | applets/wncklet/wayland-backend.c | 5 | ||||
-rw-r--r-- | applets/wncklet/window-list.c | 139 | ||||
-rw-r--r-- | applets/wncklet/window-list.ui | 20 | ||||
-rw-r--r-- | applets/wncklet/window-menu.c | 8 | ||||
-rw-r--r-- | applets/wncklet/workspace-switcher.c | 26 |
7 files changed, 126 insertions, 82 deletions
diff --git a/applets/wncklet/Makefile.am b/applets/wncklet/Makefile.am index 38dfaca5..ed442671 100644 --- a/applets/wncklet/Makefile.am +++ b/applets/wncklet/Makefile.am @@ -1,3 +1,5 @@ +AUTOMAKE_OPTIONS = subdir-objects + AM_CPPFLAGS = \ $(LIBMATE_PANEL_APPLET_CFLAGS) \ $(WNCKLET_CFLAGS) \ diff --git a/applets/wncklet/showdesktop.c b/applets/wncklet/showdesktop.c index c3454a0f..aabc1a63 100644 --- a/applets/wncklet/showdesktop.c +++ b/applets/wncklet/showdesktop.c @@ -22,7 +22,7 @@ */ #ifdef HAVE_CONFIG_H - #include <config.h> +#include <config.h> #endif #include <glib/gi18n.h> @@ -458,8 +458,6 @@ gboolean show_desktop_applet_fill(MatePanelApplet* applet) initial oriantation, and we get that during the _add call */ g_signal_connect(G_OBJECT (sdd->applet), "change_orient", G_CALLBACK (applet_change_orient), sdd); - mate_panel_applet_set_background_widget(MATE_PANEL_APPLET (sdd->applet), GTK_WIDGET(sdd->applet)); - action_group = gtk_action_group_new("ShowDesktop Applet Actions"); gtk_action_group_set_translation_domain(action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions(action_group, show_desktop_menu_actions, G_N_ELEMENTS (show_desktop_menu_actions), sdd); @@ -506,13 +504,13 @@ static void display_about_dialog(GtkAction* action, ShowDesktopData* sdd) "comments", _("This button lets you hide all windows and show the desktop."), "copyright", _("Copyright \xc2\xa9 2002 Red Hat, Inc.\n" "Copyright \xc2\xa9 2011 Perberos\n" - "Copyright \xc2\xa9 2012-2020 MATE developers"), + "Copyright \xc2\xa9 2012-2021 MATE developers"), "documenters", documenters, "icon-name", SHOW_DESKTOP_ICON, "logo-icon-name", SHOW_DESKTOP_ICON, "translator-credits", _("translator-credits"), "version", VERSION, - "website", "http://www.mate-desktop.org/", + "website", PACKAGE_URL, NULL); } diff --git a/applets/wncklet/wayland-backend.c b/applets/wncklet/wayland-backend.c index 658eb6d3..a6f50a77 100644 --- a/applets/wncklet/wayland-backend.c +++ b/applets/wncklet/wayland-backend.c @@ -55,7 +55,6 @@ static struct wl_registry *wl_registry_global = NULL; static uint32_t foreign_toplevel_manager_global_id = 0; static uint32_t foreign_toplevel_manager_global_version = 0; -static TasklistManager *tasklist_manager_new (); static ToplevelTask *toplevel_task_new (TasklistManager *tasklist, struct zwlr_foreign_toplevel_handle_v1 *handle); static void @@ -92,7 +91,7 @@ static const struct wl_registry_listener wl_registry_listener = { }; static void -wayland_tasklist_init_if_needed () +wayland_tasklist_init_if_needed (void) { if (has_initialized) return; @@ -165,7 +164,7 @@ tasklist_manager_disconnected_from_widget (TasklistManager *tasklist) } static TasklistManager * -tasklist_manager_new () +tasklist_manager_new (void) { if (!foreign_toplevel_manager_global_id) return NULL; diff --git a/applets/wncklet/window-list.c b/applets/wncklet/window-list.c index dd18fc72..ce3ddbb4 100644 --- a/applets/wncklet/window-list.c +++ b/applets/wncklet/window-list.c @@ -73,6 +73,7 @@ typedef struct { /* Properties: */ GtkWidget* properties_dialog; + GtkWidget* wayland_info_label; GtkWidget* show_current_radio; GtkWidget* show_all_radio; #ifdef HAVE_WINDOW_PREVIEWS @@ -119,10 +120,17 @@ static void tasklist_update(TasklistData* tasklist) WnckTasklistGroupingType grouping; switch (tasklist->grouping) { - case TASKLIST_NEVER_GROUP: grouping = WNCK_TASKLIST_NEVER_GROUP; - case TASKLIST_AUTO_GROUP: grouping = WNCK_TASKLIST_AUTO_GROUP; - case TASKLIST_ALWAYS_GROUP: grouping = WNCK_TASKLIST_ALWAYS_GROUP; - default: grouping = WNCK_TASKLIST_NEVER_GROUP; + case TASKLIST_NEVER_GROUP: + grouping = WNCK_TASKLIST_NEVER_GROUP; + break; + case TASKLIST_AUTO_GROUP: + grouping = WNCK_TASKLIST_AUTO_GROUP; + break; + case TASKLIST_ALWAYS_GROUP: + grouping = WNCK_TASKLIST_ALWAYS_GROUP; + break; + default: + grouping = WNCK_TASKLIST_NEVER_GROUP; } wnck_tasklist_set_grouping(WNCK_TASKLIST(tasklist->tasklist), grouping); wnck_tasklist_set_include_all_workspaces(WNCK_TASKLIST(tasklist->tasklist), tasklist->include_all_workspaces); @@ -236,71 +244,87 @@ static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBac #ifdef HAVE_X11 #ifdef HAVE_WINDOW_PREVIEWS -static GdkPixbuf *preview_window_thumbnail (WnckWindow *wnck_window, TasklistData *tasklist) +static cairo_surface_t* +preview_window_thumbnail (WnckWindow *wnck_window, + TasklistData *tasklist, + int *thumbnail_width, + int *thumbnail_height, + int *thumbnail_scale) { GdkWindow *window; - GdkPixbuf *screenshot; - GdkPixbuf *thumbnail; + GdkWindow *window_wrapper = NULL; + Window win; + cairo_surface_t *thumbnail; + cairo_t *cr; double ratio; - int width, height; - int scale; + int width, height, scale; - window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), wnck_window_get_xid (wnck_window)); + win = wnck_window_get_xid (wnck_window); - if (window == NULL) - return NULL; + if ((window = gdk_x11_window_lookup_for_display (gdk_display_get_default (), win)) == NULL) + { + if ((window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), win)) == NULL) + { + return NULL; + } + else + { + window_wrapper = window; + } + } + else + { + g_object_ref (window); + } - scale = gdk_window_get_scale_factor (window); + *thumbnail_scale = scale = gdk_window_get_scale_factor (window); width = gdk_window_get_width (window) * scale; height = gdk_window_get_height (window) * scale; - /* Generate window screenshot for preview */ - screenshot = gdk_pixbuf_get_from_window (window, 0, 0, width / scale, height / scale); - g_object_unref (window); - - if (screenshot == NULL) - return NULL; - - /* Determine whether the contents of the screenshot are empty */ - if (gdk_pixbuf_get_byte_length (screenshot) == 0) - { - g_object_unref (screenshot); - return NULL; - } - /* Scale to configured size while maintaining aspect ratio */ if (width > height) { - ratio = (double) height / (double) width; - width = MIN(width, tasklist->thumbnail_size); - height = width * ratio; + int max_size = MIN (width, tasklist->thumbnail_size * scale); + ratio = (double) max_size / (double) width; + *thumbnail_width = max_size; + *thumbnail_height = (int) ((double) height * ratio); } else { - ratio = (double) width / (double) height; - height = MIN(height, tasklist->thumbnail_size); - width = height * ratio; + int max_size = MIN (height, tasklist->thumbnail_size * scale); + ratio = (double) max_size / (double) height; + *thumbnail_height = max_size; + *thumbnail_width = (int) ((double) width * ratio); } - thumbnail = gdk_pixbuf_scale_simple (screenshot, width, height, GDK_INTERP_BILINEAR); - g_object_unref (screenshot); + thumbnail = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, + *thumbnail_width, + *thumbnail_height); + cairo_surface_set_device_scale (thumbnail, scale, scale); + cr = cairo_create (thumbnail); + cairo_scale (cr, ratio, ratio); + gdk_cairo_set_source_window (cr, window, 0, 0); + cairo_paint (cr); + cairo_destroy (cr); + + if (window_wrapper) + g_object_unref (window_wrapper); + g_object_unref (window); return thumbnail; } #define PREVIEW_PADDING 5 -static void preview_window_reposition (TasklistData *tasklist, GdkPixbuf *thumbnail) +static void +preview_window_reposition (TasklistData *tasklist, + cairo_surface_t *thumbnail, + int width, + int height, + int scale) { GdkMonitor *monitor; GdkRectangle monitor_geom; int x_pos, y_pos; - int width, height; - - width = gdk_pixbuf_get_width (thumbnail); - height = gdk_pixbuf_get_height (thumbnail); - - /* Resize window to fit thumbnail */ - gtk_window_resize (GTK_WINDOW (tasklist->preview), width, height); /* Set position at pointer, then re-adjust from there to just outside of the pointer */ gtk_window_set_position (GTK_WINDOW (tasklist->preview), GTK_WIN_POS_MOUSE); @@ -314,13 +338,13 @@ static void preview_window_reposition (TasklistData *tasklist, GdkPixbuf *thumbn switch (mate_panel_applet_get_orient (MATE_PANEL_APPLET (tasklist->applet))) { case MATE_PANEL_APPLET_ORIENT_LEFT: - x_pos = monitor_geom.width + monitor_geom.x - (width + tasklist->size) - PREVIEW_PADDING; + x_pos = monitor_geom.width + monitor_geom.x - (width/scale + tasklist->size) - PREVIEW_PADDING; break; case MATE_PANEL_APPLET_ORIENT_RIGHT: x_pos = tasklist->size + PREVIEW_PADDING; break; case MATE_PANEL_APPLET_ORIENT_UP: - y_pos = monitor_geom.height + monitor_geom.y - (height + tasklist->size) - PREVIEW_PADDING; + y_pos = monitor_geom.height + monitor_geom.y - (height/scale + tasklist->size) - PREVIEW_PADDING; break; case MATE_PANEL_APPLET_ORIENT_DOWN: default: @@ -331,21 +355,24 @@ static void preview_window_reposition (TasklistData *tasklist, GdkPixbuf *thumbn gtk_window_move (GTK_WINDOW (tasklist->preview), x_pos, y_pos); } -static gboolean preview_window_draw (GtkWidget *widget, cairo_t *cr, GdkPixbuf *thumbnail) +static gboolean preview_window_draw (GtkWidget *widget, cairo_t *cr, cairo_surface_t *thumbnail) { GtkStyleContext *context; context = gtk_widget_get_style_context (widget); - gtk_render_icon (context, cr, thumbnail, 0, 0); + gtk_render_icon_surface (context, cr, thumbnail, 0, 0); return FALSE; } static gboolean applet_enter_notify_event (WnckTasklist *tl, GList *wnck_windows, TasklistData *tasklist) { - GdkPixbuf *thumbnail; + cairo_surface_t *thumbnail; WnckWindow *wnck_window = NULL; int n_windows; + int thumbnail_width; + int thumbnail_height; + int thumbnail_scale; if (tasklist->preview != NULL) { @@ -373,7 +400,7 @@ static gboolean applet_enter_notify_event (WnckTasklist *tl, GList *wnck_windows wnck_screen_get_active_workspace (wnck_screen_get_default ()))) return FALSE; - thumbnail = preview_window_thumbnail (wnck_window, tasklist); + thumbnail = preview_window_thumbnail (wnck_window, tasklist, &thumbnail_width, &thumbnail_height, &thumbnail_scale); if (thumbnail == NULL) return FALSE; @@ -382,13 +409,14 @@ static gboolean applet_enter_notify_event (WnckTasklist *tl, GList *wnck_windows tasklist->preview = gtk_window_new (GTK_WINDOW_POPUP); gtk_widget_set_app_paintable (tasklist->preview, TRUE); + gtk_window_set_default_size (GTK_WINDOW (tasklist->preview), thumbnail_width/thumbnail_scale, thumbnail_height/thumbnail_scale); gtk_window_set_resizable (GTK_WINDOW (tasklist->preview), TRUE); - preview_window_reposition (tasklist, thumbnail); + preview_window_reposition (tasklist, thumbnail, thumbnail_width, thumbnail_height, thumbnail_scale); gtk_widget_show (tasklist->preview); - g_signal_connect_data (G_OBJECT (tasklist->preview), "draw", G_CALLBACK (preview_window_draw), thumbnail, (GClosureNotify) G_CALLBACK (g_object_unref), 0); + g_signal_connect_data (G_OBJECT (tasklist->preview), "draw", G_CALLBACK (preview_window_draw), thumbnail, (GClosureNotify) G_CALLBACK (cairo_surface_destroy), 0); return FALSE; } @@ -787,8 +815,6 @@ gboolean window_list_applet_fill(MatePanelApplet* applet) g_signal_connect(G_OBJECT(tasklist->applet), "change_size", G_CALLBACK(applet_change_pixel_size), tasklist); g_signal_connect(G_OBJECT(tasklist->applet), "change_background", G_CALLBACK(applet_change_background), tasklist); - mate_panel_applet_set_background_widget(MATE_PANEL_APPLET(tasklist->applet), GTK_WIDGET(tasklist->applet)); - action_group = gtk_action_group_new("Tasklist Applet Actions"); gtk_action_group_set_translation_domain(action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions(action_group, tasklist_menu_actions, G_N_ELEMENTS(tasklist_menu_actions), tasklist); @@ -889,13 +915,13 @@ static void display_about_dialog(GtkAction* action, TasklistData* tasklist) "comments", _("The Window List shows a list of all windows in a set of buttons and lets you browse them."), "copyright", _("Copyright \xc2\xa9 2002 Red Hat, Inc.\n" "Copyright \xc2\xa9 2011 Perberos\n" - "Copyright \xc2\xa9 2012-2020 MATE developers"), + "Copyright \xc2\xa9 2012-2021 MATE developers"), "documenters", documenters, "icon-name", WINDOW_LIST_ICON, "logo-icon-name", WINDOW_LIST_ICON, "translator-credits", _("translator-credits"), "version", VERSION, - "website", "http://www.mate-desktop.org/", + "website", PACKAGE_URL, NULL); } @@ -959,6 +985,8 @@ static void setup_sensitivity(TasklistData* tasklist, GtkBuilder* builder, const #ifdef HAVE_WAYLAND static void setup_dialog_wayland(TasklistData* tasklist) { + gtk_widget_show(tasklist->wayland_info_label); + gtk_widget_set_sensitive(tasklist->window_list_content_box, FALSE); gtk_widget_set_sensitive(tasklist->window_grouping_box, FALSE); gtk_widget_set_sensitive(tasklist->minimized_windows_box, FALSE); @@ -976,6 +1004,7 @@ static void setup_dialog(GtkBuilder* builder, TasklistData* tasklist) GtkAdjustment *adjustment; #endif /* HAVE_WINDOW_PREVIEWS */ + tasklist->wayland_info_label = WID("wayland_info_label"); tasklist->show_current_radio = WID("show_current_radio"); tasklist->show_all_radio = WID("show_all_radio"); diff --git a/applets/wncklet/window-list.ui b/applets/wncklet/window-list.ui index 2161d427..765b5b68 100644 --- a/applets/wncklet/window-list.ui +++ b/applets/wncklet/window-list.ui @@ -77,6 +77,22 @@ <property name="orientation">vertical</property> <property name="spacing">18</property> <child> + <object class="GtkLabel" id="wayland_info_label"> + <property name="visible">False</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Some options not available on Wayland</property> + <property name="xalign">0</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> <object class="GtkBox" id="window_list_content_box"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -154,7 +170,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">0</property> + <property name="position">1</property> </packing> </child> <child> @@ -270,7 +286,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> <child> diff --git a/applets/wncklet/window-menu.c b/applets/wncklet/window-menu.c index 48b1c31b..804898d8 100644 --- a/applets/wncklet/window-menu.c +++ b/applets/wncklet/window-menu.c @@ -26,7 +26,7 @@ */ #ifdef HAVE_CONFIG_H - #include <config.h> +#include <config.h> #endif #include <string.h> @@ -88,13 +88,13 @@ static void window_menu_about(GtkAction* action, WindowMenu* window_menu) "Copyright \xc2\xa9 2001 Free Software Foundation, Inc.\n" "Copyright \xc2\xa9 2003 Sun Microsystems, Inc.\n" "Copyright \xc2\xa9 2011 Perberos\n" - "Copyright \xc2\xa9 2012-2020 MATE developers"), + "Copyright \xc2\xa9 2012-2021 MATE developers"), "documenters", documenters, "icon-name", WINDOW_MENU_ICON, "logo-icon-name", WINDOW_MENU_ICON, "translator-credits", _("translator-credits"), "version", VERSION, - "website", "http://www.mate-desktop.org/", + "website", PACKAGE_URL, NULL); } @@ -253,8 +253,6 @@ gboolean window_menu_applet_fill(MatePanelApplet* applet) if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) { window_menu->selector = wnck_selector_new(); - mate_panel_applet_set_background_widget(MATE_PANEL_APPLET(window_menu->applet), GTK_WIDGET(window_menu->selector)); - } else #endif /* HAVE_X11 */ diff --git a/applets/wncklet/workspace-switcher.c b/applets/wncklet/workspace-switcher.c index 2335bb1d..22b473bd 100644 --- a/applets/wncklet/workspace-switcher.c +++ b/applets/wncklet/workspace-switcher.c @@ -200,14 +200,13 @@ static void update_properties_for_wm(PagerData* pager) static void window_manager_changed(WnckScreen* screen, PagerData* pager) { +#ifdef HAVE_X11 const char *wm_name = NULL; -#ifdef HAVE_X11 if (pager->screen) { wm_name = wnck_screen_get_window_manager_name (pager->screen); } -#endif /* HAVE_X11 */ if (!wm_name) pager->wm = PAGER_WM_UNKNOWN; @@ -221,6 +220,9 @@ static void window_manager_changed(WnckScreen* screen, PagerData* pager) pager->wm = PAGER_WM_COMPIZ; else pager->wm = PAGER_WM_UNKNOWN; +#else + pager->wm = PAGER_WM_UNKNOWN; +#endif /* HAVE_X11 */ update_properties_for_wm(pager); pager_update(pager); @@ -321,11 +323,13 @@ static void applet_style_updated (MatePanelApplet *applet, GtkStyleContext *cont */ static gboolean applet_scroll(MatePanelApplet* applet, GdkEventScroll* event, PagerData* pager) { +#ifdef HAVE_X11 GdkScrollDirection absolute_direction; int index; int n_workspaces; int n_columns; int in_last_row; +#endif /* HAVE_X11 */ if (event->type != GDK_SCROLL) return FALSE; @@ -340,7 +344,6 @@ static gboolean applet_scroll(MatePanelApplet* applet, GdkEventScroll* event, Pa n_workspaces = wnck_screen_get_workspace_count(pager->screen); } else -#endif /* HAVE_X11 */ { index = 0; n_workspaces = 1; @@ -431,7 +434,6 @@ static gboolean applet_scroll(MatePanelApplet* applet, GdkEventScroll* event, Pa break; } -#ifdef HAVE_X11 if (pager->screen) { wnck_workspace_activate(wnck_screen_get_workspace(pager->screen, index), event->time); @@ -646,8 +648,6 @@ gboolean workspace_switcher_applet_fill(MatePanelApplet* applet) gtk_widget_show(pager->pager); gtk_widget_show(pager->applet); - mate_panel_applet_set_background_widget(MATE_PANEL_APPLET(pager->applet), GTK_WIDGET(pager->applet)); - action_group = gtk_action_group_new("WorkspaceSwitcher Applet Actions"); gtk_action_group_set_translation_domain(action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions(action_group, pager_menu_actions, G_N_ELEMENTS(pager_menu_actions), pager); @@ -697,13 +697,13 @@ static void display_about_dialog(GtkAction* action, PagerData* pager) "comments", _("The Workspace Switcher shows you a small version of your workspaces that lets you manage your windows."), "copyright", _("Copyright \xc2\xa9 2002 Red Hat, Inc.\n" "Copyright \xc2\xa9 2011 Perberos\n" - "Copyright \xc2\xa9 2012-2020 MATE developers"), + "Copyright \xc2\xa9 2012-2021 MATE developers"), "documenters", documenters, "icon-name", WORKSPACE_SWITCHER_ICON, "logo-icon-name", WORKSPACE_SWITCHER_ICON, "translator-credits", _("translator-credits"), "version", VERSION, - "website", "http://www.mate-desktop.org/", + "website", PACKAGE_URL, NULL); } @@ -796,12 +796,14 @@ static void workspace_destroyed(WnckScreen* screen, WnckWorkspace* space, PagerD } #endif /* HAVE_X11 */ -static void num_workspaces_value_changed(GtkSpinButton* button, PagerData* pager) +static void +on_num_workspaces_value_changed (GtkSpinButton *button, + PagerData *pager) { #ifdef HAVE_X11 if (pager->screen) { - int workspace_count = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(pager->num_workspaces_spin)); + int workspace_count = gtk_spin_button_get_value_as_int (button); wnck_screen_change_workspace_count(pager->screen, workspace_count); } #endif /* HAVE_X11 */ @@ -1015,7 +1017,7 @@ static void setup_dialog(GtkBuilder* builder, PagerData* pager) } /* Num rows: */ - g_signal_connect(G_OBJECT(pager->num_rows_spin), "value_changed", (GCallback) num_rows_value_changed, pager); + g_signal_connect (pager->num_rows_spin, "value-changed", G_CALLBACK (num_rows_value_changed), pager); gtk_spin_button_set_value(GTK_SPIN_BUTTON(pager->num_rows_spin), pager->n_rows); gtk_label_set_text(GTK_LABEL(pager->label_row_col), pager->orientation == GTK_ORIENTATION_HORIZONTAL ? _("rows") : _("columns")); @@ -1043,7 +1045,7 @@ static void setup_dialog(GtkBuilder* builder, PagerData* pager) } #endif /* HAVE_X11 */ - g_signal_connect(G_OBJECT(pager->num_workspaces_spin), "value_changed", (GCallback) num_workspaces_value_changed, pager); + g_signal_connect (pager->num_workspaces_spin, "value-changed", G_CALLBACK (on_num_workspaces_value_changed), pager); g_signal_connect(G_OBJECT(pager->workspaces_tree), "focus_out_event", (GCallback) workspaces_tree_focused_out, pager); |