Changeset 0ccc84ad4dfc694659e9e1bb251584bdf9b7149b
- Timestamp:
- 07/30/2008 04:46:44 PM
(4 months ago)
- Author:
- Dave Foster <daf@minuslab.net>
- git-committer:
- Dave Foster <daf@minuslab.net> 1217461604 -0400
- git-parent:
[69c1750dc41ea3051e2a4abb3f653be3536d9ae1]
- git-author:
- Dave Foster <daf@minuslab.net> 1217461604 -0400
- Message:
Make default selections on program start work better for xinerama.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r69c1750 |
r0ccc84a |
|
| 26 | 26 | #include "gcs-i18n.h" |
|---|
| 27 | 27 | #include "Util.h" |
|---|
| | 28 | #include <algorithm> |
|---|
| 28 | 29 | |
|---|
| 29 | 30 | #ifdef USE_XINERAMA |
|---|
| … | … | |
| 312 | 313 | Config *cfg = Config::get_instance(); |
|---|
| 313 | 314 | std::vector<Glib::ustring> cfg_displays; |
|---|
| 314 | | if( cfg->get_bg_groups(cfg_displays) ) { |
|---|
| 315 | | |
|---|
| 316 | | SetBG::SetMode m; |
|---|
| 317 | | Gdk::Color c; |
|---|
| | 315 | if( cfg->get_bg_groups(cfg_displays) ) |
|---|
| | 316 | { |
|---|
| | 317 | SetBG::SetMode m; |
|---|
| | 318 | Gdk::Color c; |
|---|
| 318 | 319 | Glib::ustring default_selection; |
|---|
| | 320 | Glib::ustring file; |
|---|
| 319 | 321 | |
|---|
| 320 | 322 | // get default display |
|---|
| 321 | | Glib::RefPtr<Gdk::DisplayManager> manager = Gdk::DisplayManager::get(); |
|---|
| 322 | | Glib::RefPtr<Gdk::Display> disp = manager->get_default_display(); |
|---|
| 323 | | Glib::RefPtr<Gdk::Screen> screen = disp->get_default_screen(); |
|---|
| 324 | | |
|---|
| 325 | | // TODO: will be a bug if default has no config entry :P |
|---|
| 326 | | if (!cfg->get_bg(screen->make_display_name(), default_selection, m, c)) { |
|---|
| | 323 | if (this->is_xinerama) |
|---|
| | 324 | { |
|---|
| | 325 | // we want the lowest numbered xinerama display (slightly hacky) |
|---|
| | 326 | int max = 99; |
|---|
| | 327 | for (std::vector<Glib::ustring>::iterator i = cfg_displays.begin(); i != cfg_displays.end(); i++) |
|---|
| | 328 | { |
|---|
| | 329 | if ((*i).substr(0, 4) != "xin_") |
|---|
| | 330 | continue; |
|---|
| | 331 | |
|---|
| | 332 | std::stringstream stream((*i).substr(4)); |
|---|
| | 333 | int newmax; |
|---|
| | 334 | stream >> newmax; |
|---|
| | 335 | if (newmax < max) |
|---|
| | 336 | max = newmax; |
|---|
| | 337 | } |
|---|
| | 338 | |
|---|
| | 339 | std::ostringstream ostr; |
|---|
| | 340 | ostr << "xin_" << max; |
|---|
| | 341 | default_selection = ostr.str(); |
|---|
| | 342 | } |
|---|
| | 343 | else |
|---|
| | 344 | default_selection = Gdk::DisplayManager::get()->get_default_display()->get_default_screen()->make_display_name(); |
|---|
| | 345 | |
|---|
| | 346 | // make sure whatever we came up with is in the config file, if not, just return |
|---|
| | 347 | if (find(cfg_displays.begin(), cfg_displays.end(), default_selection) == cfg_displays.end()) |
|---|
| | 348 | return; |
|---|
| | 349 | |
|---|
| | 350 | if (!cfg->get_bg(default_selection, file, m, c)) { |
|---|
| 327 | 351 | // failed. return? |
|---|
| 328 | 352 | return; |
|---|
| … | … | |
| 336 | 360 | for (Gtk::TreeIter iter = view.store->children().begin(); iter != view.store->children().end(); iter++) |
|---|
| 337 | 361 | { |
|---|
| 338 | | if ( (*iter)[view.record.Filename] == default_selection) { |
|---|
| | 362 | if ( (*iter)[view.record.CurBGOnDisp] == default_selection) { |
|---|
| 339 | 363 | view.view.get_selection()->select(iter); |
|---|
| 340 | 364 | view.view.scroll_to_row(Gtk::TreeModel::Path(iter), 0.5); |
|---|