Jesús González has proposed merging lp:~jgonzalezdr/cairo-dock-plug-ins/3.3 into lp:cairo-dock-plug-ins/3.3.
Requested reviews: Cairo-Dock Devs (cairo-dock-team) For more details, see: https://code.launchpad.net/~jgonzalezdr/cairo-dock-plug-ins/3.3/+merge/233144 Added Suspend-Workaround applet that fixes the icon corruption that happens with some graphic cards (e.g. nvidia) when suspending the computer. Fixes bug #535065 "symptoms" with a workaround that doesn't need external scripts added and configured manually by affected users (as proposed in https://bugs.launchpad.net/cairo-dock-plug-ins/+bug/535065/comments/14), therefore it's a lot more user-friendly solution and it's more robust (the python script solution sometimes fails, maybe because dbus messages to reboot cairo-dock are lost). To test it just install the applet in an affected computer and enable it, suspend the computer, resume, and voilà... icons aren't corrupted any more. -- https://code.launchpad.net/~jgonzalezdr/cairo-dock-plug-ins/3.3/+merge/233144 Your team Cairo-Dock Devs is requested to review the proposed merge of lp:~jgonzalezdr/cairo-dock-plug-ins/3.3 into lp:cairo-dock-plug-ins/3.3.
=== modified file 'CMakeLists.txt' --- CMakeLists.txt 2013-10-29 10:27:40 +0000 +++ CMakeLists.txt 2014-09-03 02:36:35 +0000 @@ -1487,6 +1487,19 @@ endif() endif() +############# SUSPEND-WORKAROUND ################# +set (with_suspend_workaround no) +if (enable-suspend-workaround) + message (STATUS "> Suspend-Workaround:") + set (GETTEXT_SUSPEND_WORKAROUND ${GETTEXT_PLUGINS}) + set (VERSION_SUSPEND_WORKAROUND "1.0.0") + set (PACKAGE_SUSPEND_WORKAROUND "cd-SuspendWorkaround") + set (with_suspend_workaround yes) + set (suspendworkarounddatadir "${pluginsdatadir}/Suspend-Workaround") + configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Suspend-Workaround/data/Suspend-Workaround.conf.in ${CMAKE_CURRENT_BINARY_DIR}/Suspend-Workaround/data/Suspend-Workaround.conf) + add_subdirectory (Suspend-Workaround) +endif() + message ("") message (STATUS "===============") message (STATUS "Language build:") @@ -1521,6 +1534,7 @@ message (STATUS " - with Terminal applet: ${with_terminal}") message (STATUS " - with Weblets applet: ${with_weblets}") message (STATUS " - with Xgamma applet: ${with_xgamma}") +message (STATUS " - with Suspend-Workaround applet: ${with_suspend_workaround}") message (STATUS "Add On:") message (STATUS " - with Sound-Menu support: ${with_soundmenu}") message (STATUS " - with Screen Resolution support: ${with_xrandr}") === added directory 'Suspend-Workaround' === added file 'Suspend-Workaround/CMakeLists.txt' --- Suspend-Workaround/CMakeLists.txt 1970-01-01 00:00:00 +0000 +++ Suspend-Workaround/CMakeLists.txt 2014-09-03 02:36:35 +0000 @@ -0,0 +1,2 @@ +add_subdirectory(src) +add_subdirectory(data) === added directory 'Suspend-Workaround/data' === added file 'Suspend-Workaround/data/CMakeLists.txt' --- Suspend-Workaround/data/CMakeLists.txt 1970-01-01 00:00:00 +0000 +++ Suspend-Workaround/data/CMakeLists.txt 2014-09-03 02:36:35 +0000 @@ -0,0 +1,7 @@ + +########### install files ############### + +install (FILES ${CMAKE_CURRENT_BINARY_DIR}/Suspend-Workaround.conf + icon.png + DESTINATION ${suspendworkarounddatadir}) + === added file 'Suspend-Workaround/data/Suspend-Workaround.conf.in' --- Suspend-Workaround/data/Suspend-Workaround.conf.in 1970-01-01 00:00:00 +0000 +++ Suspend-Workaround/data/Suspend-Workaround.conf.in 2014-09-03 02:36:35 +0000 @@ -0,0 +1,8 @@ +#@VERSION_SUSPEND_WORKAROUND@ + +#[gtk-about] +[Icon] + +#A +handbook=Suspend-Workaround + === added file 'Suspend-Workaround/data/icon.png' Binary files Suspend-Workaround/data/icon.png 1970-01-01 00:00:00 +0000 and Suspend-Workaround/data/icon.png 2014-09-03 02:36:35 +0000 differ === added directory 'Suspend-Workaround/src' === added file 'Suspend-Workaround/src/CMakeLists.txt' --- Suspend-Workaround/src/CMakeLists.txt 1970-01-01 00:00:00 +0000 +++ Suspend-Workaround/src/CMakeLists.txt 2014-09-03 02:36:35 +0000 @@ -0,0 +1,38 @@ + +########### sources ############### + +SET(MODULE_SRCS + applet-struct.h + applet-init.c + applet-init.h + applet-config.h +) + +add_library(${PACKAGE_SUSPEND_WORKAROUND} SHARED ${MODULE_SRCS}) + +########### compil ############### +add_definitions (-DMY_APPLET_SHARE_DATA_DIR="${suspendworkarounddatadir}") +add_definitions (-DMY_APPLET_PREVIEW_FILE="icon.png") +add_definitions (-DMY_APPLET_CONF_FILE="Suspend-Workaround.conf") +add_definitions (-DMY_APPLET_USER_DATA_DIR="Suspend-Workaround") +add_definitions (-DMY_APPLET_VERSION="${VERSION_SUSPEND_WORKAROUND}") +add_definitions (-DMY_APPLET_GETTEXT_DOMAIN="${GETTEXT_SUSPEND_WORKAROUND}") +add_definitions (-DMY_APPLET_DOCK_VERSION="${dock_version}") +add_definitions (-DMY_APPLET_ICON_FILE="icon.png") +### uncomment the following line to allow multi-instance applet. +#add_definitions (-DCD_APPLET_MULTI_INSTANCE="1") +### uncomment the following line to allow extended OpenGL drawing. +#add_definitions (-DGL_GLEXT_PROTOTYPES="1") + +include_directories ( + ${PACKAGE_INCLUDE_DIRS}) + +link_directories ( + ${PACKAGE_LIBRARY_DIRS}) + +target_link_libraries (${PACKAGE_SUSPEND_WORKAROUND} + ${PACKAGE_LIBRARIES}) + +########### install files ############### + +install(TARGETS ${PACKAGE_SUSPEND_WORKAROUND} DESTINATION ${pluginsdir}) === added file 'Suspend-Workaround/src/applet-config.h' --- Suspend-Workaround/src/applet-config.h 1970-01-01 00:00:00 +0000 +++ Suspend-Workaround/src/applet-config.h 2014-09-03 02:36:35 +0000 @@ -0,0 +1,30 @@ +/** +* This file is a part of the Cairo-Dock project +* +* Copyright : (C) see the 'copyright' file. +* E-mail : see the 'copyright' file. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 3 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + + +#ifndef __APPLET_CONFIG__ +#define __APPLET_CONFIG__ + +#include <cairo-dock.h> + + +CD_APPLET_CONFIG_H + + +#endif === added file 'Suspend-Workaround/src/applet-init.c' --- Suspend-Workaround/src/applet-init.c 1970-01-01 00:00:00 +0000 +++ Suspend-Workaround/src/applet-init.c 2014-09-03 02:36:35 +0000 @@ -0,0 +1,157 @@ +/** +* This file is a part of the Cairo-Dock project +* +* Copyright : (C) see the 'copyright' file. +* E-mail : see the 'copyright' file. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 3 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "stdlib.h" + +#include "applet-config.h" +#include "applet-struct.h" +#include "applet-init.h" + +#define SIGNAL_TYPE_LOGIN1 0 +#define SIGNAL_TYPE_UPOWER 1 + +#define APPLET_NAME "Suspend-Workaround" +#define APPLET_LOG APPLET_NAME " > " + +CD_APPLET_DEFINE_BEGIN( APPLET_NAME, + 1, 0, 0, + CAIRO_DOCK_CATEGORY_APPLET_SYSTEM, + N_("This plug-in is a workaround that fixes the icon corruption that " + "happens with some graphic cards (e.g. nvidia) when suspending the computer"), + "Jesús González" ) + pInterface->initModule = CD_APPLET_INIT_FUNC; + pInterface->stopModule = CD_APPLET_STOP_FUNC; + CD_APPLET_SET_CONTAINER_TYPE( CAIRO_DOCK_MODULE_IS_PLUGIN ); + CD_APPLET_REDEFINE_TITLE (N_("Corruption-on-Suspend workaround")) +CD_APPLET_DEFINE_END + +#define DBUS_POWER_OBJECT_INFO_SIZE 2 + +struct _dbus_power_object_info dbus_power_object_info[DBUS_POWER_OBJECT_INFO_SIZE] = +{ + { + "org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", "PrepareForSleep", G_TYPE_BOOLEAN, + }, + { + "org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.UPower", "Resuming", G_TYPE_NONE, + } +}; + +static void _on_resuming(void) +{ + cd_message( APPLET_LOG "Resuming from sleep" ); + cairo_dock_load_current_theme(); +} + +static void _on_prepare_for_sleep( DBusGProxy* proxy, gboolean going_to_sleep, gpointer userData ) +{ + if( going_to_sleep ) + { + cd_message( APPLET_LOG "Going to sleep" ); + } + else + { + _on_resuming(); + } +} + +CD_APPLET_INIT_BEGIN + + myDataPtr->power_object_info = NULL; + + DBusGProxy *pMainProxy = cairo_dock_get_main_system_proxy(); + if( pMainProxy == NULL ) + { + cd_warning( APPLET_LOG "Can't get main system dbus proxy" ); + return; + } + + int pwrobj_index = 0; + gboolean pwrobj_found = FALSE; + while( (pwrobj_index < DBUS_POWER_OBJECT_INFO_SIZE) ) { + org_freedesktop_DBus_name_has_owner( pMainProxy, dbus_power_object_info[pwrobj_index].name, &pwrobj_found, NULL ); + if( pwrobj_found ) + { + break; + } + pwrobj_index++; + } + + if( !pwrobj_found ) + { + cd_warning( APPLET_LOG "Power management object not available on dbus" ); + return; + } + + myDataPtr->power_object_info = &dbus_power_object_info[pwrobj_index]; + + cd_message( APPLET_LOG "Power management object used is %s", myDataPtr->power_object_info->name ); + + myDataPtr->pProxy = cairo_dock_create_new_system_proxy( myDataPtr->power_object_info->name, myDataPtr->power_object_info->path, myDataPtr->power_object_info->interface ); + if( myDataPtr->pProxy == NULL ) + { + cd_warning( APPLET_LOG "Error accessing power management object on dbus" ); + return; + } + + if( myDataPtr->power_object_info->signal_type == SIGNAL_TYPE_UPOWER ) + { + dbus_g_object_register_marshaller ( + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + G_TYPE_INVALID); + + dbus_g_proxy_add_signal( myDataPtr->pProxy, myDataPtr->power_object_info->resume_signal, G_TYPE_INVALID ); + dbus_g_proxy_connect_signal( myDataPtr->pProxy, myDataPtr->power_object_info->resume_signal, G_CALLBACK( _on_resuming ), NULL, NULL ); + } + else + { + dbus_g_object_register_marshaller ( + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, + G_TYPE_BOOLEAN, + G_TYPE_INVALID); + + dbus_g_proxy_add_signal( myDataPtr->pProxy, myDataPtr->power_object_info->resume_signal, G_TYPE_BOOLEAN, G_TYPE_INVALID ); + dbus_g_proxy_connect_signal( myDataPtr->pProxy, myDataPtr->power_object_info->resume_signal, G_CALLBACK( _on_prepare_for_sleep ), NULL, NULL ); + } + + cd_message( APPLET_LOG "Listening for power management events..." ); + +CD_APPLET_INIT_END + + +CD_APPLET_STOP_BEGIN + + if( myDataPtr->pProxy != NULL ) + { + if( myDataPtr->power_object_info->signal_type == SIGNAL_TYPE_UPOWER ) + { + dbus_g_proxy_disconnect_signal( myDataPtr->pProxy, myDataPtr->power_object_info->resume_signal, G_CALLBACK( _on_resuming ), NULL); + } + else + { + dbus_g_proxy_disconnect_signal( myDataPtr->pProxy, myDataPtr->power_object_info->resume_signal, G_CALLBACK( _on_prepare_for_sleep ), NULL); + } + g_object_unref( myDataPtr->pProxy ); + } + + cd_message( APPLET_LOG "Stopped listening for power management events" ); + +CD_APPLET_STOP_END === added file 'Suspend-Workaround/src/applet-init.h' --- Suspend-Workaround/src/applet-init.h 1970-01-01 00:00:00 +0000 +++ Suspend-Workaround/src/applet-init.h 2014-09-03 02:36:35 +0000 @@ -0,0 +1,31 @@ +/** +* This file is a part of the Cairo-Dock project +* +* Copyright : (C) see the 'copyright' file. +* E-mail : see the 'copyright' file. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 3 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + + +#ifndef __APPLET_INIT__ +#define __APPLET_INIT__ + + +#include <cairo-dock.h> + + +CD_APPLET_H + + +#endif === added file 'Suspend-Workaround/src/applet-struct.h' --- Suspend-Workaround/src/applet-struct.h 1970-01-01 00:00:00 +0000 +++ Suspend-Workaround/src/applet-struct.h 2014-09-03 02:36:35 +0000 @@ -0,0 +1,47 @@ +/** +* This file is a part of the Cairo-Dock project +* +* Copyright : (C) see the 'copyright' file. +* E-mail : see the 'copyright' file. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 3 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + + +#ifndef __CD_APPLET_STRUCT__ +#define __CD_APPLET_STRUCT__ + +#include <cairo-dock.h> + +#include <dbus/dbus-glib.h> + +//\___________ structure containing the applet's configuration parameters. +struct _AppletConfig { +} ; + +struct _dbus_power_object_info { + char* name; + char* path; + char* interface; + char* resume_signal; + int signal_type; +}; + +//\___________ structure containing the applet's data, like surfaces, dialogs, results of calculus, etc. +struct _AppletData { + DBusGProxy *pProxy; + struct _dbus_power_object_info *power_object_info; +} ; + + +#endif
_______________________________________________ Mailing list: https://launchpad.net/~cairo-dock-team Post to : cairo-dock-team@lists.launchpad.net Unsubscribe : https://launchpad.net/~cairo-dock-team More help : https://help.launchpad.net/ListHelp