40
40
unsigned long nItems, bytesAfter;
44
result = XGetWindowProperty (screen->dpy (), id, atom, 0L, 65536, False,
45
utf8StringAtom, &type, &format, &nItems,
46
&bytesAfter, (unsigned char **) &val);
44
int result = XGetWindowProperty (screen->dpy (), id, atom, 0L, 65536, False,
45
utf8StringAtom, &type, &format, &nItems,
46
&bytesAfter, (unsigned char **) &val);
48
48
if (result != Success)
75
if (XGetTextProperty (screen->dpy (), id, &text, atom))
76
if (XGetTextProperty (screen->dpy (), id, &text, atom) &&
79
char valueString[text.nitems + 1];
81
strncpy (valueString, (char *) text.value, text.nitems);
82
valueString[text.nitems] = 0;
79
char valueString[text.nitems + 1];
81
strncpy (valueString, (char *) text.value, text.nitems);
82
valueString[text.nitems] = 0;
94
93
PrivateTextScreen::getWindowName (Window id)
98
name = getUtf8Property (id, visibleNameAtom);
95
CompString name = getUtf8Property (id, visibleNameAtom);
100
97
if (name.empty ())
101
98
name = getUtf8Property (id, wmNameAtom);
112
109
* Draw a rounded rectangle path
115
TextSurface::drawBackground (int x,
112
TextSurface::drawBackground (int x,
123
const float halfPi = PI / 2.0f;
124
const float triHalfPi = halfPi * 3;
128
126
cairo_new_path (cr);
129
cairo_arc (cr, x0 + radius, y1 - radius, radius, PI / 2, PI);
127
cairo_arc (cr, x0 + radius, y1 - radius, radius, halfPi, PI);
130
128
cairo_line_to (cr, x0, y0 + radius);
131
cairo_arc (cr, x0 + radius, y0 + radius, radius, PI, 3 * PI / 2);
129
cairo_arc (cr, x0 + radius, y0 + radius, radius, PI, triHalfPi);
132
130
cairo_line_to (cr, x1 - radius, y0);
133
cairo_arc (cr, x1 - radius, y0 + radius, radius, 3 * PI / 2, 2 * PI);
131
cairo_arc (cr, x1 - radius, y0 + radius, radius, triHalfPi, 2 * PI);
134
132
cairo_line_to (cr, x1, y1 - radius);
135
cairo_arc (cr, x1 - radius, y1 - radius, radius, 0, PI / 2);
133
cairo_arc (cr, x1 - radius, y1 - radius, radius, 0, halfPi);
136
134
cairo_close_path (cr);
143
141
Display *dpy = screen->dpy ();
146
145
if (width > 0 && height > 0)
147
146
mPixmap = XCreatePixmap (dpy, screen->root (), width, height, 32);
202
202
TextSurface::render (const CompText::Attrib &attrib,
203
203
const CompString &text)
205
int width, height, layoutWidth;
210
208
pango_font_description_set_family (font, attrib.family);
211
pango_font_description_set_absolute_size (font,
212
attrib.size * PANGO_SCALE);
209
pango_font_description_set_absolute_size (font, attrib.size * PANGO_SCALE);
213
210
pango_font_description_set_style (font, PANGO_STYLE_NORMAL);
215
212
if (attrib.flags & CompText::StyleBold)
226
223
pango_layout_set_auto_dir (layout, false);
227
224
pango_layout_set_text (layout, text.c_str (), -1);
229
228
pango_layout_get_pixel_size (layout, &width, &height);
231
230
if (attrib.flags & CompText::WithBackground)
238
237
height = MIN (attrib.maxHeight, height);
240
239
/* update the size of the pango layout */
241
layoutWidth = attrib.maxWidth;
240
int layoutWidth = attrib.maxWidth;
242
242
if (attrib.flags & CompText::WithBackground)
243
243
layoutWidth -= 2 * attrib.bgHMargin;
413
CompText::renderWindowTitle (Window window,
414
bool withViewportNumber,
415
const CompText::Attrib &attrib)
413
CompText::renderWindowTitle (Window window,
414
bool withViewportNumber,
415
const CompText::Attrib &attrib)
417
TEXT_SCREEN (screen);
419
TEXT_SCREEN (screen);
424
424
if (withViewportNumber)
427
CompPoint winViewport;
428
CompSize viewportSize;
426
CompString title = ts->getWindowName (window);
430
title = ts->getWindowName (window);
431
428
if (!title.empty ())
430
CompWindow *w = screen->findWindow (window);
435
w = screen->findWindow (window);
434
CompPoint winViewport = w->defaultViewport ();
435
CompSize viewportSize = screen->vpSize ();
436
int viewport = winViewport.y () * viewportSize.width () +
437
winViewport.x () + 1;
440
winViewport = w->defaultViewport ();
441
viewportSize = screen->vpSize ();
442
viewport = winViewport.y () * viewportSize.width () +
443
winViewport.x () + 1;
444
439
text = compPrintf ("%s -[%d]-", title.c_str (), viewport);
454
446
text = ts->getWindowName (window);
457
448
if (text.empty ())
490
481
CompText::draw (const GLMatrix &transform,
495
GLint oldBlendSrc, oldBlendDst;
496
GLushort colorData[4];
497
GLfloat textureData[8];
498
GLfloat vertexData[12];
499
GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
501
486
if (texture.empty ())
489
GLint oldBlendSrc, oldBlendDst;
505
GLint oldBlendSrcAlpha, oldBlendDstAlpha;
491
GLint oldBlendSrcAlpha, oldBlendDstAlpha;
506
492
glGetIntegerv (GL_BLEND_SRC_RGB, &oldBlendSrc);
507
493
glGetIntegerv (GL_BLEND_DST_RGB, &oldBlendDst);
508
494
glGetIntegerv (GL_BLEND_SRC_ALPHA, &oldBlendSrcAlpha);
511
497
glGetIntegerv (GL_BLEND_SRC, &oldBlendSrc);
512
498
glGetIntegerv (GL_BLEND_DST, &oldBlendDst);
515
wasBlend = glIsEnabled (GL_BLEND);
500
GLboolean wasBlend = glIsEnabled (GL_BLEND);
517
503
glEnable (GL_BLEND);
520
506
glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
508
GLushort colorData[4];
509
GLfloat textureData[8];
510
GLfloat vertexData[12];
511
GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
514
GLfloat xPlusWidth = x + width;
515
GLfloat yMinusHeight = y - height;
522
517
colorData[0] = alpha * 65535;
523
518
colorData[1] = alpha * 65535;
524
519
colorData[2] = alpha * 65535;
525
520
colorData[3] = alpha * 65535;
527
for (unsigned int i = 0; i < texture.size (); i++)
522
for (unsigned int i = 0; i < texture.size (); ++i)
529
GLTexture *tex = texture[i];
530
GLTexture::Matrix m = tex->matrix ();
532
527
tex->enable (GLTexture::Good);
534
529
streamingBuffer->begin (GL_TRIANGLE_STRIP);
536
531
vertexData[0] = x;
537
vertexData[1] = y - height;
532
vertexData[1] = yMinusHeight;
538
533
vertexData[2] = 0;
539
534
vertexData[3] = x;
540
535
vertexData[4] = y;
541
536
vertexData[5] = 0;
542
vertexData[6] = x + width;
543
vertexData[7] = y - height;
537
vertexData[6] = xPlusWidth;
538
vertexData[7] = yMinusHeight;
544
539
vertexData[8] = 0;
545
vertexData[9] = x + width;
540
vertexData[9] = xPlusWidth;
546
541
vertexData[10] = y;
547
542
vertexData[11] = 0;
569
564
glBlendFuncSeparate (oldBlendSrc, oldBlendDst,
570
oldBlendSrcAlpha, oldBlendDstAlpha);
565
oldBlendSrcAlpha, oldBlendDstAlpha);
573
568
glDisable (GL_BLEND);
574
570
glBlendFunc (oldBlendSrc, oldBlendDst);
578
574
CompText::CompText () :
595
591
gScreen (GLScreen::get (screen))
597
593
visibleNameAtom = XInternAtom (screen->dpy (), "_NET_WM_VISIBLE_NAME", 0);
598
utf8StringAtom = XInternAtom (screen->dpy (), "UTF8_STRING", 0);
599
wmNameAtom = XInternAtom (screen->dpy (), "_NET_WM_NAME", 0);
594
utf8StringAtom = XInternAtom (screen->dpy (), "UTF8_STRING", 0);
595
wmNameAtom = XInternAtom (screen->dpy (), "_NET_WM_NAME", 0);
602
598
PrivateTextScreen::~PrivateTextScreen ()
607
603
TextPluginVTable::init ()
609
if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
613
p.uval = COMPIZ_TEXT_ABI;
614
screen->storeValue ("text_ABI", p);
605
if (CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
608
p.uval = COMPIZ_TEXT_ABI;
609
screen->storeValue ("text_ABI", p);