X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fclient.c;h=da38843b74e210b56f9694fe644fbc2fed360ed1;hb=b8f207892a11b53365c47b4828254269fca5c8e9;hp=e77a4ea6f9e141eb6d5acf61c71f45fea503b35b;hpb=64d812c6d7b2e8da981a97a921981fbdb073551a;p=chaz%2Fopenbox diff --git a/openbox/client.c b/openbox/client.c index e77a4ea6..da38843b 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -314,7 +314,8 @@ void client_manage(Window window) grab_server(FALSE); /* per-app settings override stuff from client_get_all, and return the - settings for other uses too */ + settings for other uses too. the returned settings is a shallow copy, + that needs to be freed with g_free(). */ settings = client_get_settings_state(self); /* the session should get the last say thought */ client_restore_session_state(self); @@ -506,6 +507,9 @@ void client_manage(Window window) /* update the list hints */ client_set_list(); + /* free the ObAppSettings shallow copy */ + g_free(settings); + ob_debug("Managed window 0x%lx plate 0x%x (%s)\n", window, self->frame->plate, self->class); @@ -527,7 +531,7 @@ ObClient *client_fake_manage(Window window) client_get_all(self, FALSE); /* per-app settings override stuff, and return the settings for other - uses too */ + uses too. this returns a shallow copy that needs to be freed */ settings = client_get_settings_state(self); client_setup_decor_and_functions(self); @@ -535,6 +539,10 @@ ObClient *client_fake_manage(Window window) /* create the decoration frame for the client window and adjust its size */ self->frame = frame_new(self); frame_adjust_area(self->frame, FALSE, TRUE, TRUE); + + /* free the ObAppSettings shallow copy */ + g_free(settings); + return self; } @@ -694,30 +702,39 @@ void client_fake_unmanage(ObClient *self) g_free(self); } +/*! Returns a new structure containing the per-app settings for this client. + The returned structure needs to be freed with g_free. */ static ObAppSettings *client_get_settings_state(ObClient *self) { - ObAppSettings *settings = NULL; + ObAppSettings *settings; GSList *it; + settings = config_create_app_settings(); + for (it = config_per_app_settings; it; it = g_slist_next(it)) { ObAppSettings *app = it->data; - - if ((app->name && !app->class && !strcmp(app->name, self->name)) - || (app->class && !app->name && !strcmp(app->class, self->class)) - || (app->class && app->name && !strcmp(app->class, self->class) - && !strcmp(app->name, self->name))) - { - /* Match if no role was specified in the per app setting, or if the - * string matches the beginning of the role, since apps like to set - * the role to things like browser-window-23c4b2f */ - if (!app->role - || !strncmp(app->role, self->role, strlen(app->role))) - { - ob_debug("Window matching: %s\n", app->name); - /* use this one */ - settings = app; - break; - } + gboolean match = TRUE; + + g_assert(app->name != NULL || app->class != NULL); + + /* we know that either name or class is not NULL so it will have to + match to use the rule */ + if (app->name && + !g_pattern_match(app->name, strlen(self->name), self->name, NULL)) + match = FALSE; + if (app->class && + !g_pattern_match(app->class, strlen(self->class),self->class,NULL)) + match = FALSE; + if (app->role && + !g_pattern_match(app->role, strlen(self->role), self->role, NULL)) + match = FALSE; + + if (match) { + ob_debug("Window matching: %s\n", app->name); + + /* copy the settings to our struct, overriding the existing + settings if they are not defaults */ + config_app_settings_copy_non_defaults(app, settings); } } @@ -2723,6 +2740,7 @@ void client_configure(ObClient *self, gint x, gint y, gint w, gint h, gboolean fmoved, fresized; guint fdecor = self->frame->decorations; gboolean fhorz = self->frame->max_horz; + gboolean fvert = self->frame->max_vert; gint logicalw, logicalh; /* find the new x, y, width, and height (and logical size) */ @@ -2758,8 +2776,11 @@ void client_configure(ObClient *self, gint x, gint y, gint w, gint h, /* find the frame's dimensions and move/resize it */ fmoved = moved; fresized = resized; - if (self->decorations != fdecor || self->max_horz != fhorz) + if (self->decorations != fdecor || + self->max_horz != fhorz || self->max_vert != fvert) + { fmoved = fresized = TRUE; + } if (fmoved || fresized) frame_adjust_area(self->frame, fmoved, fresized, FALSE); @@ -3471,12 +3492,9 @@ void client_activate(ObClient *self, gboolean here, gboolean user) self->window, event_curtime, last_time, (user ? "user" : "application"), allow); - if (allow) { - if (event_curtime != CurrentTime) - self->user_time = event_curtime; - + if (allow) client_present(self, here, TRUE); - } else + else /* don't focus it but tell the user it wants attention */ client_hilite(self, TRUE); }