[beryl-commits] r2250 - branches/beryl-plugins/group-tabbed
marex at server.beryl-project.org
marex at server.beryl-project.org
Tue Jan 2 03:51:49 CET 2007
Author: marex
Date: 2007-01-02 02:51:48 +0000 (Tue, 02 Jan 2007)
New Revision: 2250
Modified:
branches/beryl-plugins/group-tabbed/group.c
branches/beryl-plugins/group-tabbed/group.h
branches/beryl-plugins/group-tabbed/paint.c
branches/beryl-plugins/group-tabbed/tab.c
Log:
group-tab-branch: A lot of fixes and polish...
* fixed bug with dragging
* fixed tab bar calucaltion
* fixed cairo texture drawing
* fixed shorten of the window title
Modified: branches/beryl-plugins/group-tabbed/group.c
===================================================================
--- branches/beryl-plugins/group-tabbed/group.c 2007-01-02 01:12:22 UTC (rev 2249)
+++ branches/beryl-plugins/group-tabbed/group.c 2007-01-02 02:51:48 UTC (rev 2250)
@@ -532,9 +532,9 @@
for (slot = group->tabBar->slots; slot; slot = slot->next) {
if (XPointInRegion (slot->region, event->xbutton.x_root,
event->xbutton.y_root)) {
- if (group->topTab == slot) {
+ if (group->topTab == slot) // start drag
group->tabBar->draggedSlot = slot;
- } else
+ else
groupChangeTab(slot);
}
}
@@ -602,11 +602,9 @@
int middle = slot->region->extents.x1 + ((slot->region->extents.x2 - slot->region->extents.x1) / 2);
groupUnhookTabBarSlot(group->tabBar, group->tabBar->draggedSlot);
if(middle > mouseX)
- {
groupInsertTabBarSlotBefore(group->tabBar, group->tabBar->draggedSlot, slot);
- } else {
+ else
groupInsertTabBarSlotAfter(group->tabBar, group->tabBar->draggedSlot, slot);
- }
}
}
group->tabBar->draggedSlot = NULL;
Modified: branches/beryl-plugins/group-tabbed/group.h
===================================================================
--- branches/beryl-plugins/group-tabbed/group.h 2007-01-02 01:12:22 UTC (rev 2249)
+++ branches/beryl-plugins/group-tabbed/group.h 2007-01-02 02:51:48 UTC (rev 2250)
@@ -449,6 +449,8 @@
void groupDrawTabAnimation(CompScreen * s);
Bool groupUpdateTabBars(void* display);
void groupGetCurrentMousePosition(CompDisplay *d, int *x, int *y);
+void groupRebuildCairoContext(GroupSelection *group);
+void groupDestroyCairoContext(GroupSelection *group, CompScreen *s);
void groupCreateCairoContext(GroupSelection *group, CompScreen *s);
void groupClearCairoContext(GroupCairoContext *cc);
void groupRecalcTabBarPos(GroupSelection *group, int middleX, int minX1, int maxX2);
Modified: branches/beryl-plugins/group-tabbed/paint.c
===================================================================
--- branches/beryl-plugins/group-tabbed/paint.c 2007-01-02 01:12:22 UTC (rev 2249)
+++ branches/beryl-plugins/group-tabbed/paint.c 2007-01-02 02:51:48 UTC (rev 2250)
@@ -123,6 +123,33 @@
}
/*
+ * groupShortWindowTitle
+ *
+ */
+static char* groupShortWindowTitle(char* title, int max)
+{
+ char *ret = malloc((max+1) * sizeof(char));
+
+ Bool shortIt = TRUE;
+ int i;
+ for(i = 0; i < max; i++){
+ if (title[i] == '\0') {
+ shortIt = FALSE;
+ }
+ ret[i] = title[i];
+ }
+
+ if (shortIt) {
+ ret[max-3] = '.';
+ ret[max-2] = '.';
+ ret[max-1] = '.';
+ ret[max] = '\0';
+ }
+
+ return ret;
+}
+
+/*
* groupRenderWindowTitle
*
*/
@@ -136,12 +163,19 @@
if (!group->tabBar || !group->topTab || !group->tabBar->cc || !group->tabBar->cc->cairo)
return;
- groupClearCairoContext(group->tabBar->cc);
+ // we have to rebuild it here..
+ // which means we get a complete new context
+ groupRebuildCairoContext(group);
+ int w, h;
+ w = group->tabBar->region->extents.x2 - group->tabBar->region->extents.x1;
+ h = group->tabBar->region->extents.y2 - group->tabBar->region->extents.y1;
+
bar = group->tabBar;
cr = group->tabBar->cc->cairo;
- cairo_set_line_width(cr, 1);
+ cairo_set_antialias(cr, CAIRO_ANTIALIAS_DEFAULT);
+ cairo_set_line_width(cr, 2);
cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f);
cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
@@ -150,18 +184,16 @@
cairo_text_extents(cr, group->topTab->name, &extents);
cairo_save(cr);
- cairo_move_to(cr, 20, 20);
- cairo_text_path(cr, group->topTab->name);
+ cairo_move_to(cr, 5, h - 10);
+ char *shortedTitle = groupShortWindowTitle(group->topTab->name, w/7);
+ cairo_text_path(cr, shortedTitle);
+ free(shortedTitle);
cairo_fill_preserve(cr);
- cairo_set_source_rgba(cr, 1.0f, 0.0f, 0.0f, 1.0f);
+ cairo_set_source_rgba(cr, 0.0f, 0.0f, 0.0f, 0.0f);
cairo_stroke(cr);
cairo_restore(cr);
- int w, h;
- w = group->tabBar->region->extents.x2 - group->tabBar->region->extents.x1;
- h = group->tabBar->region->extents.y2 - group->tabBar->region->extents.y1;
-
glEnable(GL_TEXTURE_RECTANGLE_ARB);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, group->tabBar->cc->texture);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, group->tabBar->cc->texBuf);
@@ -264,14 +296,14 @@
glEnable(GL_TEXTURE_RECTANGLE_ARB);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, group->tabBar->cc->texture);
glBegin(GL_QUADS);
+ glTexCoord2i(0, height);
+ glVertex2i(group->tabBar->region->extents.x1, group->tabBar->region->extents.y2);
+ glTexCoord2i(width, height);
+ glVertex2i(group->tabBar->region->extents.x2, group->tabBar->region->extents.y2);
+ glTexCoord2i(width, 0);
+ glVertex2i(group->tabBar->region->extents.x2, group->tabBar->region->extents.y1);
glTexCoord2i(0, 0);
glVertex2i(group->tabBar->region->extents.x1, group->tabBar->region->extents.y1);
- glTexCoord2i(width, 0);
- glVertex2i(group->tabBar->region->extents.x2, group->tabBar->region->extents.y1);
- glTexCoord2i(width, height);
- glVertex2i(group->tabBar->region->extents.x2, group->tabBar->region->extents.y2);
- glTexCoord2i(0, height);
- glVertex2i(group->tabBar->region->extents.x1, group->tabBar->region->extents.y2);
glEnd();
glDisable(GL_TEXTURE_RECTANGLE_ARB);
Modified: branches/beryl-plugins/group-tabbed/tab.c
===================================================================
--- branches/beryl-plugins/group-tabbed/tab.c 2007-01-02 01:12:22 UTC (rev 2249)
+++ branches/beryl-plugins/group-tabbed/tab.c 2007-01-02 02:51:48 UTC (rev 2250)
@@ -103,12 +103,8 @@
if(!bar)
return;
- if (bar->state == TabBarPermanentOn) {
- if (bar->draggedSlot)
- groupPaintThumb(group, bar->draggedSlot);
- else
- return;
- }
+ if (bar->state == TabBarPermanentOn)
+ return;
if (mask & KEEP_BAR_VISIBILITY_MASK) {
bar->state = TabBarPermanentOn;
@@ -590,6 +586,17 @@
}
/*
+ * groupRebuildCairoContext
+ *
+ */
+void groupRebuildCairoContext(GroupSelection *group)
+{
+ CompScreen *s = TOP_TAB(group)->screen;
+ groupDestroyCairoContext(group, s);
+ groupCreateCairoContext(group, s);
+}
+
+/*
* groupClearCairoContext
*
*/
@@ -606,8 +613,7 @@
* groupDestroyCairoContext
*
*/
-static void
-groupDestroyCairoContext(GroupSelection *group, CompScreen *s)
+void groupDestroyCairoContext(GroupSelection *group, CompScreen *s)
{
GroupTabBar *bar = group->tabBar;
GroupCairoContext *cc = bar->cc;
@@ -739,8 +745,14 @@
if (bar->nSlots && tabs_height < thumb_size) // we need to do the standard height too
tabs_height = thumb_size;
}
- bar_width = border_width * (bar->nSlots + 1) + tabs_width;
+ // there is no dragged slot or its not unhooked
+ if (!bar->draggedSlot || bar->draggedSlot->next || bar->draggedSlot->prev)
+ bar_width = border_width * (bar->nSlots + 1) + tabs_width;
+ else
+ bar_width = border_width * (bar->nSlots + 2) + tabs_width
+ + (bar->draggedSlot->region->extents.x2 - bar->draggedSlot->region->extents.x1);
+
if(maxX2 - minX1 < bar_width)
box.x = (maxX2 - minX1)/2 - bar_width / 2;
else if(middleX - bar_width/2 < minX1)
@@ -789,6 +801,7 @@
slot->next = nextSlot;
nextSlot->prev = slot;
+ bar->nSlots++;
CompWindow *w = slot->window;
GROUP_WINDOW(w);
@@ -816,6 +829,7 @@
slot->prev = prevSlot;
prevSlot->next = slot;
+ bar->nSlots++;
CompWindow *w = slot->window;
GROUP_WINDOW(w);
More information about the commits
mailing list