X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fclient.c;h=da38843b74e210b56f9694fe644fbc2fed360ed1;hb=b8f207892a11b53365c47b4828254269fca5c8e9;hp=b0482faa6003beb4a8321aa3a4ccddc9996504da;hpb=382d37553d9dc7679464cf71aecf8590cc06a2cb;p=chaz%2Fopenbox diff --git a/openbox/client.c b/openbox/client.c index b0482faa..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; } @@ -565,7 +573,7 @@ void client_unmanage(ObClient *self) /* ignore enter events from the unmap so it doesnt mess with the focus */ - event_ignore_queued_enters(); + event_ignore_all_queued_enters(); mouse_grab_for_client(self, FALSE); @@ -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); } } @@ -853,9 +870,11 @@ gboolean client_find_onscreen(ObClient *self, gint *x, gint *y, gint w, gint h, gint ox = *x, oy = *y; gboolean rudel = rude, ruder = rude, rudet = rude, rudeb = rude; gint fw, fh; + Rect desired; + RECT_SET(desired, *x, *y, w, h); all_a = screen_area(self->desktop); - mon_a = screen_area_monitor(self->desktop, client_monitor(self)); + mon_a = screen_area_monitor(self->desktop, screen_find_monitor(&desired)); /* get where the frame would be */ frame_client_gravity(self->frame, x, y, w, h); @@ -2721,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) */ @@ -2756,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); @@ -3469,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); }