Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: chrome/browser/ui/libgtk2ui/print_dialog_gtk2.cc

Issue 543093002: Fix focus on popup GTK dialogs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/libgtk2ui/print_dialog_gtk2.h" 5 #include "chrome/browser/ui/libgtk2ui/print_dialog_gtk2.h"
6 6
7 #include <gtk/gtkunixprint.h> 7 #include <gtk/gtkunixprint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
16 #include "base/files/file_util_proxy.h" 16 #include "base/files/file_util_proxy.h"
17 #include "base/lazy_instance.h" 17 #include "base/lazy_instance.h"
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/message_loop/message_loop_proxy.h" 19 #include "base/message_loop/message_loop_proxy.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "base/values.h" 21 #include "base/values.h"
22 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" 22 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h"
23 #include "chrome/browser/ui/libgtk2ui/printing_gtk2_util.h" 23 #include "chrome/browser/ui/libgtk2ui/printing_gtk2_util.h"
24 #include "printing/metafile.h" 24 #include "printing/metafile.h"
25 #include "printing/print_job_constants.h" 25 #include "printing/print_job_constants.h"
26 #include "printing/print_settings.h" 26 #include "printing/print_settings.h"
27 #include "ui/aura/window.h" 27 #include "ui/aura/window.h"
28 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h"
28 29
29 using content::BrowserThread; 30 using content::BrowserThread;
30 using printing::PageRanges; 31 using printing::PageRanges;
31 using printing::PrintSettings; 32 using printing::PrintSettings;
32 33
33 namespace { 34 namespace {
34 35
35 // CUPS Duplex attribute and values. 36 // CUPS Duplex attribute and values.
36 const char kCUPSDuplex[] = "cups-Duplex"; 37 const char kCUPSDuplex[] = "cups-Duplex";
37 const char kDuplexNone[] = "None"; 38 const char kDuplexNone[] = "None";
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 gtk_print_unix_dialog_set_embed_page_setup(GTK_PRINT_UNIX_DIALOG(dialog_), 347 gtk_print_unix_dialog_set_embed_page_setup(GTK_PRINT_UNIX_DIALOG(dialog_),
347 TRUE); 348 TRUE);
348 gtk_print_unix_dialog_set_support_selection(GTK_PRINT_UNIX_DIALOG(dialog_), 349 gtk_print_unix_dialog_set_support_selection(GTK_PRINT_UNIX_DIALOG(dialog_),
349 TRUE); 350 TRUE);
350 gtk_print_unix_dialog_set_has_selection(GTK_PRINT_UNIX_DIALOG(dialog_), 351 gtk_print_unix_dialog_set_has_selection(GTK_PRINT_UNIX_DIALOG(dialog_),
351 has_selection); 352 has_selection);
352 gtk_print_unix_dialog_set_settings(GTK_PRINT_UNIX_DIALOG(dialog_), 353 gtk_print_unix_dialog_set_settings(GTK_PRINT_UNIX_DIALOG(dialog_),
353 gtk_settings_); 354 gtk_settings_);
354 g_signal_connect(dialog_, "response", G_CALLBACK(OnResponseThunk), this); 355 g_signal_connect(dialog_, "response", G_CALLBACK(OnResponseThunk), this);
355 gtk_widget_show(dialog_); 356 gtk_widget_show(dialog_);
357
358 // We need to call gtk_window_present after making the widgets visible to make
359 // sure window gets correctly raised and gets focus.
360 int time = views::X11DesktopHandler::get()->wm_user_time_ms();
361 gtk_window_present_with_time(GTK_WINDOW(dialog_), time);
356 } 362 }
357 363
358 void PrintDialogGtk2::PrintDocument(const printing::Metafile* metafile, 364 void PrintDialogGtk2::PrintDocument(const printing::Metafile* metafile,
359 const base::string16& document_name) { 365 const base::string16& document_name) {
360 // This runs on the print worker thread, does not block the UI thread. 366 // This runs on the print worker thread, does not block the UI thread.
361 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); 367 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
362 368
363 // The document printing tasks can outlive the PrintingContext that created 369 // The document printing tasks can outlive the PrintingContext that created
364 // this dialog. 370 // this dialog.
365 AddRef(); 371 AddRef();
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 context_->InitWithSettings(*settings); 531 context_->InitWithSettings(*settings);
526 } 532 }
527 533
528 void PrintDialogGtk2::OnWindowDestroying(aura::Window* window) { 534 void PrintDialogGtk2::OnWindowDestroying(aura::Window* window) {
529 DCHECK_EQ(libgtk2ui::GetAuraTransientParent(dialog_), window); 535 DCHECK_EQ(libgtk2ui::GetAuraTransientParent(dialog_), window);
530 536
531 libgtk2ui::ClearAuraTransientParent(dialog_); 537 libgtk2ui::ClearAuraTransientParent(dialog_);
532 window->RemoveObserver(this); 538 window->RemoveObserver(this);
533 Release(); 539 Release();
534 } 540 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698