]> Dogcows Code - chaz/openbox/blob - openbox/per_app_settings.c
some notes to self
[chaz/openbox] / openbox / per_app_settings.c
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3 client.h for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 See the COPYING file for a copy of the GNU General Public License.
17 */
18
19 #include "per_app_settings.h"
20 #include "screen.h"
21 #include "config.h"
22
23 /* XXX put in client.c */
24 /* This should possibly do something more interesting than just match
25 * against WM_CLASS literally. */
26 ObAppSetting *get_client_settings(ObClient *client)
27 {
28 GSList *a = config_per_app_settings;
29
30 while (a) {
31 ObAppSetting *app = (ObAppSetting *) a->data;
32
33 if (!strcmp(app->name, client->name)) {
34 ob_debug("Window matching: %s\n", app->name);
35
36 return (ObAppSetting *) a->data;
37 }
38
39 a = a->next;
40 }
41 return NULL;
42 }
43
44 /* XXX put in place.c */
45 void place_window_from_settings(ObAppSetting *setting, ObClient *client, gint *x, gint *y)
46 {
47 gint px, py, i;
48 Rect *screen;
49
50 /* Find which head the pointer is on, partly taken from place.c */
51 if (setting->head == -1) {
52 screen_pointer_pos(&px, &py);
53
54 for (i = 0; i < screen_num_monitors; i++) {
55 screen = screen_area_monitor(client->desktop, i);
56 if (RECT_CONTAINS(*screen, px, py))
57 break;
58 }
59
60 if (i == screen_num_monitors)
61 screen = screen_area_monitor(client->desktop, 0);
62 }
63 else
64 screen = screen_area_monitor(client->desktop, setting->head);
65
66 if (setting->position.x == -1 && setting->center_x)
67 *x = screen->x + screen->width / 2 - client->area.width / 2;
68 else if (setting->position.x != -1)
69 *x = screen->x + setting->position.x;
70
71 if (setting->position.y == -1 && setting->center_y)
72 *y = screen->y + screen->height / 2 - client->area.height / 2;
73 else if (setting->position.y != -1)
74 *y = screen->y + setting->position.y;
75
76 }
This page took 0.035067 seconds and 4 git commands to generate.