OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <gtk/gtk.h> | 5 #include <gtk/gtk.h> |
6 #include <math.h> | 6 #include <math.h> |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 cairo_stroke(cairo_context); | 134 cairo_stroke(cairo_context); |
135 } | 135 } |
136 | 136 |
137 DisconnectWindowGtk::DisconnectWindowGtk() | 137 DisconnectWindowGtk::DisconnectWindowGtk() |
138 : disconnect_window_(nullptr), | 138 : disconnect_window_(nullptr), |
139 current_width_(0), | 139 current_width_(0), |
140 current_height_(0) { | 140 current_height_(0) { |
141 } | 141 } |
142 | 142 |
143 DisconnectWindowGtk::~DisconnectWindowGtk() { | 143 DisconnectWindowGtk::~DisconnectWindowGtk() { |
144 DCHECK(CalledOnValidThread()); | 144 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
145 | 145 |
146 if (disconnect_window_) { | 146 if (disconnect_window_) { |
147 gtk_widget_destroy(disconnect_window_); | 147 gtk_widget_destroy(disconnect_window_); |
148 disconnect_window_ = nullptr; | 148 disconnect_window_ = nullptr; |
149 } | 149 } |
150 } | 150 } |
151 | 151 |
152 void DisconnectWindowGtk::Start( | 152 void DisconnectWindowGtk::Start( |
153 const base::WeakPtr<ClientSessionControl>& client_session_control) { | 153 const base::WeakPtr<ClientSessionControl>& client_session_control) { |
154 DCHECK(CalledOnValidThread()); | 154 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
155 DCHECK(!client_session_control_.get()); | 155 DCHECK(!client_session_control_.get()); |
156 DCHECK(client_session_control.get()); | 156 DCHECK(client_session_control.get()); |
157 DCHECK(!disconnect_window_); | 157 DCHECK(!disconnect_window_); |
158 | 158 |
159 client_session_control_ = client_session_control; | 159 client_session_control_ = client_session_control; |
160 | 160 |
161 // Create the window. | 161 // Create the window. |
162 disconnect_window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 162 disconnect_window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
163 GtkWindow* window = GTK_WINDOW(disconnect_window_); | 163 GtkWindow* window = GTK_WINDOW(disconnect_window_); |
164 | 164 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 std::string client_jid = client_session_control_->client_jid(); | 247 std::string client_jid = client_session_control_->client_jid(); |
248 base::string16 username = | 248 base::string16 username = |
249 base::UTF8ToUTF16(client_jid.substr(0, client_jid.find('/'))); | 249 base::UTF8ToUTF16(client_jid.substr(0, client_jid.find('/'))); |
250 gtk_label_set_text( | 250 gtk_label_set_text( |
251 GTK_LABEL(message_), | 251 GTK_LABEL(message_), |
252 l10n_util::GetStringFUTF8(IDS_MESSAGE_SHARED, username).c_str()); | 252 l10n_util::GetStringFUTF8(IDS_MESSAGE_SHARED, username).c_str()); |
253 gtk_window_present(window); | 253 gtk_window_present(window); |
254 } | 254 } |
255 | 255 |
256 void DisconnectWindowGtk::OnClicked(GtkButton* button) { | 256 void DisconnectWindowGtk::OnClicked(GtkButton* button) { |
257 DCHECK(CalledOnValidThread()); | 257 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
258 | 258 |
259 if (client_session_control_.get()) | 259 if (client_session_control_.get()) |
260 client_session_control_->DisconnectSession(protocol::OK); | 260 client_session_control_->DisconnectSession(protocol::OK); |
261 } | 261 } |
262 | 262 |
263 gboolean DisconnectWindowGtk::OnDelete(GtkWidget* window, | 263 gboolean DisconnectWindowGtk::OnDelete(GtkWidget* window, |
264 GdkEvent* event) { | 264 GdkEvent* event) { |
265 DCHECK(CalledOnValidThread()); | 265 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
266 | 266 |
267 if (client_session_control_.get()) | 267 if (client_session_control_.get()) |
268 client_session_control_->DisconnectSession(protocol::OK); | 268 client_session_control_->DisconnectSession(protocol::OK); |
269 return TRUE; | 269 return TRUE; |
270 } | 270 } |
271 | 271 |
272 gboolean DisconnectWindowGtk::OnConfigure(GtkWidget* widget, | 272 gboolean DisconnectWindowGtk::OnConfigure(GtkWidget* widget, |
273 GdkEventConfigure* event) { | 273 GdkEventConfigure* event) { |
274 DCHECK(CalledOnValidThread()); | 274 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
275 | 275 |
276 // Only generate bitmaps if the size has actually changed. | 276 // Only generate bitmaps if the size has actually changed. |
277 if (event->width == current_width_ && event->height == current_height_) | 277 if (event->width == current_width_ && event->height == current_height_) |
278 return FALSE; | 278 return FALSE; |
279 | 279 |
280 current_width_ = event->width; | 280 current_width_ = event->width; |
281 current_height_ = event->height; | 281 current_height_ = event->height; |
282 | 282 |
283 // gdk_window_set_back_pixmap() is not supported in GDK3, and | 283 // gdk_window_set_back_pixmap() is not supported in GDK3, and |
284 // background drawing is handled in OnDraw(). | 284 // background drawing is handled in OnDraw(). |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 gdk_window_invalidate_rect(widget->window, nullptr, TRUE); | 320 gdk_window_invalidate_rect(widget->window, nullptr, TRUE); |
321 #endif // GTK_MAJOR_VERSION == 2 | 321 #endif // GTK_MAJOR_VERSION == 2 |
322 | 322 |
323 return FALSE; | 323 return FALSE; |
324 } | 324 } |
325 | 325 |
326 gboolean DisconnectWindowGtk::OnDraw(GtkWidget* widget, cairo_t* cr) { | 326 gboolean DisconnectWindowGtk::OnDraw(GtkWidget* widget, cairo_t* cr) { |
327 #if GTK_MAJOR_VERSION == 2 | 327 #if GTK_MAJOR_VERSION == 2 |
328 NOTREACHED(); | 328 NOTREACHED(); |
329 #endif | 329 #endif |
330 DCHECK(CalledOnValidThread()); | 330 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
331 | 331 |
332 DrawBackground(cr, current_width_, current_height_); | 332 DrawBackground(cr, current_width_, current_height_); |
333 return FALSE; | 333 return FALSE; |
334 } | 334 } |
335 | 335 |
336 gboolean DisconnectWindowGtk::OnButtonPress(GtkWidget* widget, | 336 gboolean DisconnectWindowGtk::OnButtonPress(GtkWidget* widget, |
337 GdkEventButton* event) { | 337 GdkEventButton* event) { |
338 DCHECK(CalledOnValidThread()); | 338 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
339 | 339 |
340 gtk_window_begin_move_drag(GTK_WINDOW(disconnect_window_), | 340 gtk_window_begin_move_drag(GTK_WINDOW(disconnect_window_), |
341 event->button, | 341 event->button, |
342 event->x_root, | 342 event->x_root, |
343 event->y_root, | 343 event->y_root, |
344 event->time); | 344 event->time); |
345 return FALSE; | 345 return FALSE; |
346 } | 346 } |
347 | 347 |
348 } // namespace | 348 } // namespace |
349 | 349 |
350 // static | 350 // static |
351 std::unique_ptr<HostWindow> HostWindow::CreateDisconnectWindow() { | 351 std::unique_ptr<HostWindow> HostWindow::CreateDisconnectWindow() { |
352 return base::MakeUnique<DisconnectWindowGtk>(); | 352 return base::MakeUnique<DisconnectWindowGtk>(); |
353 } | 353 } |
354 | 354 |
355 } // namespace remoting | 355 } // namespace remoting |
OLD | NEW |