├── AUTHORS ├── .gitignore ├── hotcorner.desktop ├── CMakeLists.txt ├── po ├── xfce4-hotcorner-plugin.pot └── zh_TW.po ├── src ├── util.h ├── hotcorner.h ├── util.c └── hotcorner.c └── README.md /AUTHORS: -------------------------------------------------------------------------------- 1 | BrianHsu 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | CMakeCache.txt 2 | CMakeFiles 3 | cmake_install.cmake 4 | libhotcorner.so 5 | Makefile 6 | *.swp 7 | install_manifest.txt 8 | -------------------------------------------------------------------------------- /hotcorner.desktop: -------------------------------------------------------------------------------- 1 | [Xfce Panel] 2 | Type=X-XFCE-PanelPlugin 3 | Encoding=UTF-8 4 | Name=HotCorner 5 | Name[zh_TW]=螢幕熱點 6 | Comment=HotCorner 7 | Comment[zh_TW]=螢幕熱點 8 | Icon=xfce4-display 9 | X-XFCE-Internal=FALSE 10 | X-XFCE-Module=hotcorner 11 | X-XFCE-Unique=true 12 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED(VERSION 2.6) 2 | 3 | PROJECT(xfce4-hotcorner-plugin C) 4 | 5 | SET(VERSION 0.0.2) 6 | 7 | FIND_PACKAGE(PkgConfig REQUIRED) 8 | FIND_PACKAGE(Gettext REQUIRED) 9 | include(GNUInstallDirs) 10 | 11 | PKG_CHECK_MODULES(GTK REQUIRED libxfce4panel-1.0 libxfce4ui-1 libwnck-3.0) 12 | 13 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 14 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 15 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 16 | 17 | INCLUDE_DIRECTORIES(${GTK_INCLUDE_DIRS}) 18 | LINK_DIRECTORIES(${GTK_LIBRARY_DIRS}) 19 | ADD_DEFINITIONS( 20 | ${GTK_CFLAGS_OTHER} 21 | -DWNCK_I_KNOW_THIS_IS_UNSTABLE=1 22 | -DGETTEXT_PACKAGE="${PROJECT_NAME}" 23 | -DLOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}" 24 | ) 25 | 26 | 27 | ADD_LIBRARY(hotcorner SHARED src/hotcorner.c src/util.c) 28 | 29 | TARGET_LINK_LIBRARIES(hotcorner ${GTK_LIBRARIES}) 30 | 31 | INSTALL(TARGETS hotcorner LIBRARY DESTINATION lib/xfce4/panel/plugins/) 32 | INSTALL(FILES hotcorner.desktop DESTINATION share/xfce4/panel/plugins/) 33 | GETTEXT_CREATE_TRANSLATIONS(po/xfce4-hotcorner-plugin.pot ALL po/zh_TW.po) 34 | 35 | -------------------------------------------------------------------------------- /po/xfce4-hotcorner-plugin.pot: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: PACKAGE VERSION\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2015-06-30 15:57+0800\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "Language: \n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=CHARSET\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | 20 | #: hotcorner.c:318 21 | msgid "-" 22 | msgstr "" 23 | 24 | #: hotcorner.c:323 25 | msgid "Custom Command" 26 | msgstr "" 27 | 28 | #: hotcorner.c:399 29 | msgid "Disable when active window is full screen" 30 | msgstr "" 31 | 32 | #: hotcorner.c:392 33 | msgid "HotCorner" 34 | msgstr "" 35 | 36 | #: hotcorner.c:320 37 | msgid "Show Desktop" 38 | msgstr "" 39 | 40 | #: hotcorner.c:321 41 | msgid "Start Screensaver" 42 | msgstr "" 43 | 44 | #: hotcorner.c:322 45 | msgid "Turn Off Monitor" 46 | msgstr "" 47 | 48 | #: hotcorner.c:319 49 | msgid "Xfdashboard" 50 | msgstr "" 51 | -------------------------------------------------------------------------------- /po/zh_TW.po: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: xfce4-hotcorner-plugin\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2015-06-30 15:57+0800\n" 12 | "PO-Revision-Date: 2015-06-26 15:00+0800\n" 13 | "Last-Translator: BrianHsu \n" 14 | "Language-Team: LANGUAGE \n" 15 | "Language: \n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=UTF-8\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | 20 | #: hotcorner.c:318 21 | msgid "-" 22 | msgstr "" 23 | 24 | #: hotcorner.c:323 25 | msgid "Custom Command" 26 | msgstr "自訂指令" 27 | 28 | #: hotcorner.c:399 29 | msgid "Disable when active window is full screen" 30 | msgstr "當前視窗為全螢幕時不執行螢幕熱點" 31 | 32 | #: hotcorner.c:392 33 | msgid "HotCorner" 34 | msgstr "螢幕熱點" 35 | 36 | #: hotcorner.c:320 37 | msgid "Show Desktop" 38 | msgstr "顯示桌面" 39 | 40 | #: hotcorner.c:321 41 | msgid "Start Screensaver" 42 | msgstr "啟動螢幕保護程式" 43 | 44 | #: hotcorner.c:322 45 | msgid "Turn Off Monitor" 46 | msgstr "關閉螢幕" 47 | 48 | #: hotcorner.c:319 49 | msgid "Xfdashboard" 50 | msgstr "" 51 | -------------------------------------------------------------------------------- /src/util.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) BrianHsu 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 | * Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef __HOTCORNER_H__ 20 | #define __HOTCORNER_H__ 21 | 22 | #include 23 | #include "hotcorner.h" 24 | 25 | gboolean is_upper_left(GdkRectangle monitorInfo, gint x, gint y); 26 | gboolean is_upper_right(GdkRectangle monitorInfo, gint x, gint y); 27 | gboolean is_lower_right(GdkRectangle monitorInfo, gint x, gint y); 28 | gboolean is_lower_left(GdkRectangle monitorInfo, gint x, gint y); 29 | void toggle_desktop(int spot, HotCorner * hotCorenr); 30 | void turn_off_monitor(int spot, HotCorner * hotCorner); 31 | void start_screensaver(int spot, HotCorner * hotCorner); 32 | void start_dashboard(int spot, HotCorner * hotCorner); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | XFCE4 HotCorner Panel Plugin 2 | ============================== 3 | 4 | Please use other's fork 5 | ------------------------ 6 | 7 | I've not use XFCE4 for a long time. So this project is abandoned and I won't maintain it anymore. 8 | If you are seeking for a more useable, updated version, please check https://github.com/christopherkobayashi/xfce4-hotcorner-plugin 9 | 10 | Introduction 11 | -------------- 12 | 13 | This is aim to provide an easy to use xfce4 panel plugin that let users set hot corner action. 14 | 15 | Currently it supports the following operation in primary display: 16 | 17 | - xfdashboard 18 | - toggle desktop 19 | - start screensaver 20 | - turn off monitor 21 | - run custom command 22 | 23 | Screenshot 24 | ------------------------ 25 | 26 | ![Screenshot](http://i.imgur.com/575haSy.png) 27 | 28 | Prerequisite 29 | ------------------------ 30 | 31 | - CMake 32 | - libwnck >= 3.14.0 33 | - xfce4-panel >= 4.12.0 34 | 35 | Compile & Installation 36 | ------------------------- 37 | 38 | ```console 39 | git clone git://github.com/brianhsu/xfce4-hotcorner-plugin.git 40 | cd xfce4-hotcorner-plugin 41 | cmake -DCMAKE_INSTALL_PREFIX=/usr . 42 | make install 43 | ``` 44 | 45 | Installation 46 | ---------------------- 47 | 48 | - ArchLinux AUR: 49 | - https://aur4.archlinux.org/packages/xfce4-hotcorner-plugin 50 | 51 | - Gentoo Ebuild: 52 | - https://gist.github.com/brianhsu/637a906e9a1e17ca6392 53 | 54 | License 55 | ----------- 56 | 57 | Licensed under [GNU GPL v2][0] or (at your option) any later version.. 58 | 59 | [0]: https://www.gnu.org/licenses/gpl-2.0.html 60 | -------------------------------------------------------------------------------- /src/hotcorner.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) BrianHsu 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 | * Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #ifndef __HOTCORNER_PLUGIN__ 20 | #define __HOTCORNER_PLUGIN__ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #define UPDATE_TIMEOUT 50 27 | 28 | typedef struct HotCorner HotCorner; 29 | typedef void (* ActionCallback)(int spot, HotCorner * hotCorner); 30 | 31 | struct HotCorner { 32 | 33 | XfcePanelPlugin * plugin; 34 | 35 | guint timeout_id; 36 | guint ticket; 37 | 38 | gboolean isExecuted; 39 | 40 | GtkWidget * icon; 41 | 42 | GdkRectangle monitorInfo; 43 | 44 | ActionCallback upperLeftCallback; 45 | ActionCallback lowerLeftCallback; 46 | ActionCallback upperRightCallback; 47 | ActionCallback lowerRightCallback; 48 | 49 | gint upperLeftActionID; 50 | gint upperRightActionID; 51 | gint lowerLeftActionID; 52 | gint lowerRightActionID; 53 | gboolean disableWhenFullScreen; 54 | 55 | GtkWidget * upperLeftCommand; 56 | GtkWidget * upperRightCommand; 57 | GtkWidget * lowerLeftCommand; 58 | GtkWidget * lowerRightCommand; 59 | 60 | const gchar * upperLeftSavedCommand; 61 | const gchar * upperRightSavedCommand; 62 | const gchar * lowerLeftSavedCommand; 63 | const gchar * lowerRightSavedCommand; 64 | 65 | }; 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /src/util.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) BrianHsu 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 | * Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #include 20 | #include "util.h" 21 | 22 | gboolean is_upper_left(GdkRectangle monitorInfo, gint x, gint y) { 23 | return (x == monitorInfo.x) && (y == monitorInfo.y); 24 | } 25 | 26 | gboolean is_upper_right(GdkRectangle monitorInfo, gint x, gint y) { 27 | return (x == monitorInfo.x + monitorInfo.width - 1) && (y == monitorInfo.y); 28 | } 29 | 30 | gboolean is_lower_right(GdkRectangle monitorInfo, gint x, gint y) { 31 | return (x == monitorInfo.x + monitorInfo.width - 1) && (y == monitorInfo.y + monitorInfo.height - 1); 32 | } 33 | 34 | gboolean is_lower_left(GdkRectangle monitorInfo, gint x, gint y) { 35 | return (x == monitorInfo.x) && (y == monitorInfo.y + monitorInfo.height - 1); 36 | } 37 | 38 | void toggle_desktop(int spot, HotCorner * hotCorner) { 39 | WnckScreen * wnck = wnck_screen_get_default(); 40 | gboolean is_showing = wnck_screen_get_showing_desktop(wnck); 41 | wnck_screen_toggle_showing_desktop(wnck, !is_showing); 42 | } 43 | 44 | void turn_off_monitor(int spot, HotCorner * hotCorner) { 45 | system("xset dpms force off"); 46 | } 47 | 48 | void start_screensaver(int spot, HotCorner * hotCorner) { 49 | system("xscreensaver-command -activate"); 50 | } 51 | 52 | void start_dashboard(int spot, HotCorner * hotCorenr) { 53 | system("xfdashboard"); 54 | } 55 | 56 | -------------------------------------------------------------------------------- /src/hotcorner.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) BrianHsu 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 | * Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | #include 20 | #include "hotcorner.h" 21 | #include "util.h" 22 | 23 | #define UPPER_LEFT 0 24 | #define UPPER_RIGHT 1 25 | #define LOWER_LEFT 2 26 | #define LOWER_RIGHT 3 27 | 28 | void run_command(const gchar * command) { 29 | 30 | gchar * value = g_strstrip(g_strdup(command)); 31 | 32 | if (strlen(value) > 0) { 33 | system(value); 34 | } 35 | 36 | g_free(value); 37 | 38 | } 39 | 40 | void run_custom_command(int spot, HotCorner * hotCorner) { 41 | 42 | switch (spot) { 43 | case UPPER_LEFT: 44 | run_command(hotCorner->upperLeftSavedCommand); 45 | break; 46 | case UPPER_RIGHT: 47 | run_command(hotCorner->upperRightSavedCommand); 48 | break; 49 | case LOWER_LEFT: 50 | run_command(hotCorner->lowerLeftSavedCommand); 51 | break; 52 | case LOWER_RIGHT: 53 | run_command(hotCorner->lowerRightSavedCommand); 54 | break; 55 | 56 | } 57 | 58 | } 59 | 60 | ActionCallback get_action_callback_from_index(int index, int * outSelected) { 61 | *outSelected = index; 62 | 63 | switch (index) { 64 | case 0: 65 | return NULL; 66 | break; 67 | case 1: 68 | return start_dashboard; 69 | break; 70 | case 2: 71 | return toggle_desktop; 72 | break; 73 | case 3: 74 | return start_screensaver; 75 | break; 76 | case 4: 77 | return turn_off_monitor; 78 | break; 79 | case 5: 80 | return run_custom_command; 81 | } 82 | 83 | } 84 | 85 | static void read_config_file(XfcePanelPlugin * plugin, HotCorner * hotCorner) { 86 | gchar *file = xfce_panel_plugin_lookup_rc_file(plugin); 87 | 88 | if (file) 89 | { 90 | XfceRc *rc = xfce_rc_simple_open (file, TRUE); 91 | 92 | if (rc != NULL) 93 | { 94 | hotCorner->disableWhenFullScreen = xfce_rc_read_int_entry(rc, "DISABLE_WHEN_FULL_SCREEN", FALSE); 95 | hotCorner->upperLeftActionID = xfce_rc_read_int_entry(rc, "UPPER_LEFT_ACTION_ID", 0); 96 | hotCorner->upperRightActionID = xfce_rc_read_int_entry(rc, "UPPER_RIGHT_ACTION_ID", 0); 97 | hotCorner->lowerLeftActionID = xfce_rc_read_int_entry(rc, "LOWER_LEFT_ACTION_ID", 0); 98 | hotCorner->lowerRightActionID = xfce_rc_read_int_entry(rc, "LOWER_RIGHT_ACTION_ID", 0); 99 | 100 | hotCorner->upperLeftSavedCommand = g_strdup(xfce_rc_read_entry (rc, "UPPER_LEFT_COMMAND", NULL)); 101 | hotCorner->upperRightSavedCommand = g_strdup(xfce_rc_read_entry (rc, "UPPER_RIGHT_COMMAND", NULL)); 102 | hotCorner->lowerLeftSavedCommand = g_strdup(xfce_rc_read_entry (rc, "LOWER_LEFT_COMMAND", NULL)); 103 | hotCorner->lowerRightSavedCommand = g_strdup(xfce_rc_read_entry (rc, "LOWER_RIGHT_COMMAND", NULL)); 104 | 105 | hotCorner->upperLeftCallback = get_action_callback_from_index(hotCorner->upperLeftActionID, &(hotCorner->upperLeftActionID)); 106 | hotCorner->upperRightCallback = get_action_callback_from_index(hotCorner->upperRightActionID, &(hotCorner->upperRightActionID)); 107 | hotCorner->lowerLeftCallback = get_action_callback_from_index(hotCorner->lowerLeftActionID, &(hotCorner->lowerLeftActionID)); 108 | hotCorner->lowerRightCallback = get_action_callback_from_index(hotCorner->lowerRightActionID, &(hotCorner->lowerRightActionID)); 109 | 110 | xfce_rc_close (rc); 111 | } 112 | 113 | g_free (file); 114 | } 115 | 116 | } 117 | 118 | static void save_config_file(XfcePanelPlugin * plugin, HotCorner * hotCorner) { 119 | 120 | gchar *file = xfce_panel_plugin_save_location (plugin, TRUE); 121 | 122 | hotCorner->upperLeftSavedCommand = g_strdup(gtk_entry_get_text(GTK_ENTRY(hotCorner->upperLeftCommand))); 123 | hotCorner->upperRightSavedCommand = g_strdup(gtk_entry_get_text(GTK_ENTRY(hotCorner->upperRightCommand))); 124 | hotCorner->lowerLeftSavedCommand = g_strdup(gtk_entry_get_text(GTK_ENTRY(hotCorner->lowerLeftCommand))); 125 | hotCorner->lowerRightSavedCommand = g_strdup(gtk_entry_get_text(GTK_ENTRY(hotCorner->lowerRightCommand))); 126 | 127 | if (file) { 128 | 129 | XfceRc * rc = xfce_rc_simple_open (file, FALSE); 130 | 131 | if (rc) { 132 | xfce_rc_write_int_entry (rc, "UPPER_LEFT_ACTION_ID", hotCorner->upperLeftActionID); 133 | xfce_rc_write_int_entry (rc, "UPPER_RIGHT_ACTION_ID", hotCorner->upperRightActionID); 134 | xfce_rc_write_int_entry (rc, "LOWER_LEFT_ACTION_ID", hotCorner->lowerLeftActionID); 135 | xfce_rc_write_int_entry (rc, "LOWER_RIGHT_ACTION_ID", hotCorner->lowerRightActionID); 136 | 137 | xfce_rc_write_int_entry (rc, "DISABLE_WHEN_FULL_SCREEN", hotCorner->disableWhenFullScreen); 138 | 139 | xfce_rc_write_entry (rc, "UPPER_LEFT_COMMAND", gtk_entry_get_text(GTK_ENTRY(hotCorner->upperLeftCommand))); 140 | xfce_rc_write_entry (rc, "UPPER_RIGHT_COMMAND", gtk_entry_get_text(GTK_ENTRY(hotCorner->upperRightCommand))); 141 | xfce_rc_write_entry (rc, "LOWER_LEFT_COMMAND", gtk_entry_get_text(GTK_ENTRY(hotCorner->lowerLeftCommand))); 142 | xfce_rc_write_entry (rc, "LOWER_RIGHT_COMMAND", gtk_entry_get_text(GTK_ENTRY(hotCorner->lowerRightCommand))); 143 | 144 | xfce_rc_close (rc); 145 | } 146 | 147 | g_free(file); 148 | 149 | } 150 | } 151 | 152 | 153 | static void free_data(XfcePanelPlugin *plugin, HotCorner * hotCorner) { 154 | if (hotCorner->timeout_id != 0) { 155 | g_source_remove (hotCorner->timeout_id); 156 | } 157 | 158 | gtk_widget_destroy(hotCorner->icon); 159 | g_free(hotCorner); 160 | } 161 | 162 | static gint check_hot_corner_action(HotCorner * hotCorner) { 163 | GdkScreen * screen = gtk_widget_get_screen(hotCorner->icon); 164 | GdkWindow * window = gdk_screen_get_root_window(screen); 165 | GdkDisplay * display = gtk_widget_get_display(hotCorner->icon); 166 | gint x, y; 167 | gdk_window_get_pointer(window, &x, &y, NULL); 168 | 169 | if (hotCorner->disableWhenFullScreen) { 170 | WnckScreen * wnckScreen = wnck_screen_get_default(); 171 | WnckWindow * activeWindow = wnck_screen_get_active_window(wnckScreen); 172 | if (wnck_window_is_fullscreen(activeWindow)) { 173 | return TRUE; 174 | } 175 | } 176 | 177 | if (is_upper_left(hotCorner->monitorInfo, x, y) && hotCorner->upperLeftCallback != NULL) { 178 | hotCorner->ticket++; 179 | if (!hotCorner->isExecuted && hotCorner->ticket >= 5) { 180 | hotCorner->upperLeftCallback(UPPER_LEFT, hotCorner); 181 | hotCorner->isExecuted = TRUE; 182 | } 183 | } else if (is_upper_right(hotCorner->monitorInfo, x, y) && hotCorner->upperRightCallback != NULL) { 184 | hotCorner->ticket++; 185 | if (!hotCorner->isExecuted && hotCorner->ticket >= 5) { 186 | hotCorner->upperRightCallback(UPPER_RIGHT, hotCorner); 187 | hotCorner->isExecuted = TRUE; 188 | } 189 | } else if (is_lower_right(hotCorner->monitorInfo, x, y) && hotCorner->lowerRightCallback != NULL) { 190 | hotCorner->ticket++; 191 | if (!hotCorner->isExecuted && hotCorner->ticket >= 5) { 192 | hotCorner->lowerRightCallback(LOWER_RIGHT, hotCorner); 193 | hotCorner->isExecuted = TRUE; 194 | } 195 | 196 | } else if (is_lower_left(hotCorner->monitorInfo, x, y) && hotCorner->lowerLeftCallback != NULL) { 197 | hotCorner->ticket++; 198 | if (!hotCorner->isExecuted && hotCorner->ticket >= 5) { 199 | hotCorner->lowerLeftCallback(LOWER_LEFT, hotCorner); 200 | hotCorner->isExecuted = TRUE; 201 | } 202 | } else { 203 | hotCorner->ticket = 0; 204 | hotCorner->isExecuted = FALSE; 205 | } 206 | return TRUE; 207 | } 208 | 209 | static void start_polling_mouse_position(HotCorner * hotCorner) { 210 | if (hotCorner->timeout_id == 0) 211 | { 212 | hotCorner->timeout_id = g_timeout_add (UPDATE_TIMEOUT, (GSourceFunc)check_hot_corner_action, hotCorner); 213 | } 214 | } 215 | 216 | static HotCorner * hotCorner_new(XfcePanelPlugin *plugin) { 217 | HotCorner * hotCorner = g_new0(HotCorner, 1); 218 | hotCorner->plugin = plugin; 219 | hotCorner->icon = xfce_panel_image_new_from_source ("xfce4-display"); 220 | hotCorner->disableWhenFullScreen = TRUE; 221 | hotCorner->upperLeftCallback = NULL; 222 | hotCorner->lowerLeftCallback = NULL; 223 | hotCorner->upperRightCallback = NULL; 224 | hotCorner->lowerRightCallback = NULL; 225 | hotCorner->upperLeftCommand = NULL; 226 | hotCorner->lowerLeftCommand = NULL; 227 | hotCorner->upperRightCommand = NULL; 228 | hotCorner->lowerRightCommand = NULL; 229 | hotCorner->upperLeftActionID = 0; 230 | hotCorner->upperRightActionID = 0; 231 | hotCorner->lowerLeftActionID = 0; 232 | hotCorner->lowerRightActionID = 0; 233 | 234 | 235 | gtk_container_add(GTK_CONTAINER(hotCorner->plugin), hotCorner->icon); 236 | gtk_widget_show_all(hotCorner->icon); 237 | 238 | start_polling_mouse_position(hotCorner); 239 | 240 | return hotCorner; 241 | } 242 | 243 | static void set_monitor_size(HotCorner * hotCorner) { 244 | GdkScreen * screen = gdk_screen_get_default(); 245 | GdkRectangle monitorInfo; 246 | gint monitorID = gdk_screen_get_primary_monitor(screen); 247 | gdk_screen_get_monitor_geometry (screen, monitorID, &monitorInfo); 248 | hotCorner->monitorInfo = monitorInfo; 249 | } 250 | 251 | ActionCallback get_action_callback(GtkComboBox * comboBox, int * outSelected) { 252 | gint selected = gtk_combo_box_get_active(comboBox); 253 | return get_action_callback_from_index(selected, outSelected); 254 | } 255 | 256 | static void set_new_entry_visibility(GtkComboBox * comboBox, GtkWidget * entry) { 257 | gint selected = gtk_combo_box_get_active(comboBox); 258 | 259 | if (selected != 5) { 260 | gtk_widget_set_no_show_all(entry, TRUE); 261 | gtk_widget_hide(entry); 262 | } else { 263 | gtk_widget_set_no_show_all(entry, FALSE); 264 | gtk_widget_show(entry); 265 | } 266 | 267 | } 268 | 269 | static void set_corner_command_entry(GtkWidget * entry, HotCorner * hotCorner) { 270 | 271 | const gchar * name = gtk_widget_get_name(GTK_WIDGET(entry)); 272 | 273 | if (g_strcmp0(name, "UPPER_LEFT") == 0) { 274 | hotCorner->upperLeftCommand = entry; 275 | gtk_entry_set_text(GTK_ENTRY(entry), hotCorner->upperLeftSavedCommand); 276 | } else if (g_strcmp0(name, "UPPER_RIGHT") == 0) { 277 | hotCorner->upperRightCommand = entry; 278 | gtk_entry_set_text(GTK_ENTRY(entry), hotCorner->upperRightSavedCommand); 279 | } else if (g_strcmp0(name, "LOWER_LEFT") == 0) { 280 | hotCorner->lowerLeftCommand = entry; 281 | gtk_entry_set_text(GTK_ENTRY(entry), hotCorner->lowerLeftSavedCommand); 282 | } else if (g_strcmp0(name, "LOWER_RIGHT") == 0) { 283 | hotCorner->lowerRightCommand = entry; 284 | gtk_entry_set_text(GTK_ENTRY(entry), hotCorner->lowerRightSavedCommand); 285 | } 286 | 287 | } 288 | 289 | static void on_combo_box_changed(GtkComboBox * comboBox, HotCorner * hotCorner) { 290 | 291 | const gchar * name = gtk_widget_get_name(GTK_WIDGET(comboBox)); 292 | if (g_strcmp0(name, "UPPER_LEFT") == 0) { 293 | ActionCallback callback = get_action_callback(comboBox, &(hotCorner->upperLeftActionID)); 294 | hotCorner->upperLeftCallback = callback; 295 | } else if (g_strcmp0(name, "UPPER_RIGHT") == 0) { 296 | ActionCallback callback = get_action_callback(comboBox, &(hotCorner->upperRightActionID)); 297 | hotCorner->upperRightCallback = callback; 298 | } else if (g_strcmp0(name, "LOWER_LEFT") == 0) { 299 | ActionCallback callback = get_action_callback(comboBox, &(hotCorner->lowerLeftActionID)); 300 | hotCorner->lowerLeftCallback = callback; 301 | } else if (g_strcmp0(name, "LOWER_RIGHT") == 0) { 302 | ActionCallback callback = get_action_callback(comboBox, &(hotCorner->lowerRightActionID)); 303 | hotCorner->lowerRightCallback = callback; 304 | } 305 | 306 | } 307 | 308 | static GtkWidget * createComboBox(const gchar *name, HotCorner * hotCorner, gint actionID) { 309 | 310 | GtkWidget * vbox = gtk_vbox_new(FALSE, 5); 311 | GtkWidget * entry = gtk_entry_new(); 312 | GtkWidget * comboBox = gtk_combo_box_text_new(); 313 | 314 | gtk_widget_set_name(comboBox, name); 315 | gtk_widget_set_name(entry, name); 316 | 317 | 318 | gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(comboBox), _("-")); 319 | gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(comboBox), _("Xfdashboard")); 320 | gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(comboBox), _("Show Desktop")); 321 | gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(comboBox), _("Start Screensaver")); 322 | gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(comboBox), _("Turn Off Monitor")); 323 | gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(comboBox), _("Custom Command")); 324 | 325 | gtk_combo_box_set_active(GTK_COMBO_BOX(comboBox), actionID); 326 | 327 | gint selected = gtk_combo_box_get_active(GTK_COMBO_BOX(comboBox)); 328 | set_new_entry_visibility(GTK_COMBO_BOX(comboBox), entry); 329 | 330 | gtk_box_pack_start(GTK_BOX(vbox), comboBox, TRUE, FALSE, TRUE); 331 | gtk_box_pack_start(GTK_BOX(vbox), entry, TRUE, FALSE, TRUE); 332 | 333 | set_corner_command_entry(entry, hotCorner); 334 | 335 | g_signal_connect (comboBox, "changed", G_CALLBACK(on_combo_box_changed), hotCorner); 336 | g_signal_connect (comboBox, "changed", G_CALLBACK(set_new_entry_visibility), entry); 337 | 338 | return vbox; 339 | } 340 | 341 | 342 | static GtkWidget * create_layout(HotCorner * hotCorner) { 343 | 344 | GtkWidget * vbox = gtk_vbox_new(FALSE, 10); 345 | GtkWidget * row1 = gtk_hbox_new(FALSE, 10); 346 | GtkWidget * row2 = gtk_hbox_new(FALSE, 10); 347 | GtkWidget * row3 = gtk_hbox_new(FALSE, 10); 348 | 349 | GtkWidget * upperLeftCombo = createComboBox("UPPER_LEFT", hotCorner, hotCorner->upperLeftActionID); 350 | GtkWidget * upperRightCombo = createComboBox("UPPER_RIGHT", hotCorner, hotCorner->upperRightActionID); 351 | GtkWidget * lowerLeftCombo = createComboBox("LOWER_LEFT", hotCorner, hotCorner->lowerLeftActionID); 352 | GtkWidget * lowerRightCombo = createComboBox("LOWER_RIGHT", hotCorner, hotCorner->lowerRightActionID); 353 | 354 | GtkWidget * emptyLabel = gtk_label_new(""); 355 | GtkWidget * monitorImage = gtk_image_new_from_icon_name("xfce4-display", GTK_ICON_SIZE_BUTTON); 356 | 357 | gtk_image_set_pixel_size(GTK_IMAGE(monitorImage), 256); 358 | 359 | gtk_box_pack_start(GTK_BOX(row1), upperLeftCombo, TRUE, FALSE, TRUE); 360 | gtk_box_pack_start(GTK_BOX(row1), emptyLabel, TRUE, FALSE, TRUE); 361 | gtk_box_pack_start(GTK_BOX(row1), upperRightCombo, TRUE, FALSE, TRUE); 362 | gtk_box_pack_start(GTK_BOX(vbox), row1, FALSE, FALSE, FALSE); 363 | 364 | gtk_box_pack_start(GTK_BOX(row2), emptyLabel, TRUE, FALSE, TRUE); 365 | gtk_box_pack_start(GTK_BOX(row2), monitorImage, TRUE, TRUE, TRUE); 366 | gtk_box_pack_start(GTK_BOX(row2), emptyLabel, TRUE, FALSE, TRUE); 367 | gtk_box_pack_start(GTK_BOX(vbox), row2, FALSE, FALSE, FALSE); 368 | 369 | gtk_box_pack_start(GTK_BOX(row3), lowerLeftCombo, TRUE, FALSE, TRUE); 370 | gtk_box_pack_start(GTK_BOX(row3), emptyLabel, TRUE, FALSE, TRUE); 371 | gtk_box_pack_start(GTK_BOX(row3), lowerRightCombo, TRUE, FALSE, TRUE); 372 | gtk_box_pack_start(GTK_BOX(vbox), row3, FALSE, FALSE, FALSE); 373 | 374 | return vbox; 375 | } 376 | 377 | static void on_close_configure_window(GtkWidget * dialog, gint response, HotCorner * hotCorner) { 378 | xfce_panel_plugin_unblock_menu(hotCorner->plugin); 379 | save_config_file(hotCorner->plugin, hotCorner); 380 | gtk_widget_destroy(dialog); 381 | } 382 | 383 | static void setFullScreenDisableFlag(GtkToggleButton *toggleButton, HotCorner * hotCorner) { 384 | hotCorner->disableWhenFullScreen = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggleButton)); 385 | } 386 | 387 | 388 | static void on_open_configure_window(XfcePanelPlugin * plugin, HotCorner * hotCorner) { 389 | 390 | xfce_panel_plugin_block_menu (plugin); 391 | GtkWidget * dialog = xfce_titled_dialog_new_with_buttons ( 392 | _("HotCorner"), 393 | GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (hotCorner->plugin))), 394 | GTK_DIALOG_DESTROY_WITH_PARENT, 395 | GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL 396 | ); 397 | 398 | GtkWidget * vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); 399 | GtkWidget * disableInFullScreenCheckbox = gtk_check_button_new_with_label(_("Disable when active window is full screen")); 400 | GtkWidget * content = create_layout(hotCorner); 401 | 402 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(disableInFullScreenCheckbox), hotCorner->disableWhenFullScreen); 403 | 404 | gtk_box_pack_start(GTK_BOX(vbox), content, TRUE, FALSE, TRUE); 405 | gtk_box_pack_start(GTK_BOX(vbox), disableInFullScreenCheckbox, TRUE, FALSE, TRUE); 406 | 407 | gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); 408 | gtk_window_set_icon_name (GTK_WINDOW (dialog), "xfce4-display"); 409 | 410 | g_signal_connect (dialog, "response", G_CALLBACK(on_close_configure_window), hotCorner); 411 | g_signal_connect (disableInFullScreenCheckbox, "toggled", G_CALLBACK(setFullScreenDisableFlag), hotCorner); 412 | 413 | gtk_widget_show_all(dialog); 414 | 415 | } 416 | 417 | 418 | static void on_screen_changed(GtkWidget * widget, GdkScreen * previous_screen, HotCorner * hotCorner) { 419 | set_monitor_size(hotCorner); 420 | } 421 | 422 | static void constructor(XfcePanelPlugin *plugin) { 423 | HotCorner * hotCorner = hotCorner_new(plugin); 424 | xfce_textdomain(GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); 425 | set_monitor_size(hotCorner); 426 | xfce_panel_plugin_menu_show_configure (plugin); 427 | 428 | 429 | GdkScreen * screen = gdk_screen_get_default(); 430 | g_signal_connect (plugin, "free-data", G_CALLBACK(free_data), hotCorner); 431 | g_signal_connect (plugin, "configure-plugin", G_CALLBACK(on_open_configure_window), hotCorner); 432 | g_signal_connect (screen, "monitors-changed", G_CALLBACK(on_screen_changed), hotCorner); 433 | g_signal_connect (plugin, "save", G_CALLBACK(save_config_file), hotCorner); 434 | 435 | 436 | read_config_file(plugin, hotCorner); 437 | 438 | xfce_panel_plugin_set_expand (XFCE_PANEL_PLUGIN(plugin), FALSE); 439 | 440 | } 441 | 442 | XFCE_PANEL_PLUGIN_REGISTER_INTERNAL(constructor); 443 | 444 | --------------------------------------------------------------------------------