378
378
/* Draws a box from the screen coordinates inx1,iny1 to inx2,iny2 */
380
380
EZoomScreen::drawBox (const GLMatrix &transform,
384
GLMatrix zTransform = transform;
386
int inx1, inx2, iny1, iny2;
387
int out = output->id ();
384
GLMatrix zTransform (transform);
386
int inx1, inx2, iny1, iny2;
387
int out = output->id ();
388
GLushort colorData[4];
389
GLfloat vertexData[12];
390
GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
389
392
zTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
390
393
convertToZoomed (out, box.x1 (), box.y1 (), &inx1, &iny1);
394
397
y1 = MIN (iny1, iny2);
395
398
x2 = MAX (inx1, inx2);
396
399
y2 = MAX (iny1, iny2);
398
glLoadMatrixf (zTransform.getMatrix ());
399
glDisableClientState (GL_TEXTURE_COORD_ARRAY);
401
glColor4us (0x2fff, 0x2fff, 0x4fff, 0x4fff);
402
glRecti (x1,y2,x2,y1);
403
glColor4us (0x2fff, 0x2fff, 0x4fff, 0x9fff);
404
glBegin (GL_LINE_LOOP);
410
glColor4usv (defaultColor);
411
glDisable (GL_BLEND);
412
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
401
streamingBuffer->begin (GL_TRIANGLE_STRIP);
403
colorData[0] = 0x2fff;
404
colorData[1] = 0x2fff;
405
colorData[2] = 0x2fff;
406
colorData[3] = 0x4fff;
408
streamingBuffer->addColors (1, colorData);
412
vertexData[2] = 0.0f;
415
vertexData[5] = 0.0f;
418
vertexData[8] = 0.0f;
421
vertexData[11] = 0.0f;
423
streamingBuffer->addVertices (4, vertexData);
425
streamingBuffer->end ();
426
streamingBuffer->render (zTransform);
429
streamingBuffer->begin (GL_LINE_LOOP);
431
colorData[0] = 0x2fff;
432
colorData[1] = 0x2fff;
433
colorData[2] = 0x4fff;
434
colorData[3] = 0x9fff;
436
streamingBuffer->addColors (1, colorData);
440
vertexData[2] = 0.0f;
443
vertexData[5] = 0.0f;
446
vertexData[8] = 0.0f;
449
vertexData[11] = 0.0f;
451
streamingBuffer->addVertices (4, vertexData);
453
streamingBuffer->end ();
454
streamingBuffer->render (zTransform);
415
456
/* Apply the zoom if we are grabbed.
416
457
* Make sure to use the correct filter.
1051
1092
/* Translate into place and draw the scaled cursor. */
1053
EZoomScreen::drawCursor (CompOutput *output,
1054
const GLMatrix &transform)
1094
EZoomScreen::drawCursor (CompOutput *output,
1095
const GLMatrix &transform)
1056
int out = output->id ();
1097
int out = output->id ();
1058
1099
if (cursor.isSet)
1060
GLMatrix sTransform = transform;
1101
GLMatrix sTransform (transform);
1104
GLfloat textureData[8];
1105
GLfloat vertexData[12];
1106
GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
1065
1109
* XXX: expo knows how to handle mouse when zoomed, so we back off
1066
1110
* when expo is active.
1068
if (screen->grabExist ( "expo"))
1112
if (screen->grabExist ("expo"))
1070
1114
cursorZoomInactive ();
1074
1118
sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
1075
1119
convertToZoomed (out, mouse.x (), mouse.y (), &ax, &ay);
1077
glLoadMatrixf (sTransform.getMatrix ());
1078
glTranslatef ((float) ax, (float) ay, 0.0f);
1120
sTransform.translate ((float) ax, (float) ay, 0.0f);
1079
1122
if (optionGetScaleMouseDynamic ())
1080
1123
scaleFactor = 1.0f / zooms.at (out).currentZoom;
1082
1125
scaleFactor = 1.0f / optionGetScaleMouseStatic ();
1083
glScalef (scaleFactor,
1127
sTransform.scale (scaleFactor, scaleFactor, 1.0f);
1086
1128
x = -cursor.hotX;
1087
1129
y = -cursor.hotY;
1089
glEnable (GL_BLEND);
1090
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, cursor.texture);
1091
glEnable (GL_TEXTURE_RECTANGLE_ARB);
1094
glTexCoord2d (0, 0);
1096
glTexCoord2d (0, cursor.height);
1097
glVertex2f (x, y + cursor.height);
1098
glTexCoord2d (cursor.width, cursor.height);
1099
glVertex2f (x + cursor.width, y + cursor.height);
1100
glTexCoord2d (cursor.width, 0);
1101
glVertex2f (x + cursor.width, y);
1103
glDisable (GL_BLEND);
1104
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
1105
glDisable (GL_TEXTURE_RECTANGLE_ARB);
1131
glBindTexture (GL_TEXTURE_2D, cursor.texture);
1133
streamingBuffer->begin (GL_TRIANGLE_STRIP);
1137
vertexData[2] = 0.0f;
1139
vertexData[4] = y + cursor.height;
1140
vertexData[5] = 0.0f;
1141
vertexData[6] = x + cursor.width;
1143
vertexData[8] = 0.0f;
1144
vertexData[9] = x + cursor.width;
1145
vertexData[10] = y + cursor.height;
1146
vertexData[11] = 0.0f;
1148
streamingBuffer->addVertices (4, vertexData);
1153
textureData[3] = cursor.height;
1154
textureData[4] = cursor.width;
1156
textureData[6] = cursor.width;
1157
textureData[7] = cursor.height;
1159
streamingBuffer->addTexCoords (1, 4, textureData);
1161
streamingBuffer->end ();
1162
streamingBuffer->render (sTransform);
1164
glBindTexture (GL_TEXTURE_2D, 0);
1110
1168
/* Create (if necessary) a texture to store the cursor,
1111
1169
* fetch the cursor with XFixes. Store it. */
1113
EZoomScreen::updateCursor (CursorTexture * cursor)
1171
EZoomScreen::updateCursor (CursorTexture *cursor)
1115
1173
unsigned char *pixels;
1117
1175
Display *dpy = screen->dpy ();
1119
1177
if (!cursor->isSet)
1121
1179
cursor->isSet = true;
1122
1180
cursor->screen = screen;
1123
glEnable (GL_TEXTURE_RECTANGLE_ARB);
1182
glEnable (GL_TEXTURE_2D);
1124
1183
glGenTextures (1, &cursor->texture);
1125
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, cursor->texture);
1184
glBindTexture (GL_TEXTURE_2D, cursor->texture);
1127
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB,
1128
GL_TEXTURE_WRAP_S, GL_CLAMP);
1129
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB,
1130
GL_TEXTURE_WRAP_T, GL_CLAMP);
1132
glEnable (GL_TEXTURE_RECTANGLE_ARB);
1186
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1187
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1190
glEnable (GL_TEXTURE_2D);
1135
1193
XFixesCursorImage *ci = XFixesGetCursorImage (dpy);
1185
1243
compLogMessage ("ezoom", CompLogLevelWarn, "unable to get system cursor image!");
1188
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, cursor->texture);
1189
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, cursor->width,
1246
glBindTexture (GL_TEXTURE_2D, cursor->texture);
1247
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, cursor->width,
1190
1248
cursor->height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pixels);
1191
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
1192
glDisable (GL_TEXTURE_RECTANGLE_ARB);
1249
glBindTexture (GL_TEXTURE_2D, 0);
1250
glDisable (GL_TEXTURE_2D);