88
90
} ScaleFilterScreen;
90
92
#define GET_FILTER_DISPLAY(d) \
91
((ScaleFilterDisplay *) (d)->privates[displayPrivateIndex].ptr)
93
((ScaleFilterDisplay *) (d)->base.privates[displayPrivateIndex].ptr)
93
95
#define FILTER_DISPLAY(d) \
94
96
ScaleFilterDisplay *fd = GET_FILTER_DISPLAY (d)
96
98
#define GET_FILTER_SCREEN(s, fd) \
97
((ScaleFilterScreen *) (s)->privates[(fd)->screenPrivateIndex].ptr)
99
((ScaleFilterScreen *) (s)->base.privates[(fd)->screenPrivateIndex].ptr)
99
#define FILTER_SCREEN(s) \
100
ScaleFilterScreen *fs = GET_FILTER_SCREEN (s, GET_FILTER_DISPLAY (s->display))
101
#define FILTER_SCREEN(s) \
102
ScaleFilterScreen *fs = GET_FILTER_SCREEN (s, \
103
GET_FILTER_DISPLAY (s->display))
103
106
scalefilterFreeFilterText (CompScreen *s)
160
164
if (fs->filterInfo->filterStringLength == 0)
163
tA.maxwidth = x2 - x1 - (2 * scalefilterGetBorderSize (s));
164
tA.maxheight = y2 - y1 - (2 * scalefilterGetBorderSize (s));
167
if (!fd->textAvailable)
170
tA.maxWidth = x2 - x1 - (2 * scalefilterGetBorderSize (s));
171
tA.maxHeight = y2 - y1 - (2 * scalefilterGetBorderSize (s));
166
173
tA.size = scalefilterGetFontSize (s);
167
174
tA.color[0] = scalefilterGetFontColorRed (s);
221
228
FILTER_SCREEN (s);
224
GLint oldBlendSrc, oldBlendDst;
225
int ox1, ox2, oy1, oy2;
231
GLint oldBlendSrc, oldBlendDst;
233
int ox1, ox2, oy1, oy2;
234
float width, height, border;
227
float width = fs->filterInfo->textWidth;
228
float height = fs->filterInfo->textHeight;
229
float border = scalefilterGetBorderSize (s);
238
width = fs->filterInfo->textWidth;
239
height = fs->filterInfo->textHeight;
240
border = scalefilterGetBorderSize (s);
231
242
ox1 = output->region.extents.x1;
232
243
ox2 = output->region.extents.x2;
233
244
oy1 = output->region.extents.y1;
234
245
oy2 = output->region.extents.y2;
235
float x = ox1 + ((ox2 - ox1) / 2) - (width / 2);
236
float y = oy1 + ((oy2 - oy1) / 2) + (height / 2);
247
x = floor (ox1 + ((ox2 - ox1) / 2) - (width / 2));
248
y = floor (oy1 + ((oy2 - oy1) / 2) + (height / 2));
241
250
wasBlend = glIsEnabled (GL_BLEND);
242
251
glGetIntegerv (GL_BLEND_SRC, &oldBlendSrc);
265
274
#define CORNER(a,b) \
266
275
for (k = a; k < b; k++) \
268
float rad = k* (3.14159 / 180.0f);\
277
float rad = k * (3.14159 / 180.0f);\
269
278
glVertex2f (0.0f, 0.0f);\
270
279
glVertex2f (cos (rad) * border, sin (rad) * border);\
271
280
glVertex2f (cos ((k - 1) * (3.14159 / 180.0f)) * border, \
305
312
enableTexture (s, &fs->filterInfo->textTexture, COMP_TEXTURE_FILTER_GOOD);
307
CompMatrix *m = &fs->filterInfo->textTexture.matrix;
314
m = &fs->filterInfo->textTexture.matrix;
309
316
glBegin (GL_QUADS);
311
glTexCoord2f (COMP_TEX_COORD_X(m, 0),COMP_TEX_COORD_Y(m ,0));
318
glTexCoord2f (COMP_TEX_COORD_X (m, 0), COMP_TEX_COORD_Y (m ,0));
312
319
glVertex2f (x, y - height);
313
glTexCoord2f (COMP_TEX_COORD_X(m, 0),COMP_TEX_COORD_Y(m, height));
320
glTexCoord2f (COMP_TEX_COORD_X (m, 0), COMP_TEX_COORD_Y (m, height));
314
321
glVertex2f (x, y);
315
glTexCoord2f (COMP_TEX_COORD_X(m, width),COMP_TEX_COORD_Y(m, height));
322
glTexCoord2f (COMP_TEX_COORD_X (m, width), COMP_TEX_COORD_Y (m, height));
316
323
glVertex2f (x + width, y);
317
glTexCoord2f (COMP_TEX_COORD_X(m, width),COMP_TEX_COORD_Y(m, 0));
324
glTexCoord2f (COMP_TEX_COORD_X (m, width), COMP_TEX_COORD_Y (m, 0));
318
325
glVertex2f (x + width, y - height);
385
392
scalefilterInitFilterInfo (CompScreen *s)
394
ScaleFilterInfo *info;
387
396
FILTER_SCREEN (s);
388
397
SCALE_SCREEN (s);
390
ScaleFilterInfo *info = fs->filterInfo;
399
info = fs->filterInfo;
392
400
memset (info->filterString, 0, sizeof (info->filterString));
393
401
info->filterStringLength = 0;
632
640
matchInit (&fs->scaleMatch);
633
641
matchCopy (&fs->scaleMatch, ss->currentMatch);
634
642
matchUpdate (d, &fs->scaleMatch);
635
fs->matchApplied = FALSE;
644
else if (fs->filterInfo)
642
ss->currentMatch = fs->filterInfo->origMatch;
643
scalefilterFiniFilterInfo (s, TRUE);
645
fs->matchApplied = FALSE;
646
ss->currentMatch = fs->filterInfo->origMatch;
647
scalefilterFiniFilterInfo (s, TRUE);
650
fs->matchApplied = FALSE;
740
744
scalefilterInitDisplay (CompPlugin *p,
743
747
ScaleFilterDisplay *fd;
744
CompPlugin *scale = findActivePlugin ("scale");
748
if (!scale || !scale->vTable->getDisplayOptions)
751
option = (*scale->vTable->getDisplayOptions) (scale, d, &nOption);
753
if (getIntOptionNamed (option, nOption, "abi", 0) != SCALE_ABIVERSION)
755
compLogMessage (d, "scalefilter", CompLogLevelError,
756
"scale ABI version mismatch");
760
scaleDisplayPrivateIndex = getIntOptionNamed (option, nOption, "index", -1);
761
if (scaleDisplayPrivateIndex < 0)
749
if (!checkPluginABI ("core", CORE_ABIVERSION))
752
if (!checkPluginABI ("scale", SCALE_ABIVERSION))
755
if (!getPluginDisplayIndex (d, "scale", &scaleDisplayPrivateIndex))
764
758
fd = malloc (sizeof (ScaleFilterDisplay));
786
780
setlocale (LC_CTYPE, "");
782
fd->textAvailable = checkPluginABI ("text", TEXT_ABIVERSION);
783
if (!fd->textAvailable)
784
compLogMessage (d, "scalefilter", CompLogLevelWarn,
785
"No compatible text plugin found.");
788
787
WRAP (fd, d, handleEvent, scalefilterHandleEvent);
789
788
WRAP (fd, d, handleCompizEvent, scalefilterHandleCompizEvent);
791
d->privates[displayPrivateIndex].ptr = fd;
790
d->base.privates[displayPrivateIndex].ptr = fd;
838
837
scalefilterSetFontColorNotify (s, scalefilterScreenOptionChanged);
839
838
scalefilterSetBackColorNotify (s, scalefilterScreenOptionChanged);
841
s->privates[fd->screenPrivateIndex].ptr = fs;
840
s->base.privates[fd->screenPrivateIndex].ptr = fs;
847
846
scalefilterFiniScreen (CompPlugin *p,
850
849
FILTER_SCREEN (s);
851
850
SCALE_SCREEN (s);
865
scalefilterInitObject (CompPlugin *p,
868
static InitPluginObjectProc dispTab[] = {
869
(InitPluginObjectProc) 0, /* InitCore */
870
(InitPluginObjectProc) scalefilterInitDisplay,
871
(InitPluginObjectProc) scalefilterInitScreen
874
RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o));
878
scalefilterFiniObject (CompPlugin *p,
881
static FiniPluginObjectProc dispTab[] = {
882
(FiniPluginObjectProc) 0, /* FiniCore */
883
(FiniPluginObjectProc) scalefilterFiniDisplay,
884
(FiniPluginObjectProc) scalefilterFiniScreen
887
DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o));
866
891
scalefilterInit (CompPlugin *p)