diff --git a/src/common.h b/src/common.h index d0d945e..dc07089 100644 --- a/src/common.h +++ b/src/common.h @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2009 Pierre Pronchery */ +/* Copyright (c) 2010 Pierre Pronchery */ /* This file is part of DeforaOS Desktop Panel */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,6 +23,11 @@ /* types */ typedef struct _Panel Panel; +typedef struct _PanelPrefs +{ + int monitor; +} PanelPrefs; + /* constants */ #define PANEL_BORDER_WIDTH 4 @@ -30,7 +35,7 @@ typedef struct _Panel Panel; /* functions */ -Panel * panel_new(void); +Panel * panel_new(PanelPrefs * prefs); void panel_delete(Panel * panel); /* useful */ diff --git a/src/main.c b/src/main.c index 10c00ea..2cf677a 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2009 Pierre Pronchery */ +/* Copyright (c) 2010 Pierre Pronchery */ /* This file is part of DeforaOS Desktop Panel */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,7 +17,9 @@ #include #include +#include #include +#include #include #include #include "common.h" @@ -27,7 +29,7 @@ /* usage */ static int _usage(void) { - fputs("Usage: " PACKAGE "\n", stderr); + fputs("Usage: " PACKAGE " [-m monitor]\n", stderr); return 1; } @@ -39,18 +41,26 @@ int main(int argc, char * argv[]) { int o; Panel * panel; + PanelPrefs prefs; + char * p; struct sigaction sa; gtk_init(&argc, &argv); - while((o = getopt(argc, argv, "")) != -1) + memset(&prefs, 0, sizeof(prefs)); + while((o = getopt(argc, argv, "m:")) != -1) switch(o) { + case 'm': + prefs.monitor = strtol(optarg, &p, 10); + if(optarg[0] == '\0' || *p != '\0') + return _usage(); + break; default: return _usage(); } if(optind != argc) return _usage(); - if((panel = panel_new()) == NULL) + if((panel = panel_new(&prefs)) == NULL) return 2; sa.sa_handler = _main_sigchld; sigemptyset(&sa.sa_mask); diff --git a/src/panel.c b/src/panel.c index d85c2a2..4e4c611 100644 --- a/src/panel.c +++ b/src/panel.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2009 Pierre Pronchery */ +/* Copyright (c) 2010 Pierre Pronchery */ /* This file is part of DeforaOS Desktop Panel */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -72,10 +72,11 @@ static gboolean _on_button_press(GtkWidget * widget, GdkEventButton * event, gpointer data); static gboolean _on_closex(void); -Panel * panel_new(void) +Panel * panel_new(PanelPrefs * prefs) { Panel * panel; GdkScreen * screen; + int monitor; GtkWidget * event; GdkRectangle rect; @@ -102,7 +103,12 @@ Panel * panel_new(void) /* root window */ panel->root = gdk_screen_get_root_window(gdk_screen_get_default()); screen = gdk_screen_get_default(); - gdk_screen_get_monitor_geometry(screen, 0, &rect); + if(prefs != NULL && prefs->monitor > 0 + && prefs->monitor < gdk_screen_get_n_monitors(screen)) + monitor = prefs->monitor; + else + monitor = 0; + gdk_screen_get_monitor_geometry(screen, monitor, &rect); panel->root_width = rect.width; panel->root_height = rect.height; #ifdef DEBUG @@ -120,8 +126,8 @@ Panel * panel_new(void) rect.height); gtk_window_set_type_hint(GTK_WINDOW(panel->window), GDK_WINDOW_TYPE_HINT_DOCK); - gtk_window_move(GTK_WINDOW(panel->window), 0, panel->root_height - - rect.height); + gtk_window_move(GTK_WINDOW(panel->window), rect.x, + rect.y + panel->root_height - rect.height); gtk_window_stick(GTK_WINDOW(panel->window)); g_signal_connect(G_OBJECT(panel->window), "delete-event", G_CALLBACK( _on_closex), panel);