zarfy

Check-in [4529699034]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:add -m option to control map scaling. By default, map is now scaled by 0.1. You can change the scaling factor with this parameter. If you specify -m without parameter, zarfy will scale automatically (the original behaviour before this change)
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:4529699034b53f766b7611ab3bc5ce96e763f237
User & Date: jamesbond 2019-02-15 05:20:36
Context
2019-02-15
05:21
increase MAXCRTC to 32 check-in: cca781dccc user: jamesbond tags: trunk
05:20
add -m option to control map scaling. By default, map is now scaled by 0.1. You can change the scaling factor with this parameter. If you specify -m without parameter, zarfy will scale automatically (the original behaviour before this change) check-in: 4529699034 user: jamesbond tags: trunk
2014-08-31
18:52
increase MAXCRTC to 16 check-in: fc1593596b user: jamesbond tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/callbacks.c.

119
120
121
122
123
124
125



126
127
128
129
130
131
132
133
}

/* crtc map area clicked */
gint
map_click()
{
	int x, y;



	double scale= ( double )maxheight / ( double )map_da->allocation.height;

	if ( selected.crtc == NULL ) return FALSE;

/* once seen, get rid of tooltip so as not to annoy */
//	gtk_widget_set_has_tooltip ( map_da, FALSE );

	gdk_window_get_pointer(map_da->window, &x, &y, NULL);







>
>
>
|







119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
}

/* crtc map area clicked */
gint
map_click()
{
	int x, y;
	double scale = map_scale;

	if (scale == 0)
		scale= (double)(map_da->allocation.height) / (double)maxheight;

	if ( selected.crtc == NULL ) return FALSE;

/* once seen, get rid of tooltip so as not to annoy */
//	gtk_widget_set_has_tooltip ( map_da, FALSE );

	gdk_window_get_pointer(map_da->window, &x, &y, NULL);

Changes to src/draw.c.

161
162
163
164
165
166
167
168
169
170



171
172
173
174
175
176
177
}

void
draw_map()
{
	GdkPixbuf *screenshot, *ss_scaled;
	GdkColor white = WHITE;
	double scale= (double)(map_da->allocation.height) / (double)maxheight;
	int  i;




	clear_window(map_da, map_pm);

	/*  max screen area */
	gdk_gc_set_rgb_fg_color(draw_gc, &white);
	gdk_draw_rectangle(map_pm, draw_gc, TRUE, 0, 0, maxwidth*scale, maxheight*scale);

	/* actual screen area: draw scaled screenshot*/







|


>
>
>







161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
}

void
draw_map()
{
	GdkPixbuf *screenshot, *ss_scaled;
	GdkColor white = WHITE;
	double scale = map_scale;
	int  i;

	if (scale == 0)
		scale= (double)(map_da->allocation.height) / (double)maxheight;

	clear_window(map_da, map_pm);

	/*  max screen area */
	gdk_gc_set_rgb_fg_color(draw_gc, &white);
	gdk_draw_rectangle(map_pm, draw_gc, TRUE, 0, 0, maxwidth*scale, maxheight*scale);

	/* actual screen area: draw scaled screenshot*/

Changes to src/zarfy.c.

16
17
18
19
20
21
22


23
24
25
26
27
28
29
...
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
...
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
...
257
258
259
260
261
262
263





264
265
266
267
268
269
270
*    You should have received a copy of the GNU General Public License
*    along with zarfy.  If not, see <http://www.gnu.org/licenses/>.
*
*/

#include "zarfy.h"



void
bail (char *format, ...)
{
	va_list vl;
	va_start (vl, format);
	vfprintf (stderr, format, vl);
	va_end (vl);
................................................................................
		legend_da_pms[i] = gdk_pixmap_new(legend_da[i]->window,
											legend_da[i]->allocation.width,
											legend_da[i]->allocation.height, -1);

	gdkptr = gdk_cursor_new(GDK_LEFT_PTR);
	gdkhand = gdk_cursor_new(GDK_HAND2);

	sprintf( buf, "ZARFY\n\nVersion %s", VERSION );
	gtk_label_set_text ( about_lbl, buf );

	sprintf( buf, "Author %s\n%s", PACKAGE_AUTHOR, PACKAGE_BUGREPORT );
	gtk_label_set_text (credits_lbl, buf);

	for ( i=0; i<scres->noutput; i++ )
		if ( outputs[i]->connection == RR_Connected )
................................................................................
	rootwin = RootWindow (disp, screen);
	gdk_pixbuf_xlib_init (disp, screen); /* needed for screenshot */
}

void
usage()
{
	printf("Usage: zarfy [-l | -s] [-d display]\n");
	exit(1);
}

int
main(int argc, char **argv)
{
	int i, loadnexit=FALSE;
................................................................................
			switch_mode = TRUE;
		}
		else if ( !strcmp(argv[i], "-d") ) {
			if ( ++i < argc && argv[i][0] != '-' )
				display_name = argv[i];
			else
				usage();





		}
		else
			usage();
	}

	xrr_init();








>
>







 







|







 







|







 







>
>
>
>
>







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
...
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
...
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
...
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
*    You should have received a copy of the GNU General Public License
*    along with zarfy.  If not, see <http://www.gnu.org/licenses/>.
*
*/

#include "zarfy.h"

double map_scale = DEFAULT_MAP_SCALE;

