File: x_picture.c

package info (click to toggle)
mlterm 2.9.4-5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 16,728 kB
  • ctags: 5,338
  • sloc: ansic: 74,649; sh: 8,532; cpp: 1,451; makefile: 1,126; perl: 496; sed: 16
file content (129 lines) | stat: -rw-r--r-- 1,770 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
 *	$Id: x_picture.c,v 1.8 2003/03/01 14:59:48 arakiken Exp $
 */

#include  "x_picture.h"

#include  <X11/Xatom.h>			/* XA_PIXMAP */
#include  <kiklib/kik_debug.h>

#include  "x_window.h"
#include  "x_imagelib.h"


/* --- global functions --- */

int
x_picture_display_opened(
	Display *  display
	)
{
	if( ! x_imagelib_display_opened( display))
	{
		return  0 ;
	}

	/* Want _XROOTPIAMP_ID changed events. */
	XSelectInput( display , DefaultRootWindow(display) , PropertyChangeMask) ;

	return  1 ;
}

int
x_picture_display_closed(
	Display *  display
	)
{
	return  x_imagelib_display_closed( display) ;
}

int
x_root_pixmap_available(
	Display *  display
	)
{
	return  x_imagelib_root_pixmap_available( display) ;
}
	
int
x_picture_init(
	x_picture_t *  pic ,
	x_window_t *  win ,
	x_picture_modifier_t *  mod
	)
{
	pic->pixmap = 0 ;
	pic->win = win ;
	pic->mod = mod ;

	return  1 ;
}

int
x_picture_final(
	x_picture_t *  pic
	)
{
	if( pic->pixmap)
	{
		XFreePixmap( pic->win->display , pic->pixmap) ;
	}

	return  1 ;
}

int
x_picture_load_file(
	x_picture_t *  pic ,
	char *  file_path
	)
{
	if( pic->pixmap)
	{
		/* already loaded */
		
		return  0 ;
	}
	pic->pixmap = x_imagelib_load_file_for_background( pic->win , file_path , pic->mod) ;
	if( pic->pixmap == None)
	{
		return  0 ;
	}
	
	return  1 ;
}

int
x_picture_load_background(
	x_picture_t *  pic
	)
{
	if( pic->pixmap)
	{
		/* already loaded */
		
		return  0 ;
	}

	if( ( pic->pixmap = x_imagelib_get_transparent_background( pic->win , pic->mod)) == None)
	{
		return  0 ;
	}

	return  1 ;
}

int
x_picture_modifier_is_normal(
	x_picture_modifier_t *  pic_mod
	)
{
	if( pic_mod->brightness == 100 && pic_mod->contrast == 100 && pic_mod->gamma == 100)
	{
		return  1 ;
	}
	else
	{
		return  0 ;
	}
}