1 /* GKrellM
2 | Copyright (C) 1999-2019 Bill Wilson
3 |
4 | Author: Bill Wilson billw@gkrellm.net
5 | Latest versions might be found at: http://gkrellm.net
6 |
7 |
8 | GKrellM is free software: you can redistribute it and/or modify it
9 | under the terms of the GNU General Public License as published by
10 | the Free Software Foundation, either version 3 of the License, or
11 | (at your option) any later version.
12 |
13 | GKrellM is distributed in the hope that it will be useful, but WITHOUT
14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 | License for more details.
17 |
18 | You should have received a copy of the GNU General Public License
19 | along with this program. If not, see http://www.gnu.org/licenses/
20 |
21 |
22 | Additional permission under GNU GPL version 3 section 7
23 |
24 | If you modify this program, or any covered work, by linking or
25 | combining it with the OpenSSL project's OpenSSL library (or a
26 | modified version of that library), containing parts covered by
27 | the terms of the OpenSSL or SSLeay licenses, you are granted
28 | additional permission to convey the resulting work.
29 | Corresponding Source for a non-source form of such a combination
30 | shall include the source code for the parts of OpenSSL used as well
31 | as that of the covered work.
32 */
33
34 #include "gkrellm.h"
35 #include "gkrellm-private.h"
36
37 #include <errno.h>
38 #if !defined(F_TLOCK)
39 #include <sys/file.h>
40 #endif
41
42 #include <pwd.h>
43 #include <sys/types.h>
44
45
46 static FILE *f_lock;
47
48 static gboolean
_gkrellm_get_lock(void)49 _gkrellm_get_lock(void)
50 {
51 gchar *lock_dir, *lock_file; //, *display, *s;
52 gchar buf[32];
53
54 snprintf(buf, sizeof(buf), "LCK..%d", (gint) getuid());
55
56 #if defined(F_TLOCK)
57 lock_dir = "/var/lock/gkrellm";
58 if (!g_file_test(lock_dir, G_FILE_TEST_IS_DIR))
59 mkdir(lock_dir, 0755);
60
61 lock_file = gkrellm_make_config_file_name(lock_dir, buf);
62 /*display = XDisplayName(NULL);
63 if (display)
64 {
65 s = g_strconcat(lock_file, "_", display, NULL);
66 g_free(lock_file);
67 lock_file = s;
68 }*/
69 f_lock = fopen(lock_file, "w+"); /* buffering does not apply here */
70 g_free(lock_file);
71 if ( f_lock
72 && lockf(fileno(f_lock), F_TLOCK, 0) != 0
73 && errno == EAGAIN
74 )
75 return FALSE;
76 if (f_lock)
77 {
78 fprintf(f_lock, "%10d\n", (gint) getpid());
79 fflush(f_lock);
80 }
81 #endif
82 return TRUE;
83 }
84
85
86
87
88 void
gkrellm_winop_reset(void)89 gkrellm_winop_reset(void)
90 {
91 }
92
93 void
gkrellm_winop_state_skip_taskbar(gboolean state)94 gkrellm_winop_state_skip_taskbar(gboolean state)
95 {
96 gdk_window_set_skip_taskbar_hint(gkrellm_get_top_window()->window, state);
97 }
98
99 void
gkrellm_winop_state_skip_pager(gboolean state)100 gkrellm_winop_state_skip_pager(gboolean state)
101 {
102 gdk_window_set_skip_pager_hint(gkrellm_get_top_window()->window, state);
103 }
104
105 void
gkrellm_winop_state_above(gboolean state)106 gkrellm_winop_state_above(gboolean state)
107 {
108 gdk_window_set_keep_above(gkrellm_get_top_window()->window, state);
109 }
110
111 void
gkrellm_winop_state_below(gboolean state)112 gkrellm_winop_state_below(gboolean state)
113 {
114 gdk_window_set_keep_below(gkrellm_get_top_window()->window, state);
115 }
116
117 void
gkrellm_winop_update_struts(void)118 gkrellm_winop_update_struts(void)
119 {
120 }
121
122 void
gkrellm_winop_options(gint argc,gchar ** argv)123 gkrellm_winop_options(gint argc, gchar **argv)
124 {
125 gint n = 0;
126
127 if ( !_GK.allow_multiple_instances_real
128 && !_GK.force_host_config
129 && !_gkrellm_get_lock()
130 )
131 {
132 g_message("gkrellm: %s\n",
133 _("Exiting because multiple instances option is off.\n"));
134 exit(0);
135 }
136 }
137
138 void
gkrellm_winop_withdrawn(void)139 gkrellm_winop_withdrawn(void)
140 {
141 }
142
143 /* Use XParseGeometry, but width and height are ignored.
144 | If GKrellM is moved, update _GK.y_position.
145 */
146 void
gkrellm_winop_place_gkrellm(gchar * geom)147 gkrellm_winop_place_gkrellm(gchar *geom)
148 {
149 /*gint place, x, y, w_gkrell, h_gkrell;
150
151 x = y = 0;
152 place = XParseGeometry(geom, &x, &y,
153 (guint *) &w_gkrell, (guint *) &h_gkrell);
154
155 w_gkrell = _GK.chart_width + _GK.frame_left_width + _GK.frame_right_width;
156 h_gkrell = _GK.monitor_height + _GK.total_frame_height;
157
158 if (place & YNegative)
159 y = _GK.h_display - h_gkrell + y;
160 if (place & XNegative)
161 x = _GK.w_display - w_gkrell + x;
162 gdk_window_move(gkrellm_get_top_window()->window, x, y);
163 _GK.y_position = y;
164 _GK.x_position = x;
165 _GK.position_valid = TRUE;
166 gkrellm_debug(DEBUG_POSITION, "geometry moveto %d %d\n", x, y);
167 */
168 }
169
170 void
gkrellm_winop_flush_motion_events(void)171 gkrellm_winop_flush_motion_events(void)
172 {
173 }
174
175 /* Check if background has changed
176 */
177 gboolean
gkrellm_winop_updated_background(void)178 gkrellm_winop_updated_background(void)
179 {
180 return TRUE;
181 }
182
183 gboolean
gkrellm_winop_draw_rootpixmap_onto_transparent_chart(GkrellmChart * cp)184 gkrellm_winop_draw_rootpixmap_onto_transparent_chart(GkrellmChart *cp)
185 {
186 return FALSE;
187 }
188
189 gboolean
gkrellm_winop_draw_rootpixmap_onto_transparent_panel(GkrellmPanel * p)190 gkrellm_winop_draw_rootpixmap_onto_transparent_panel(GkrellmPanel *p)
191 {
192 return FALSE;
193 }
194
195 void
gkrellm_winop_apply_rootpixmap_transparency(void)196 gkrellm_winop_apply_rootpixmap_transparency(void)
197 {
198 }
199