Code

add logging of basic display properties
authormental <mental@users.sourceforge.net>
Thu, 10 May 2007 01:18:46 +0000 (01:18 +0000)
committermental <mental@users.sourceforge.net>
Thu, 10 May 2007 01:18:46 +0000 (01:18 +0000)
src/debug/Makefile_insert
src/debug/log-display-config.cpp [new file with mode: 0644]
src/debug/log-display-config.h [new file with mode: 0644]
src/main.cpp

index 6205b5ca9ab79bbf074b08e1227ab0ac27ce7b6f..96a12f3f4bbb836e9938974634971666dca6f26c 100644 (file)
@@ -11,6 +11,7 @@ debug_libinkdebug_a_SOURCES = \
        debug/heap.cpp debug/heap.h \
        debug/gc-heap.h \
        debug/logger.cpp debug/logger.h \
+       debug/log-display-config.cpp debug/log-display-config.h \
        debug/simple-event.h \
        debug/sysv-heap.cpp debug/sysv-heap.h \
         debug/timestamp.cpp debug/timestamp.h
diff --git a/src/debug/log-display-config.cpp b/src/debug/log-display-config.cpp
new file mode 100644 (file)
index 0000000..0aeb71c
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Inkscape::Debug::log_display_config - log display configuration
+ *
+ * Authors:
+ *   MenTaLguY <mental@rydia.net>
+ *
+ * Copyright (C) 2007 MenTaLguY
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <iostream>
+#include <gdk/gdkdisplay.h>
+#include <gdk/gdkscreen.h>
+#include "debug/event-tracker.h"
+#include "debug/logger.h"
+#include "debug/simple-event.h"
+#include "debug/log-display-config.h"
+
+namespace Inkscape {
+
+namespace Debug {
+
+namespace {
+
+typedef SimpleEvent<Event::CONFIGURATION> ConfigurationEvent;
+
+class Monitor : public ConfigurationEvent {
+public:
+    Monitor(GdkScreen *screen, gint monitor) : ConfigurationEvent("monitor") {
+        GdkRectangle area;
+        gdk_screen_get_monitor_geometry(screen, monitor, &area);
+        _addProperty("x", area.x);
+        _addProperty("y", area.y);
+        _addProperty("width", area.width);
+        _addProperty("height", area.height);
+    }
+};
+
+class Screen : public ConfigurationEvent {
+public:
+    Screen(GdkScreen *s) : ConfigurationEvent("screen"), screen(s) {
+        _addProperty("width", gdk_screen_get_width(screen));
+        _addProperty("height", gdk_screen_get_height(screen));
+    }
+    void generateChildEvents() const {
+        gint n_monitors = gdk_screen_get_n_monitors(screen);
+        for ( gint i = 0 ; i < n_monitors ; i++ ) {
+            Logger::write<Monitor>(screen, i);
+        }
+    }
+
+private:
+    GdkScreen *screen;
+};
+
+class Display : public ConfigurationEvent {
+public:
+    Display() : ConfigurationEvent("display") {}
+    void generateChildEvents() const {
+        GdkDisplay *display=gdk_display_get_default();
+        gint n_screens = gdk_display_get_n_screens(display);
+        for ( gint i = 0 ; i < n_screens ; i++ ) {
+            GdkScreen *screen = gdk_display_get_screen(display, i);
+            Logger::write<Screen>(screen);
+        }
+    }
+};
+
+}
+
+void log_display_config() {
+    Logger::write<Display>();
+}
+
+}
+
+}
+
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+  indent-tabs-mode:nil
+  fill-column:99
+  End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/debug/log-display-config.h b/src/debug/log-display-config.h
new file mode 100644 (file)
index 0000000..ae64b08
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Inkscape::Debug::log_display_config - log display configuration
+ *
+ * Authors:
+ *   MenTaLguY <mental@rydia.net>
+ *
+ * Copyright (C) 2007 MenTaLguY
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifndef SEEN_INKSCAPE_DEBUG_LOG_DISPLAY_CONFIG_H
+#define SEEN_INKSCAPE_DEBUG_LOG_DISPLAY_CONFIG_H
+
+#include "util/share.h"
+
+namespace Inkscape {
+
+namespace Debug {
+
+void log_display_config();
+
+}
+
+}
+
+#endif
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+  indent-tabs-mode:nil
+  fill-column:99
+  End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
index 3849be4fac725ebb0ac365db85c43a9d51b80818..87913a80144e11ea01b536195afd8608b822bc44 100644 (file)
@@ -77,6 +77,7 @@
 #include "io/sys.h"
 
 #include "debug/logger.h"
+#include "debug/log-display-config.h"
 
 #include "helper/png-write.h"
 
@@ -630,6 +631,8 @@ sp_main_gui(int argc, char const **argv)
 
     inkscape_gtk_stock_init();
 
+    Inkscape::Debug::log_display_config();
+
     /* Set default icon */
     gchar *filename = (gchar *) g_build_filename (INKSCAPE_APPICONDIR, "inkscape.png", NULL);
     if (Inkscape::IO::file_test(filename, (GFileTest)(G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))) {