void
bail (char *format, ...)
{
	va_list vl;
	va_start (vl, format);
	vfprintf (stderr, format, vl);
	va_end (vl);
................................................................................
		legend_da_pms[i] = gdk_pixmap_new(legend_da[i]->window,
											legend_da[i]->allocation.width,
											legend_da[i]->allocation.height, -1);

	gdkptr = gdk_cursor_new(GDK_LEFT_PTR);
	gdkhand = gdk_cursor_new(GDK_HAND2);

	sprintf( buf, "ZARFY\n\nVersion %s", VERSION_STRING);
	gtk_label_set_text ( about_lbl, buf );

	sprintf( buf, "Author %s\n%s", PACKAGE_AUTHOR, PACKAGE_BUGREPORT );
	gtk_label_set_text (credits_lbl, buf);

	for ( i=0; i<scres->noutput; i++ )
		if ( outputs[i]->connection == RR_Connected )
................................................................................
	rootwin = RootWindow (disp, screen);
	gdk_pixbuf_xlib_init (disp, screen); /* needed for screenshot */
}

void
usage()
{
	printf("Usage: zarfy [-l | -s] [-d display] [-m [scale]]\n");
	exit(1);
}

int
main(int argc, char **argv)
{
	int i, loadnexit=FALSE;
................................................................................
			switch_mode = TRUE;
		}
		else if ( !strcmp(argv[i], "-d") ) {
			if ( ++i < argc && argv[i][0] != '-' )
				display_name = argv[i];
			else
				usage();
		} if ( !strcmp(argv[i], "-m") ) {
			map_scale = 0; // use actual
			i++;
			if (i < argc)
				sscanf(argv[i],"%lf",&map_scale);
		}
		else
			usage();
	}

	xrr_init();

Changes to src/zarfy.h.

42
43
44
45
46
47
48

49
50
51
52
53
54
55
..
57
58
59
60
61
62
63

64
65
66
67
68
69
70
...
159
160
161
162
163
164
165

166
167
168
169
170
171
172
#include <dirent.h>
#include <errno.h>
#include <unistd.h>
#include <sys/time.h>
#include <signal.h>

#define PACKAGE_AUTHOR "J.S. Allingham"


#define MON_PIXMAP 			DATA_DIR "/monitor.png"
#define MON_SEL_PIXMAP 		DATA_DIR "/monitor_s.png"
#define MON_DESEL_PIXMAP 	DATA_DIR "/monitor_d.png"
#define GLADE_XML_ZARFY 	DATA_DIR "/zarfy.glade"
#define ZARFY_ICON			DATA_DIR "/zarfy.png"

................................................................................
#define MAXOUTPUT 10
#define IMAGE_WIDTH 70
#define IMAGE_HEIGHT 70
#define HEIGHT_ADJUST 22
#define SCREEN_WIDTH 62
#define WIDTH_ADJUST 7
#define MAP_HEIGHT 300


#define ROTATE_MASK (RR_Rotate_0 | RR_Rotate_90 | RR_Rotate_180 | RR_Rotate_270)
#define REFLECT_MASK (RR_Reflect_X | RR_Reflect_Y)

#define output_id(o) (scres->outputs[output_idx(o)])
#define crtc_id(c) (scres->crtcs[crtc_idx(c)])

................................................................................
/* zarfy.c */
void 				bail(char *, ...);
void 				*getmem	(size_t, size_t);
void 				get_glade_ptrs	(void);
void 				init_display(void);
void 				init_globals(void);
void				xsetup(void);


/* xrr.c */
void				apply(void);
void				apply_crtc(XRRCrtcInfo *);
void				apply_screen_size(void);
void 				cleanup	(void);
int					crtc_idx(XRRCrtcInfo *);







>







 







>







 







>







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
..
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
...
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#include <dirent.h>
#include <errno.h>
#include <unistd.h>
#include <sys/time.h>
#include <signal.h>

#define PACKAGE_AUTHOR "J.S. Allingham"
#define VERSION_STRING (VERSION "-2019.02-james")

#define MON_PIXMAP 			DATA_DIR "/monitor.png"
#define MON_SEL_PIXMAP 		DATA_DIR "/monitor_s.png"
#define MON_DESEL_PIXMAP 	DATA_DIR "/monitor_d.png"
#define GLADE_XML_ZARFY 	DATA_DIR "/zarfy.glade"
#define ZARFY_ICON			DATA_DIR "/zarfy.png"

................................................................................
#define MAXOUTPUT 10
#define IMAGE_WIDTH 70
#define IMAGE_HEIGHT 70
#define HEIGHT_ADJUST 22
#define SCREEN_WIDTH 62
#define WIDTH_ADJUST 7
#define MAP_HEIGHT 300
#define DEFAULT_MAP_SCALE 0.1

#define ROTATE_MASK (RR_Rotate_0 | RR_Rotate_90 | RR_Rotate_180 | RR_Rotate_270)
#define REFLECT_MASK (RR_Reflect_X | RR_Reflect_Y)

#define output_id(o) (scres->outputs[output_idx(o)])
#define crtc_id(c) (scres->crtcs[crtc_idx(c)])

................................................................................
/* zarfy.c */
void 				bail(char *, ...);
void 				*getmem	(size_t, size_t);
void 				get_glade_ptrs	(void);
void 				init_display(void);
void 				init_globals(void);
void				xsetup(void);
extern double		map_scale;

/* xrr.c */
void				apply(void);
void				apply_crtc(XRRCrtcInfo *);
void				apply_screen_size(void);
void 				cleanup	(void);
int					crtc_idx(XRRCrtcInfo *);