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

Side by Side Diff: chrome/browser/gtk/browser_window_gtk.cc

Issue 173030: Port more browser focus tests to linux.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: working on windows Created 11 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser_focus_uitest.cc ('k') | chrome/browser/gtk/extension_shelf_gtk.h » ('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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/gtk/browser_window_gtk.h" 5 #include "chrome/browser/gtk/browser_window_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 #include <X11/XF86keysym.h> 8 #include <X11/XF86keysym.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 GdkModifierType modifier) { 479 GdkModifierType modifier) {
480 if (!HandleCustomAccelerator(keyval, modifier, browser_.get())) { 480 if (!HandleCustomAccelerator(keyval, modifier, browser_.get())) {
481 // Pass the accelerator on to GTK. 481 // Pass the accelerator on to GTK.
482 gtk_accel_groups_activate(G_OBJECT(window_), keyval, modifier); 482 gtk_accel_groups_activate(G_OBJECT(window_), keyval, modifier);
483 } 483 }
484 } 484 }
485 485
486 gboolean BrowserWindowGtk::OnCustomFrameExpose(GtkWidget* widget, 486 gboolean BrowserWindowGtk::OnCustomFrameExpose(GtkWidget* widget,
487 GdkEventExpose* event, 487 GdkEventExpose* event,
488 BrowserWindowGtk* window) { 488 BrowserWindowGtk* window) {
489 static NineBox* default_background = NULL;
490 static NineBox* default_background_inactive = NULL;
491 static NineBox* default_background_otr = NULL;
492 static NineBox* default_background_otr_inactive = NULL;
493
494 ThemeProvider* theme_provider = 489 ThemeProvider* theme_provider =
495 window->browser()->profile()->GetThemeProvider(); 490 window->browser()->profile()->GetThemeProvider();
496 if (!default_background) {
497 default_background = new NineBox(theme_provider,
498 0, IDR_THEME_FRAME, 0, 0, 0, 0, 0, 0, 0);
499 default_background_inactive = new NineBox(theme_provider,
500 0, IDR_THEME_FRAME_INACTIVE, 0, 0, 0, 0, 0, 0, 0);
501 default_background_otr = new NineBox(theme_provider,
502 0, IDR_THEME_FRAME_INCOGNITO, 0, 0, 0, 0, 0, 0, 0);
503 default_background_otr_inactive = new NineBox(theme_provider,
504 0, IDR_THEME_FRAME_INCOGNITO_INACTIVE, 0, 0, 0, 0, 0, 0, 0);
505 }
506 491
507 // Draw the default background. 492 // Draw the default background.
508 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); 493 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window));
509 cairo_rectangle(cr, event->area.x, event->area.y, event->area.width, 494 cairo_rectangle(cr, event->area.x, event->area.y, event->area.width,
510 event->area.height); 495 event->area.height);
511 cairo_clip(cr); 496 cairo_clip(cr);
512 NineBox* image = NULL; 497
498 int image_name;
513 if (window->IsActive()) { 499 if (window->IsActive()) {
514 image = window->browser()->profile()->IsOffTheRecord() 500 image_name = window->browser()->profile()->IsOffTheRecord() ?
515 ? default_background_otr : default_background; 501 IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME;
516 } else { 502 } else {
517 image = window->browser()->profile()->IsOffTheRecord() 503 image_name = window->browser()->profile()->IsOffTheRecord() ?
518 ? default_background_otr_inactive : default_background_inactive; 504 IDR_THEME_FRAME_INCOGNITO_INACTIVE : IDR_THEME_FRAME_INACTIVE;
519 } 505 }
520 image->RenderTopCenterStrip(cr, 0, 0, widget->allocation.width); 506 GdkPixbuf* pixbuf = theme_provider->GetPixbufNamed(image_name);
507 gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0);
508 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
509 cairo_rectangle(cr, event->area.x, event->area.y,
510 event->area.width, event->area.height);
511 cairo_fill(cr);
521 512
522 if (theme_provider->HasCustomImage(IDR_THEME_FRAME_OVERLAY)) { 513 if (theme_provider->HasCustomImage(IDR_THEME_FRAME_OVERLAY)) {
523 GdkPixbuf* theme_overlay = theme_provider->GetPixbufNamed( 514 GdkPixbuf* theme_overlay = theme_provider->GetPixbufNamed(
524 window->IsActive() ? IDR_THEME_FRAME_OVERLAY 515 window->IsActive() ? IDR_THEME_FRAME_OVERLAY
525 : IDR_THEME_FRAME_OVERLAY_INACTIVE); 516 : IDR_THEME_FRAME_OVERLAY_INACTIVE);
526 gdk_cairo_set_source_pixbuf(cr, theme_overlay, 0, 0); 517 gdk_cairo_set_source_pixbuf(cr, theme_overlay, 0, 0);
527 cairo_paint(cr); 518 cairo_paint(cr);
528 } 519 }
529 520
530 DrawContentShadow(cr, window); 521 DrawContentShadow(cr, window);
531 522
532 cairo_destroy(cr); 523 cairo_destroy(cr);
533 524
534 if (window->use_custom_frame_.GetValue() && !window->IsMaximized()) { 525 if (window->use_custom_frame_.GetValue() && !window->IsMaximized()) {
535 static NineBox custom_frame_border( 526 static NineBox custom_frame_border(
536 theme_provider, 527 IDR_WINDOW_TOP_LEFT_CORNER,
537 IDR_WINDOW_TOP_LEFT_CORNER, 528 IDR_WINDOW_TOP_CENTER,
538 IDR_WINDOW_TOP_CENTER, 529 IDR_WINDOW_TOP_RIGHT_CORNER,
539 IDR_WINDOW_TOP_RIGHT_CORNER, 530 IDR_WINDOW_LEFT_SIDE,
540 IDR_WINDOW_LEFT_SIDE, 531 NULL,
541 NULL, 532 IDR_WINDOW_RIGHT_SIDE,
542 IDR_WINDOW_RIGHT_SIDE, 533 IDR_WINDOW_BOTTOM_LEFT_CORNER,
543 IDR_WINDOW_BOTTOM_LEFT_CORNER, 534 IDR_WINDOW_BOTTOM_CENTER,
544 IDR_WINDOW_BOTTOM_CENTER, 535 IDR_WINDOW_BOTTOM_RIGHT_CORNER);
545 IDR_WINDOW_BOTTOM_RIGHT_CORNER);
546 536
547 custom_frame_border.RenderToWidget(widget); 537 custom_frame_border.RenderToWidget(widget);
548 } 538 }
549 539
550 return FALSE; // Allow subwidgets to paint. 540 return FALSE; // Allow subwidgets to paint.
551 } 541 }
552 542
553 // static 543 // static
554 void BrowserWindowGtk::DrawContentShadow(cairo_t* cr, 544 void BrowserWindowGtk::DrawContentShadow(cairo_t* cr,
555 BrowserWindowGtk* window) { 545 BrowserWindowGtk* window) {
556 // Draw the shadow above the toolbar. Tabs on the tabstrip will draw over us. 546 // Draw the shadow above the toolbar. Tabs on the tabstrip will draw over us.
557 ThemeProvider* theme_provider = 547 ThemeProvider* theme_provider =
558 window->browser()->profile()->GetThemeProvider(); 548 window->browser()->profile()->GetThemeProvider();
559 static NineBox top_shadow(theme_provider,
560 0, IDR_CONTENT_TOP_CENTER, 0, 0, 0, 0, 0, 0, 0);
561 int left_x, top_y; 549 int left_x, top_y;
562 gtk_widget_translate_coordinates(window->content_vbox_, 550 gtk_widget_translate_coordinates(window->content_vbox_,
563 GTK_WIDGET(window->window_), 0, 0, &left_x, 551 GTK_WIDGET(window->window_), 0, 0, &left_x,
564 &top_y); 552 &top_y);
565 int width = window->content_vbox_->allocation.width; 553 int width = window->content_vbox_->allocation.width;
566 top_shadow.RenderTopCenterStrip(cr, 554
567 left_x, top_y - kContentShadowThickness, width); 555 GdkPixbuf* top_center = theme_provider->GetPixbufNamed(IDR_CONTENT_TOP_CENTER) ;
tony 2009/08/19 17:47:26 Nit: 80 cols.
556 gdk_cairo_set_source_pixbuf(cr, top_center,
557 left_x, top_y - kContentShadowThickness);
558 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
559 cairo_rectangle(cr, left_x, top_y - kContentShadowThickness, width,
560 gdk_pixbuf_get_height(top_center));
561 cairo_fill(cr);
568 562
569 // Only draw the rest of the shadow if the user has the custom frame enabled. 563 // Only draw the rest of the shadow if the user has the custom frame enabled.
570 if (!window->use_custom_frame_.GetValue()) 564 if (!window->use_custom_frame_.GetValue())
571 return; 565 return;
572 566
573 // The top left corner has a width of 3 pixels. On Windows, the last column 567 // The top left corner has a width of 3 pixels. On Windows, the last column
574 // of pixels overlap the toolbar. We just crop it off on Linux. The top 568 // of pixels overlap the toolbar. We just crop it off on Linux. The top
575 // corners extend to the base of the toolbar (one pixel above the dividing 569 // corners extend to the base of the toolbar (one pixel above the dividing
576 // line). 570 // line).
577 int right_x = left_x + width; 571 int right_x = left_x + width;
(...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1977 // are taken from the WMs' source code. 1971 // are taken from the WMs' source code.
1978 return (wm_name == "Blackbox" || 1972 return (wm_name == "Blackbox" ||
1979 wm_name == "compiz" || 1973 wm_name == "compiz" ||
1980 wm_name == "e16" || // Enlightenment DR16 1974 wm_name == "e16" || // Enlightenment DR16
1981 wm_name == "Fluxbox" || 1975 wm_name == "Fluxbox" ||
1982 wm_name == "KWin" || 1976 wm_name == "KWin" ||
1983 wm_name == "Metacity" || 1977 wm_name == "Metacity" ||
1984 wm_name == "Openbox" || 1978 wm_name == "Openbox" ||
1985 wm_name == "Xfwm4"); 1979 wm_name == "Xfwm4");
1986 } 1980 }
OLDNEW
« no previous file with comments | « chrome/browser/browser_focus_uitest.cc ('k') | chrome/browser/gtk/extension_shelf_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698