summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexander Valavanis <valavanisalex@gmail.com>2017-07-09 15:20:40 +0000
committerAlexander Valavanis <valavanisalex@gmail.com>2017-07-09 15:20:40 +0000
commit27cadae623ce5bc66b0401238bc7737b7b9d37d5 (patch)
tree75a45add7b9b08502dcab731bda324adb2383d91 /src
parentege-color-prof-tracker: Cosmetic cleanup (diff)
downloadinkscape-27cadae623ce5bc66b0401238bc7737b7b9d37d5.tar.gz
inkscape-27cadae623ce5bc66b0401238bc7737b7b9d37d5.zip
Updates for GdkScreen/GdkMonitor API changes
Diffstat (limited to 'src')
-rw-r--r--src/cms-system.h4
-rw-r--r--src/color-profile.cpp151
-rw-r--r--src/ege-color-prof-tracker.cpp293
-rw-r--r--src/ege-color-prof-tracker.h2
-rw-r--r--src/widgets/desktop-widget.cpp15
5 files changed, 205 insertions, 260 deletions
diff --git a/src/cms-system.h b/src/cms-system.h
index 73d1a89c4..27eb8e3e6 100644
--- a/src/cms-system.h
+++ b/src/cms-system.h
@@ -21,9 +21,9 @@ public:
static cmsHTRANSFORM getDisplayTransform();
- static Glib::ustring getDisplayId( int screen, int monitor );
+ static Glib::ustring getDisplayId( int monitor );
- static Glib::ustring setDisplayPer( void* buf, unsigned int bufLen, int screen, int monitor );
+ static Glib::ustring setDisplayPer( void* buf, unsigned int bufLen, int monitor );
static cmsHTRANSFORM getDisplayPer( Glib::ustring const& id );
diff --git a/src/color-profile.cpp b/src/color-profile.cpp
index bbf1f464a..1552c38e7 100644
--- a/src/color-profile.cpp
+++ b/src/color-profile.cpp
@@ -1198,7 +1198,7 @@ MemProfile::~MemProfile()
{
}
-static std::vector< std::vector<MemProfile> > perMonitorProfiles;
+static std::vector<MemProfile> perMonitorProfiles;
void free_transforms()
{
@@ -1207,43 +1207,33 @@ void free_transforms()
transf = 0;
}
- for ( std::vector< std::vector<MemProfile> >::iterator it = perMonitorProfiles.begin(); it != perMonitorProfiles.end(); ++it ) {
- for ( std::vector<MemProfile>::iterator it2 = it->begin(); it2 != it->end(); ++it2 ) {
- if ( it2->transf ) {
- cmsDeleteTransform(it2->transf);
- it2->transf = 0;
- }
+ for ( auto profile : perMonitorProfiles ) {
+ if ( profile.transf ) {
+ cmsDeleteTransform(profile.transf);
+ profile.transf = 0;
}
}
}
-Glib::ustring Inkscape::CMSSystem::getDisplayId( int screen, int monitor )
+Glib::ustring Inkscape::CMSSystem::getDisplayId( int monitor )
{
Glib::ustring id;
- if ( screen >= 0 && screen < static_cast<int>(perMonitorProfiles.size()) ) {
- std::vector<MemProfile>& row = perMonitorProfiles[screen];
- if ( monitor >= 0 && monitor < static_cast<int>(row.size()) ) {
- MemProfile& item = row[monitor];
- id = item.id;
- }
+ if ( monitor >= 0 && monitor < static_cast<int>(perMonitorProfiles.size()) ) {
+ MemProfile& item = perMonitorProfiles[monitor];
+ id = item.id;
}
return id;
}
-Glib::ustring Inkscape::CMSSystem::setDisplayPer( gpointer buf, guint bufLen, int screen, int monitor )
+Glib::ustring Inkscape::CMSSystem::setDisplayPer( gpointer buf, guint bufLen, int monitor )
{
- while ( static_cast<int>(perMonitorProfiles.size()) <= screen ) {
- std::vector<MemProfile> tmp;
- perMonitorProfiles.push_back(tmp);
- }
- std::vector<MemProfile>& row = perMonitorProfiles[screen];
- while ( static_cast<int>(row.size()) <= monitor ) {
+ while ( static_cast<int>(perMonitorProfiles.size()) <= monitor ) {
MemProfile tmp;
- row.push_back(tmp);
+ perMonitorProfiles.push_back(tmp);
}
- MemProfile& item = row[monitor];
+ MemProfile& item = perMonitorProfiles[monitor];
if ( item.hprof ) {
cmsCloseProfile( item.hprof );
@@ -1274,81 +1264,80 @@ cmsHTRANSFORM Inkscape::CMSSystem::getDisplayPer( Glib::ustring const& id )
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool found = false;
- for ( std::vector< std::vector<MemProfile> >::iterator it = perMonitorProfiles.begin(); it != perMonitorProfiles.end() && !found; ++it ) {
- for ( std::vector<MemProfile>::iterator it2 = it->begin(); it2 != it->end() && !found; ++it2 ) {
- if ( id == it2->id ) {
- MemProfile& item = *it2;
-
- bool warn = prefs->getBool( "/options/softproof/gamutwarn");
- int intent = prefs->getIntLimited( "/options/displayprofile/intent", 0, 0, 3 );
- int proofIntent = prefs->getIntLimited( "/options/softproof/intent", 0, 0, 3 );
- bool bpc = prefs->getBool( "/options/softproof/bpc");
+
+ for ( auto it2 = perMonitorProfiles.begin(); it2 != perMonitorProfiles.end() && !found; ++it2 ) {
+ if ( id == it2->id ) {
+ MemProfile& item = *it2;
+
+ bool warn = prefs->getBool( "/options/softproof/gamutwarn");
+ int intent = prefs->getIntLimited( "/options/displayprofile/intent", 0, 0, 3 );
+ int proofIntent = prefs->getIntLimited( "/options/softproof/intent", 0, 0, 3 );
+ bool bpc = prefs->getBool( "/options/softproof/bpc");
#if defined(cmsFLAGS_PRESERVEBLACK)
- bool preserveBlack = prefs->getBool( "/options/softproof/preserveblack");
+ bool preserveBlack = prefs->getBool( "/options/softproof/preserveblack");
#endif //defined(cmsFLAGS_PRESERVEBLACK)
- Glib::ustring colorStr = prefs->getString("/options/softproof/gamutcolor");
- Gdk::RGBA gamutColor( colorStr.empty() ? "#808080" : colorStr );
+ Glib::ustring colorStr = prefs->getString("/options/softproof/gamutcolor");
+ Gdk::RGBA gamutColor( colorStr.empty() ? "#808080" : colorStr );
- if ( (warn != gamutWarn)
- || (lastIntent != intent)
- || (lastProofIntent != proofIntent)
- || (bpc != lastBPC)
+ if ( (warn != gamutWarn)
+ || (lastIntent != intent)
+ || (lastProofIntent != proofIntent)
+ || (bpc != lastBPC)
#if defined(cmsFLAGS_PRESERVEBLACK)
- || (preserveBlack != lastPreserveBlack)
+ || (preserveBlack != lastPreserveBlack)
#endif // defined(cmsFLAGS_PRESERVEBLACK)
- || (gamutColor != lastGamutColor)
- ) {
- gamutWarn = warn;
- free_transforms();
- lastIntent = intent;
- lastProofIntent = proofIntent;
- lastBPC = bpc;
+ || (gamutColor != lastGamutColor)
+ ) {
+ gamutWarn = warn;
+ free_transforms();
+ lastIntent = intent;
+ lastProofIntent = proofIntent;
+ lastBPC = bpc;
#if defined(cmsFLAGS_PRESERVEBLACK)
- lastPreserveBlack = preserveBlack;
+ lastPreserveBlack = preserveBlack;
#endif // defined(cmsFLAGS_PRESERVEBLACK)
- lastGamutColor = gamutColor;
- }
+ lastGamutColor = gamutColor;
+ }
- // Fetch these now, as they might clear the transform as a side effect.
- cmsHPROFILE proofProf = item.hprof ? getProofProfileHandle() : 0;
+ // Fetch these now, as they might clear the transform as a side effect.
+ cmsHPROFILE proofProf = item.hprof ? getProofProfileHandle() : 0;
- if ( !item.transf ) {
- if ( item.hprof && proofProf ) {
- cmsUInt32Number dwFlags = cmsFLAGS_SOFTPROOFING;
- if ( gamutWarn ) {
- dwFlags |= cmsFLAGS_GAMUTCHECK;
- auto gamutColor_r = gamutColor.get_red_u();
- auto gamutColor_g = gamutColor.get_green_u();
- auto gamutColor_b = gamutColor.get_blue_u();
+ if ( !item.transf ) {
+ if ( item.hprof && proofProf ) {
+ cmsUInt32Number dwFlags = cmsFLAGS_SOFTPROOFING;
+ if ( gamutWarn ) {
+ dwFlags |= cmsFLAGS_GAMUTCHECK;
+ auto gamutColor_r = gamutColor.get_red_u();
+ auto gamutColor_g = gamutColor.get_green_u();
+ auto gamutColor_b = gamutColor.get_blue_u();
#if HAVE_LIBLCMS1
- cmsSetAlarmCodes(gamutColor_r >> 8, gamutColor_g >> 8, gamutColor_b >> 8);
+ cmsSetAlarmCodes(gamutColor_r >> 8, gamutColor_g >> 8, gamutColor_b >> 8);
#elif HAVE_LIBLCMS2
- cmsUInt16Number newAlarmCodes[cmsMAXCHANNELS] = {0};
- newAlarmCodes[0] = gamutColor_r;
- newAlarmCodes[1] = gamutColor_g;
- newAlarmCodes[2] = gamutColor_b;
- newAlarmCodes[3] = ~0;
- cmsSetAlarmCodes(newAlarmCodes);
+ cmsUInt16Number newAlarmCodes[cmsMAXCHANNELS] = {0};
+ newAlarmCodes[0] = gamutColor_r;
+ newAlarmCodes[1] = gamutColor_g;
+ newAlarmCodes[2] = gamutColor_b;
+ newAlarmCodes[3] = ~0;
+ cmsSetAlarmCodes(newAlarmCodes);
#endif
- }
- if ( bpc ) {
- dwFlags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
- }
+ }
+ if ( bpc ) {
+ dwFlags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
+ }
#if defined(cmsFLAGS_PRESERVEBLACK)
- if ( preserveBlack ) {
- dwFlags |= cmsFLAGS_PRESERVEBLACK;
- }
-#endif // defined(cmsFLAGS_PRESERVEBLACK)
- item.transf = cmsCreateProofingTransform( ColorProfileImpl::getSRGBProfile(), TYPE_BGRA_8, item.hprof, TYPE_BGRA_8, proofProf, intent, proofIntent, dwFlags );
- } else if ( item.hprof ) {
- item.transf = cmsCreateTransform( ColorProfileImpl::getSRGBProfile(), TYPE_BGRA_8, item.hprof, TYPE_BGRA_8, intent, 0 );
+ if ( preserveBlack ) {
+ dwFlags |= cmsFLAGS_PRESERVEBLACK;
}
+#endif // defined(cmsFLAGS_PRESERVEBLACK)
+ item.transf = cmsCreateProofingTransform( ColorProfileImpl::getSRGBProfile(), TYPE_BGRA_8, item.hprof, TYPE_BGRA_8, proofProf, intent, proofIntent, dwFlags );
+ } else if ( item.hprof ) {
+ item.transf = cmsCreateTransform( ColorProfileImpl::getSRGBProfile(), TYPE_BGRA_8, item.hprof, TYPE_BGRA_8, intent, 0 );
}
-
- result = item.transf;
- found = true;
}
+
+ result = item.transf;
+ found = true;
}
}
diff --git a/src/ege-color-prof-tracker.cpp b/src/ege-color-prof-tracker.cpp
index 757dec6c6..2c0e8f991 100644
--- a/src/ege-color-prof-tracker.cpp
+++ b/src/ege-color-prof-tracker.cpp
@@ -64,7 +64,6 @@ static void ege_color_prof_tracker_get_property( GObject* obj, guint propId, GVa
static void ege_color_prof_tracker_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec );
typedef struct _ScreenTrack {
- GdkScreen* screen;
#ifdef GDK_WINDOWING_X11
gboolean zeroSeen;
gboolean otherSeen;
@@ -76,15 +75,17 @@ typedef struct _ScreenTrack {
#ifdef GDK_WINDOWING_X11
GdkFilterReturn x11_win_filter(GdkXEvent *xevent, GdkEvent *event, gpointer data);
void handle_property_change(GdkScreen* screen, const gchar* name);
-void add_x11_tracking_for_screen(GdkScreen* screen, ScreenTrack* screenTrack);
-static void fire(GdkScreen* screen, gint monitor);
-static void clear_profile( GdkScreen* screen, guint monitor );
-static void set_profile( GdkScreen* screen, guint monitor, const guint8* data, guint len );
+void add_x11_tracking_for_screen(GdkScreen* screen);
+static void fire(gint monitor);
+static void clear_profile( guint monitor );
+static void set_profile( guint monitor, const guint8* data, guint len );
#endif /* GDK_WINDOWING_X11 */
static guint signals[LAST_SIGNAL] = {0};
-static GSList* tracked_screens = 0;
+// There is only one GdkScreen in Gtk+ 3
+static ScreenTrack *tracked_screen = nullptr;
+
static GSList* abstract_trackers = 0;
struct _EgeColorProfTrackerPrivate
@@ -149,8 +150,7 @@ void ege_color_prof_tracker_class_init( EgeColorProfTrackerClass* klass )
0,
NULL, NULL,
sp_marshal_VOID__INT_INT,
- G_TYPE_NONE, 2,
- G_TYPE_INT,
+ G_TYPE_NONE, 1,
G_TYPE_INT);
g_type_class_add_private( klass, sizeof(EgeColorProfTrackerClass) );
@@ -176,7 +176,7 @@ EgeColorProfTracker* ege_color_prof_tracker_new( GtkWidget* target )
if ( target ) {
g_object_weak_ref( G_OBJECT(target), target_finalized, obj );
g_signal_connect( G_OBJECT(target), "hierarchy-changed", G_CALLBACK( target_hierarchy_changed_cb ), obj );
- g_signal_connect( G_OBJECT(target), "screen-changed", G_CALLBACK( target_screen_changed_cb ), obj );
+ g_signal_connect( G_OBJECT(target), "screen-changed", G_CALLBACK( target_screen_changed_cb ), obj );
/* invoke the callbacks now to connect if the widget is already visible */
target_hierarchy_changed_cb( target, 0, obj );
@@ -184,16 +184,10 @@ EgeColorProfTracker* ege_color_prof_tracker_new( GtkWidget* target )
} else {
abstract_trackers = g_slist_append( abstract_trackers, obj );
- GSList* curr = tracked_screens;
- while ( curr ) {
- ScreenTrack* track = (ScreenTrack*)curr->data;
- gint screenNum = gdk_screen_get_number(track->screen);
- gint monitor = 0;
- for ( monitor = 0; monitor < (gint)track->profiles->len; monitor++ ) {
- g_signal_emit( G_OBJECT(tracker), signals[MODIFIED], 0, screenNum, monitor );
+ if(tracked_screen) {
+ for ( gint monitor = 0; monitor < (gint)tracked_screen->profiles->len; monitor++ ) {
+ g_signal_emit( G_OBJECT(tracker), signals[MODIFIED], 0, monitor );
}
-
- curr = g_slist_next(curr);
}
}
@@ -208,22 +202,16 @@ void ege_color_prof_tracker_get_profile( EgeColorProfTracker const * tracker, gp
if (tracker) {
if (tracker->private_data->_target ) {
GdkScreen* screen = gtk_widget_get_screen(tracker->private_data->_target);
- GSList* curr = tracked_screens;
- while ( curr ) {
- ScreenTrack* screenTrack = static_cast<ScreenTrack*>(curr->data);
- if ( screenTrack->screen == screen ) {
- if ( tracker->private_data->_monitor >= 0 && tracker->private_data->_monitor < (static_cast<gint>(screenTrack->profiles->len))) {
- GByteArray* gba = static_cast<GByteArray*>(g_ptr_array_index(screenTrack->profiles, tracker->private_data->_monitor));
- if ( gba ) {
- dataPos = gba->data;
- dataLen = gba->len;
- }
- } else {
- g_warning("No profile data tracked for the specified item.");
+ if ( tracked_screen ) {
+ if ( tracker->private_data->_monitor >= 0 && tracker->private_data->_monitor < (static_cast<gint>(tracked_screen->profiles->len))) {
+ GByteArray* gba = static_cast<GByteArray*>(g_ptr_array_index(tracked_screen->profiles, tracker->private_data->_monitor));
+ if ( gba ) {
+ dataPos = gba->data;
+ dataLen = gba->len;
}
- break;
+ } else {
+ g_warning("No profile data tracked for the specified item.");
}
- curr = g_slist_next(curr);
}
}
}
@@ -235,37 +223,24 @@ void ege_color_prof_tracker_get_profile( EgeColorProfTracker const * tracker, gp
}
}
-void ege_color_prof_tracker_get_profile_for( guint screenNum, guint monitor, gpointer* ptr, guint* len )
+void ege_color_prof_tracker_get_profile_for( guint monitor, gpointer* ptr, guint* len )
{
gpointer dataPos = 0;
guint dataLen = 0;
- GdkDisplay* display = gdk_display_get_default();
-
-#if GTK_CHECK_VERSION(3,10,0)
- GdkScreen* screen = (screenNum < 1) ? gdk_display_get_screen(display, screenNum) : 0;
-#else
- gint numScreens = gdk_display_get_n_screens(display);
- GdkScreen* screen = (screenNum < (guint)numScreens) ? gdk_display_get_screen(display, screenNum) : 0;
-#endif
+ GdkDisplay *display = gdk_display_get_default();
+ GdkScreen *screen = gdk_display_get_default_screen(display);
if ( screen ) {
- GSList* curr = tracked_screens;
- while ( curr ) {
- ScreenTrack* screenTrack = (ScreenTrack*)curr->data;
- if ( screenTrack->screen == screen ) {
- if ( monitor < screenTrack->profiles->len ) {
- GByteArray* gba = (GByteArray*)g_ptr_array_index( screenTrack->profiles, monitor );
- if ( gba ) {
- dataPos = gba->data;
- dataLen = gba->len;
- }
- } else {
- g_warning("No profile data tracked for the specified item.");
+ if ( tracked_screen ) {
+ if ( monitor < tracked_screen->profiles->len ) {
+ GByteArray* gba = (GByteArray*)g_ptr_array_index( tracked_screen->profiles, monitor );
+ if ( gba ) {
+ dataPos = gba->data;
+ dataLen = gba->len;
}
- break;
+ } else {
+ g_warning("No profile data tracked for the specified item.");
}
-
- curr = g_slist_next(curr);
}
}
@@ -303,51 +278,39 @@ void ege_color_prof_tracker_set_property( GObject* obj, guint propId, const GVal
void track_screen( GdkScreen* screen, EgeColorProfTracker* tracker )
{
- GSList* curr = tracked_screens;
- /* First remove the tracker from different screens */
- while ( curr ) {
- ScreenTrack* screenTrack = (ScreenTrack*)curr->data;
- if ( screenTrack->screen != screen ) {
- screenTrack->trackers = g_slist_remove_all(screenTrack->trackers, tracker);
- }
- curr = g_slist_next(curr);
- }
-
- curr = tracked_screens;
- while ( curr && ((ScreenTrack*)curr->data)->screen != screen ) {
- curr = g_slist_next(curr);
- }
-
- if ( curr ) {
+ if ( tracked_screen ) {
/* We found the screen already being tracked */
- ScreenTrack* screenTrack = (ScreenTrack*)curr->data;
- GSList* trackHook = g_slist_find( screenTrack->trackers, tracker );
+ GSList* trackHook = g_slist_find( tracked_screen->trackers, tracker );
if ( !trackHook ) {
- screenTrack->trackers = g_slist_append( screenTrack->trackers, tracker );
+ tracked_screen->trackers = g_slist_append( tracked_screen->trackers, tracker );
}
} else {
- ScreenTrack* newTrack = g_new(ScreenTrack, 1);
+ tracked_screen = g_new(ScreenTrack, 1);
+
+ GdkDisplay* display = gdk_display_get_default();
+
+#if GTK_CHECK_VERSION(3,22,0)
+ int numMonitors = gdk_display_get_n_monitors(display);
+#else
gint numMonitors = gdk_screen_get_n_monitors(screen);
- int i = 0;
- newTrack->screen = screen;
+#endif
+
#ifdef GDK_WINDOWING_X11
- newTrack->zeroSeen = FALSE;
- newTrack->otherSeen = FALSE;
+ tracked_screen->zeroSeen = FALSE;
+ tracked_screen->otherSeen = FALSE;
#endif /* GDK_WINDOWING_X11 */
- newTrack->trackers = g_slist_append( 0, tracker );
- newTrack->profiles = g_ptr_array_new();
- for ( i = 0; i < numMonitors; i++ ) {
- g_ptr_array_add( newTrack->profiles, 0 );
+ tracked_screen->trackers = g_slist_append( 0, tracker );
+ tracked_screen->profiles = g_ptr_array_new();
+ for ( int i = 0; i < numMonitors; i++ ) {
+ g_ptr_array_add( tracked_screen->profiles, 0 );
}
- tracked_screens = g_slist_append( tracked_screens, newTrack );
g_signal_connect( G_OBJECT(screen), "size-changed", G_CALLBACK( screen_size_changed_cb ), tracker );
#ifdef GDK_WINDOWING_X11
- GdkDisplay* display = gdk_display_get_default();
if (GDK_IS_X11_DISPLAY (display) ) {
// printf( "track_screen: Display is using X11\n" );
- add_x11_tracking_for_screen(screen, newTrack);
+ add_x11_tracking_for_screen(screen);
} else {
// printf( "track_screen: Display is not using X11\n" );
}
@@ -359,22 +322,18 @@ void track_screen( GdkScreen* screen, EgeColorProfTracker* tracker )
void target_finalized( gpointer data, GObject* where_the_object_was )
{
(void)data;
- GSList* curr = tracked_screens;
- while ( curr ) {
- ScreenTrack* track = (ScreenTrack*)curr->data;
- GSList* trackHook = track->trackers;
+ if ( tracked_screen ) {
+ GSList* trackHook = tracked_screen->trackers;
while ( trackHook ) {
if ( (void*)(((EgeColorProfTracker*)(trackHook->data))->private_data->_target) == (void*)where_the_object_was ) {
/* The tracked widget is now gone, remove it */
((EgeColorProfTracker*)trackHook->data)->private_data->_target = 0;
- track->trackers = g_slist_remove( track->trackers, trackHook );
+ tracked_screen->trackers = g_slist_remove( tracked_screen->trackers, trackHook );
trackHook = 0;
} else {
trackHook = g_slist_next( trackHook );
}
}
-
- curr = g_slist_next( curr );
}
}
@@ -388,11 +347,30 @@ void window_finalized( gpointer data, GObject* where_the_object_was )
void event_after_cb( GtkWidget* widget, GdkEvent* event, gpointer user_data )
{
if ( event->type == GDK_CONFIGURE ) {
- GdkScreen* screen = gtk_widget_get_screen(widget);
GdkWindow* window = gtk_widget_get_window (widget);
EgeColorProfTracker* tracker = (EgeColorProfTracker*)user_data;
+
+ // In old Gtk+ versions, we can directly find the ID number for a monitor.
+ // In Gtk+ >= 3.22, however, we need to figure out the ID
+#if GTK_CHECK_VERSION(3,22,0)
+ auto display = gdk_display_get_default();
+ auto monitor = gdk_display_get_monitor_at_window(display, window);
+
+ int n_monitors = gdk_display_get_n_monitors(display);
+
+ int monitorNum = -1;
+
+ // Now loop through the set of monitors and figure out whether this monitor matches
+ for (int i_monitor = 0; i_monitor < n_monitors; ++i_monitor) {
+ auto monitor_at_index = gdk_display_get_monitor(display, i_monitor);
+ if(monitor_at_index == monitor) monitorNum = i_monitor;
+ }
+#else
+ GdkScreen* screen = gtk_widget_get_screen(widget);
gint monitorNum = gdk_screen_get_monitor_at_window(screen, window);
- if ( monitorNum != tracker->private_data->_monitor ) {
+#endif
+
+ if ( monitorNum != tracker->private_data->_monitor && monitorNum != -1 ) {
tracker->private_data->_monitor = monitorNum;
g_signal_emit( G_OBJECT(tracker), signals[CHANGED], 0 );
}
@@ -422,24 +400,24 @@ void target_screen_changed_cb(GtkWidget* widget, GdkScreen* prev_screen, gpointe
void screen_size_changed_cb(GdkScreen* screen, gpointer user_data)
{
- GSList* curr = tracked_screens;
(void)user_data;
/* g_message("screen size changed to (%d, %d) with %d monitors for obj:%p", */
/* gdk_screen_get_width(screen), gdk_screen_get_height(screen), */
/* gdk_screen_get_n_monitors(screen), */
/* user_data); */
- while ( curr && ((ScreenTrack*)curr->data)->screen != screen ) {
- curr = g_slist_next(curr);
- }
- if ( curr ) {
- ScreenTrack* track = (ScreenTrack*)curr->data;
+ if ( tracked_screen ) {
+ GdkDisplay* display = gdk_display_get_default();
+
+#if GTK_CHECK_VERSION(3,22,0)
+ int numMonitors = gdk_display_get_n_monitors(display);
+#else
gint numMonitors = gdk_screen_get_n_monitors(screen);
- if ( numMonitors > (gint)track->profiles->len ) {
- guint i = 0;
- for ( i = track->profiles->len; i < (guint)numMonitors; i++ ) {
- g_ptr_array_add( track->profiles, 0 );
+#endif
+
+ if ( numMonitors > (gint)tracked_screen->profiles->len ) {
+ for ( guint i = tracked_screen->profiles->len; i < (guint)numMonitors; i++ ) {
+ g_ptr_array_add( tracked_screen->profiles, 0 );
#ifdef GDK_WINDOWING_X11
- GdkDisplay* display = gdk_display_get_default();
if (GDK_IS_X11_DISPLAY (display) ) {
gchar* name = g_strdup_printf( "_ICC_PROFILE_%d", i );
handle_property_change( screen, name );
@@ -447,7 +425,7 @@ void screen_size_changed_cb(GdkScreen* screen, gpointer user_data)
}
#endif /* GDK_WINDOWING_X11 */
}
- } else if ( numMonitors < (gint)track->profiles->len ) {
+ } else if ( numMonitors < (gint)tracked_screen->profiles->len ) {
/* g_message("The count of monitors decreased, remove some"); */
}
}
@@ -473,18 +451,10 @@ GdkFilterReturn x11_win_filter(GdkXEvent *xevent,
if ( stat ) {
GdkDisplay* display = gdk_x11_lookup_xdisplay(native->xproperty.display);
if ( display ) {
-#if GTK_CHECK_VERSION(3,10,0)
- gint screenCount = 1;
-#else
- gint screenCount = gdk_display_get_n_screens(display);
-#endif
GdkScreen* targetScreen = 0;
- gint i = 0;
- for ( i = 0; i < screenCount; i++ ) {
- GdkScreen* sc = gdk_display_get_screen( display, i );
- if ( tmp.screen == GDK_SCREEN_XSCREEN(sc) ) {
- targetScreen = sc;
- }
+ GdkScreen* sc = gdk_display_get_default_screen(display);
+ if ( tmp.screen == GDK_SCREEN_XSCREEN(sc) ) {
+ targetScreen = sc;
}
handle_property_change( targetScreen, name );
@@ -517,7 +487,7 @@ void handle_property_change(GdkScreen* screen, const gchar* name)
unsigned long bytesAfter = 0;
unsigned char* prop = 0;
- clear_profile( screen, monitor );
+ clear_profile( monitor );
if ( XGetWindowProperty( xdisplay, GDK_WINDOW_XID(gdk_screen_get_root_window(screen)),
atom, 0, size, False, AnyPropertyType,
@@ -534,23 +504,23 @@ void handle_property_change(GdkScreen* screen, const gchar* name)
atom, 0, size, False, AnyPropertyType,
&actualType, &actualFormat, &nitems, &bytesAfter, &prop ) == Success ) {
gpointer profile = g_memdup( prop, nitems );
- set_profile( screen, monitor, (const guint8*)profile, nitems );
+ set_profile( monitor, (const guint8*)profile, nitems );
XFree(prop);
} else {
g_warning("Problem reading profile from root window");
}
} else {
/* clear it */
- set_profile( screen, monitor, 0, 0 );
+ set_profile( monitor, 0, 0 );
}
} else {
g_warning("error loading profile property");
}
}
- fire(screen, monitor);
+ fire(monitor);
}
-void add_x11_tracking_for_screen(GdkScreen* screen, ScreenTrack* screenTrack)
+void add_x11_tracking_for_screen(GdkScreen* screen)
{
Display* xdisplay = GDK_SCREEN_XDISPLAY(screen);
GdkWindow* root = gdk_screen_get_root_window(screen);
@@ -567,12 +537,18 @@ void add_x11_tracking_for_screen(GdkScreen* screen, ScreenTrack* screenTrack)
/* Look for any profiles attached to this root window */
if ( propArray ) {
int j = 0;
+
+#if GTK_CHECK_VERSION(3,22,0)
+ auto display = gdk_display_get_default();
+ int numMonitors = gdk_display_get_n_monitors(display);
+#else
gint numMonitors = gdk_screen_get_n_monitors(screen);
+#endif
if ( baseAtom != None ) {
for ( i = 0; i < numWinProps; i++ ) {
if ( baseAtom == propArray[i] ) {
- screenTrack->zeroSeen = TRUE;
+ tracked_screen->zeroSeen = TRUE;
handle_property_change( screen, "_ICC_PROFILE" );
}
}
@@ -586,7 +562,7 @@ void add_x11_tracking_for_screen(GdkScreen* screen, ScreenTrack* screenTrack)
if ( atom != None ) {
for ( j = 0; j < numWinProps; j++ ) {
if ( atom == propArray[j] ) {
- screenTrack->otherSeen = TRUE;
+ tracked_screen->otherSeen = TRUE;
handle_property_change( screen, name );
}
}
@@ -599,65 +575,46 @@ void add_x11_tracking_for_screen(GdkScreen* screen, ScreenTrack* screenTrack)
}
}
-void fire(GdkScreen* screen, gint monitor)
+void fire(gint monitor)
{
- GSList* curr = tracked_screens;
- while ( curr ) {
- ScreenTrack* track = (ScreenTrack*)curr->data;
- if ( track->screen == screen) {
- GSList* trackHook = track->trackers;
- while ( trackHook ) {
- EgeColorProfTracker* tracker = (EgeColorProfTracker*)(trackHook->data);
- if ( (monitor == -1) || (tracker->private_data->_monitor == monitor) ) {
- g_signal_emit( G_OBJECT(tracker), signals[CHANGED], 0 );
- }
- trackHook = g_slist_next(trackHook);
+ if ( tracked_screen ) {
+ GSList* trackHook = tracked_screen->trackers;
+
+ while ( trackHook ) {
+ EgeColorProfTracker* tracker = (EgeColorProfTracker*)(trackHook->data);
+ if ( (monitor == -1) || (tracker->private_data->_monitor == monitor) ) {
+ g_signal_emit( G_OBJECT(tracker), signals[CHANGED], 0 );
}
+ trackHook = g_slist_next(trackHook);
}
- curr = g_slist_next(curr);
}
}
-static void clear_profile( GdkScreen* screen, guint monitor )
+static void clear_profile( guint monitor )
{
- GSList* curr = tracked_screens;
- while ( curr && ((ScreenTrack*)curr->data)->screen != screen ) {
- curr = g_slist_next(curr);
- }
- if ( curr ) {
- ScreenTrack* track = (ScreenTrack*)curr->data;
- guint i = 0;
+ if ( tracked_screen ) {
GByteArray* previous = 0;
- for ( i = track->profiles->len; i <= monitor; i++ ) {
- g_ptr_array_add( track->profiles, 0 );
+ for ( guint i = tracked_screen->profiles->len; i <= monitor; i++ ) {
+ g_ptr_array_add( tracked_screen->profiles, 0 );
}
- previous = (GByteArray*)g_ptr_array_index( track->profiles, monitor );
+ previous = (GByteArray*)g_ptr_array_index( tracked_screen->profiles, monitor );
if ( previous ) {
g_byte_array_free( previous, TRUE );
}
- track->profiles->pdata[monitor] = 0;
+ tracked_screen->profiles->pdata[monitor] = 0;
}
}
-static void set_profile( GdkScreen* screen, guint monitor, const guint8* data, guint len )
+static void set_profile( guint monitor, const guint8* data, guint len )
{
- GSList* curr = tracked_screens;
- while ( curr && ((ScreenTrack*)curr->data)->screen != screen ) {
- curr = g_slist_next(curr);
- }
- if ( curr ) {
- /* Something happened to a screen being tracked. */
- ScreenTrack* track = (ScreenTrack*)curr->data;
- gint screenNum = gdk_screen_get_number(screen);
- guint i = 0;
- GByteArray* previous = 0;
+ if ( tracked_screen ) {
GSList* abstracts = 0;
- for ( i = track->profiles->len; i <= monitor; i++ ) {
- g_ptr_array_add( track->profiles, 0 );
+ for ( guint i = tracked_screen->profiles->len; i <= monitor; i++ ) {
+ g_ptr_array_add( tracked_screen->profiles, 0 );
}
- previous = (GByteArray*)g_ptr_array_index( track->profiles, monitor );
+ GByteArray *previous = (GByteArray*)g_ptr_array_index( tracked_screen->profiles, monitor );
if ( previous ) {
g_byte_array_free( previous, TRUE );
}
@@ -665,13 +622,13 @@ static void set_profile( GdkScreen* screen, guint monitor, const guint8* data, g
if ( data && len ) {
GByteArray* newBytes = g_byte_array_sized_new( len );
newBytes = g_byte_array_append( newBytes, data, len );
- track->profiles->pdata[monitor] = newBytes;
+ tracked_screen->profiles->pdata[monitor] = newBytes;
} else {
- track->profiles->pdata[monitor] = 0;
+ tracked_screen->profiles->pdata[monitor] = 0;
}
for ( abstracts = abstract_trackers; abstracts; abstracts = g_slist_next(abstracts) ) {
- g_signal_emit( G_OBJECT(abstracts->data), signals[MODIFIED], 0, screenNum, monitor );
+ g_signal_emit( G_OBJECT(abstracts->data), signals[MODIFIED], 0, monitor );
}
}
}
diff --git a/src/ege-color-prof-tracker.h b/src/ege-color-prof-tracker.h
index 19423c19f..9b8babf18 100644
--- a/src/ege-color-prof-tracker.h
+++ b/src/ege-color-prof-tracker.h
@@ -94,7 +94,7 @@ GType ege_color_prof_tracker_get_type( void );
EgeColorProfTracker* ege_color_prof_tracker_new( GtkWidget* target );
void ege_color_prof_tracker_get_profile( EgeColorProfTracker const * tracker, gpointer* ptr, guint* len );
-void ege_color_prof_tracker_get_profile_for( guint screen, guint monitor, gpointer* ptr, guint* len );
+void ege_color_prof_tracker_get_profile_for( guint monitor, gpointer* ptr, guint* len );
G_END_DECLS
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index 2479fa453..36ee1fe6a 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -133,7 +133,7 @@ public:
}
private:
- static void hook(EgeColorProfTracker *tracker, gint a, gint b, CMSPrefWatcher *watcher);
+ static void hook(EgeColorProfTracker *tracker, gint b, CMSPrefWatcher *watcher);
class DisplayProfileWatcher : public Inkscape::Preferences::Observer {
public:
@@ -172,16 +172,16 @@ private:
};
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
-void CMSPrefWatcher::hook(EgeColorProfTracker * /*tracker*/, gint screen, gint monitor, CMSPrefWatcher * /*watcher*/)
+void CMSPrefWatcher::hook(EgeColorProfTracker * /*tracker*/, gint monitor, CMSPrefWatcher * /*watcher*/)
{
unsigned char* buf = 0;
guint len = 0;
- ege_color_prof_tracker_get_profile_for( screen, monitor, reinterpret_cast<gpointer*>(&buf), &len );
- Glib::ustring id = Inkscape::CMSSystem::setDisplayPer( buf, len, screen, monitor );
+ ege_color_prof_tracker_get_profile_for( monitor, reinterpret_cast<gpointer*>(&buf), &len );
+ Glib::ustring id = Inkscape::CMSSystem::setDisplayPer( buf, len, monitor );
}
#else
-void CMSPrefWatcher::hook(EgeColorProfTracker * /*tracker*/, gint /*screen*/, gint /*monitor*/, CMSPrefWatcher * /*watcher*/)
+void CMSPrefWatcher::hook(EgeColorProfTracker * /*tracker*/, gint /*monitor*/, CMSPrefWatcher * /*watcher*/)
{
}
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
@@ -660,7 +660,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
bool fromDisplay = prefs->getBool( "/options/displayprofile/from_display");
if ( fromDisplay ) {
- Glib::ustring id = Inkscape::CMSSystem::getDisplayId( 0, 0 );
+ Glib::ustring id = Inkscape::CMSSystem::getDisplayId( 0 );
bool enabled = false;
dtw->canvas->_cms_key = id;
@@ -944,9 +944,8 @@ void sp_dtw_color_profile_event(EgeColorProfTracker */*tracker*/, SPDesktopWidge
// Handle profile changes
GdkScreen* screen = gtk_widget_get_screen(GTK_WIDGET(dtw));
GdkWindow *window = gtk_widget_get_window(gtk_widget_get_toplevel(GTK_WIDGET(dtw)));
- gint screenNum = gdk_screen_get_number(screen);
gint monitor = gdk_screen_get_monitor_at_window(screen, window);
- Glib::ustring id = Inkscape::CMSSystem::getDisplayId( screenNum, monitor );
+ Glib::ustring id = Inkscape::CMSSystem::getDisplayId( monitor );
bool enabled = false;
dtw->canvas->_cms_key = id;
dtw->requestCanvasUpdate();