X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fclient.c;h=59af202a6d426a9b28d14eb41da3c36026161ad7;hb=3a607fad9df628ab16e0f7436dfbfc9b22634003;hp=75aecf41f630500d154f15e90b0655b06d48cd80;hpb=c20a8d986a3a87dd345bede8e3b6c08e39a89485;p=chaz%2Fopenbox diff --git a/openbox/client.c b/openbox/client.c index 75aecf41..59af202a 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -461,6 +461,7 @@ void client_unmanage(ObClient *self) g_free(self->name); g_free(self->class); g_free(self->role); + g_free(self->sm_client_id); g_free(self); /* update the list hints */ @@ -551,14 +552,16 @@ gboolean client_find_onscreen(ObClient *self, int *x, int *y, int w, int h, /* XXX watch for xinerama dead areas */ a = screen_area(self->desktop); - if (!self->strut.right && *x >= a->x + a->width - 1) - *x = a->x + a->width - self->frame->area.width; - if (!self->strut.bottom && *y >= a->y + a->height - 1) - *y = a->y + a->height - self->frame->area.height; - if (!self->strut.left && *x + self->frame->area.width - 1 < a->x) - *x = a->x; - if (!self->strut.top && *y + self->frame->area.height - 1 < a->y) - *y = a->y; + if (client_normal(self)) { + if (!self->strut.right && *x >= a->x + a->width - 1) + *x = a->x + a->width - self->frame->area.width; + if (!self->strut.bottom && *y >= a->y + a->height - 1) + *y = a->y + a->height - self->frame->area.height; + if (!self->strut.left && *x + self->frame->area.width - 1 < a->x) + *x = a->x; + if (!self->strut.top && *y + self->frame->area.height - 1 < a->y) + *y = a->y; + } if (rude) { /* this is my MOZILLA BITCHSLAP. oh ya it fucking feels good. @@ -675,6 +678,7 @@ static void client_get_all(ObClient *self) client_update_title(self); client_update_class(self); + client_update_sm_client_id(self); client_update_strut(self); client_update_icons(self); } @@ -749,10 +753,6 @@ static void client_get_state(ObClient *self) guint32 *state; guint num; - self->modal = self->shaded = self->max_horz = self->max_vert = - self->fullscreen = self->above = self->below = self->iconic = - self->skip_taskbar = self->skip_pager = FALSE; - if (PROP_GETA32(self->window, net_wm_state, atom, &state, &num)) { gulong i; for (i = 0; i < num; ++i) { @@ -1310,10 +1310,11 @@ void client_update_title(ObClient *self) GList *it; guint32 nums; guint i; - char *data = NULL; + gchar *data = NULL; gboolean read_title; + gchar *old_title; - g_free(self->title); + old_title = self->title; /* try netwm */ if (!PROP_GETS(self->window, net_wm_name, utf8, &data)) @@ -1321,6 +1322,10 @@ void client_update_title(ObClient *self) if (!PROP_GETS(self->window, wm_name, locale, &data)) data = g_strdup("Unnamed Window"); + /* did the title change? then reset the title_count */ + if (old_title && 0 != strncmp(old_title, data, strlen(data))) + self->title_count = 1; + /* look for duplicates and append a number */ nums = 0; for (it = client_list; it; it = it->next) @@ -1338,12 +1343,10 @@ void client_update_title(ObClient *self) } /* dont display the number for the first window */ if (self->title_count > 1) { - char *vdata, *ndata; - ndata = g_strdup_printf(" - [%u]", self->title_count); - vdata = g_strconcat(data, ndata, NULL); - g_free(ndata); + char *ndata; + ndata = g_strdup_printf("%s - [%u]", data, self->title_count); g_free(data); - data = vdata; + data = ndata; } PROP_SETS(self->window, net_wm_visible_name, data); @@ -1353,6 +1356,8 @@ void client_update_title(ObClient *self) if (self->frame) frame_adjust_title(self->frame); + g_free(old_title); + /* update the icon title */ data = NULL; g_free(self->icon_title); @@ -1402,7 +1407,7 @@ void client_update_class(ObClient *self) } if (PROP_GETS(self->window, wm_window_role, locale, &s)) - self->role = g_strdup(s); + self->role = s; if (self->name == NULL) self->name = g_strdup(""); if (self->class == NULL) self->class = g_strdup(""); @@ -1545,6 +1550,16 @@ void client_update_icons(ObClient *self) } } + if (!self->nicons) { + self->nicons++; + self->icons = g_new(ObClientIcon, self->nicons); + self->icons[self->nicons-1].width = 48; + self->icons[self->nicons-1].height = 48; + self->icons[self->nicons-1].data = g_memdup(ob_rr_theme->def_win_icon, + sizeof(RrPixel32) + * 48 * 48); + } + if (self->frame) frame_adjust_icon(self->frame); } @@ -1752,6 +1767,8 @@ void client_configure_full(ObClient *self, ObCorner anchor, gboolean user, gboolean final, gboolean force_reply) { + gint oldw, oldh; + gboolean send_resize_client; gboolean moved = FALSE, resized = FALSE; guint fdecor = self->frame->decorations; gboolean fhorz = self->frame->max_horz; @@ -1913,14 +1930,20 @@ void client_configure_full(ObClient *self, ObCorner anchor, moved = x != self->area.x || y != self->area.y; resized = w != self->area.width || h != self->area.height; + oldw = self->area.width; + oldh = self->area.height; RECT_SET(self->area, x, y, w, h); /* for app-requested resizes, always resize if 'resized' is true. for user-requested ones, only resize if final is true, or when resizing in redraw mode */ - if ((!user && resized) || - (user && (final || (resized && config_redraw_resize)))) - XResizeWindow(ob_display, self->window, w, h); + send_resize_client = ((!user && resized) || + (user && (final || + (resized && config_redraw_resize)))); + + /* if the client is enlarging, the resize the client before the frame */ + if (send_resize_client && (w > oldw || h > oldh)) + XResizeWindow(ob_display, self->window, MAX(w, oldw), MAX(h, oldh)); /* move/resize the frame to match the request */ if (self->frame) { @@ -1952,6 +1975,12 @@ void client_configure_full(ObClient *self, ObCorner anchor, FALSE, StructureNotifyMask, &event); } } + + /* if the client is shrinking, then resize the frame before the client */ + if (send_resize_client && (w <= oldw || h <= oldh)) + XResizeWindow(ob_display, self->window, w, h); + + XFlush(ob_display); } void client_fullscreen(ObClient *self, gboolean fs, gboolean savearea) @@ -2505,12 +2534,17 @@ gboolean client_focus(ObClient *self) return FALSE; } - if (self->can_focus) + if (self->can_focus) { /* RevertToPointerRoot causes much more headache than RevertToNone, so I choose to use it always, hopefully to find errors quicker, if any - are left. (I hate X. I hate focus events.) */ - XSetInputFocus(ob_display, self->window, RevertToPointerRoot, + are left. (I hate X. I hate focus events.) + + Update: Changing this to RevertToNone fixed a bug with mozilla (bug + #799. So now it is RevertToNone again. + */ + XSetInputFocus(ob_display, self->window, RevertToNone, event_lasttime); + } if (self->focus_notify) { XEvent ce; @@ -2583,8 +2617,6 @@ ObClientIcon *client_icon(ObClient *self, int w, int h) /* li is the largest image < req */ unsigned long size, smallest = 0xffffffff, largest = 0, si = 0, li = 0; - if (!self->nicons) return NULL; - for (i = 0; i < self->nicons; ++i) { size = self->icons[i].width * self->icons[i].height; if (size < smallest && size >= (unsigned)(w * h)) { @@ -2765,13 +2797,15 @@ ObClient *client_search_transient(ObClient *self, ObClient *search) return NULL; } -gchar* client_get_sm_client_id(ObClient *self) +void client_update_sm_client_id(ObClient *self) { - gchar *id = NULL; + g_free(self->sm_client_id); + self->sm_client_id = NULL; - if (!PROP_GETS(self->window, sm_client_id, locale, &id) && self->group) - PROP_GETS(self->group->leader, sm_client_id, locale, &id); - return id; + if (!PROP_GETS(self->window, sm_client_id, locale, &self->sm_client_id) && + self->group) + PROP_GETS(self->group->leader, sm_client_id, locale, + &self->sm_client_id); } /* finds the nearest edge in the given direction from the current client