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

Side by Side Diff: ui/base/x/x11_util.cc

Issue 392153002: Remove X11/Xlib.h include from selection_requestor.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | « ui/base/x/x11_util.h ('k') | ui/gfx/x/x11_atom_cache.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) 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 // This file defines utility functions for X11 (Linux only). This code has been 5 // This file defines utility functions for X11 (Linux only). This code has been
6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support 6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support
7 // remains woefully incomplete. 7 // remains woefully incomplete.
8 8
9 #include "ui/base/x/x11_util.h" 9 #include "ui/base/x/x11_util.h"
10 10
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 78
79 int DefaultX11IOErrorHandler(XDisplay* d) { 79 int DefaultX11IOErrorHandler(XDisplay* d) {
80 // If there's an IO error it likely means the X server has gone away 80 // If there's an IO error it likely means the X server has gone away
81 LOG(ERROR) << "X IO error received (X server probably went away)"; 81 LOG(ERROR) << "X IO error received (X server probably went away)";
82 _exit(1); 82 _exit(1);
83 } 83 }
84 84
85 // Note: The caller should free the resulting value data. 85 // Note: The caller should free the resulting value data.
86 bool GetProperty(XID window, const std::string& property_name, long max_length, 86 bool GetProperty(XID window, const std::string& property_name, long max_length,
87 Atom* type, int* format, unsigned long* num_items, 87 XAtom* type, int* format, unsigned long* num_items,
88 unsigned char** property) { 88 unsigned char** property) {
89 Atom property_atom = GetAtom(property_name.c_str()); 89 XAtom property_atom = GetAtom(property_name.c_str());
90 unsigned long remaining_bytes = 0; 90 unsigned long remaining_bytes = 0;
91 return XGetWindowProperty(gfx::GetXDisplay(), 91 return XGetWindowProperty(gfx::GetXDisplay(),
92 window, 92 window,
93 property_atom, 93 property_atom,
94 0, // offset into property data to read 94 0, // offset into property data to read
95 max_length, // max length to get 95 max_length, // max length to get
96 False, // deleted 96 False, // deleted
97 AnyPropertyType, 97 AnyPropertyType,
98 type, 98 type,
99 format, 99 format,
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 unsigned long status; 476 unsigned long status;
477 } MotifWmHints; 477 } MotifWmHints;
478 478
479 MotifWmHints motif_hints; 479 MotifWmHints motif_hints;
480 memset(&motif_hints, 0, sizeof(motif_hints)); 480 memset(&motif_hints, 0, sizeof(motif_hints));
481 // Signals that the reader of the _MOTIF_WM_HINTS property should pay 481 // Signals that the reader of the _MOTIF_WM_HINTS property should pay
482 // attention to the value of |decorations|. 482 // attention to the value of |decorations|.
483 motif_hints.flags = (1L << 1); 483 motif_hints.flags = (1L << 1);
484 motif_hints.decorations = use_os_window_frame ? 1 : 0; 484 motif_hints.decorations = use_os_window_frame ? 1 : 0;
485 485
486 ::Atom hint_atom = GetAtom("_MOTIF_WM_HINTS"); 486 XAtom hint_atom = GetAtom("_MOTIF_WM_HINTS");
487 XChangeProperty(gfx::GetXDisplay(), 487 XChangeProperty(gfx::GetXDisplay(),
488 window, 488 window,
489 hint_atom, 489 hint_atom,
490 hint_atom, 490 hint_atom,
491 32, 491 32,
492 PropModeReplace, 492 PropModeReplace,
493 reinterpret_cast<unsigned char*>(&motif_hints), 493 reinterpret_cast<unsigned char*>(&motif_hints),
494 sizeof(MotifWmHints)/sizeof(long)); 494 sizeof(MotifWmHints)/sizeof(long));
495 } 495 }
496 496
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 bool IsWindowVisible(XID window) { 546 bool IsWindowVisible(XID window) {
547 TRACE_EVENT0("ui", "IsWindowVisible"); 547 TRACE_EVENT0("ui", "IsWindowVisible");
548 548
549 XWindowAttributes win_attributes; 549 XWindowAttributes win_attributes;
550 if (!XGetWindowAttributes(gfx::GetXDisplay(), window, &win_attributes)) 550 if (!XGetWindowAttributes(gfx::GetXDisplay(), window, &win_attributes))
551 return false; 551 return false;
552 if (win_attributes.map_state != IsViewable) 552 if (win_attributes.map_state != IsViewable)
553 return false; 553 return false;
554 554
555 // Minimized windows are not visible. 555 // Minimized windows are not visible.
556 std::vector<Atom> wm_states; 556 std::vector<XAtom> wm_states;
557 if (GetAtomArrayProperty(window, "_NET_WM_STATE", &wm_states)) { 557 if (GetAtomArrayProperty(window, "_NET_WM_STATE", &wm_states)) {
558 Atom hidden_atom = GetAtom("_NET_WM_STATE_HIDDEN"); 558 XAtom hidden_atom = GetAtom("_NET_WM_STATE_HIDDEN");
559 if (std::find(wm_states.begin(), wm_states.end(), hidden_atom) != 559 if (std::find(wm_states.begin(), wm_states.end(), hidden_atom) !=
560 wm_states.end()) { 560 wm_states.end()) {
561 return false; 561 return false;
562 } 562 }
563 } 563 }
564 564
565 // Some compositing window managers (notably kwin) do not actually unmap 565 // Some compositing window managers (notably kwin) do not actually unmap
566 // windows on desktop switch, so we also must check the current desktop. 566 // windows on desktop switch, so we also must check the current desktop.
567 int window_desktop, current_desktop; 567 int window_desktop, current_desktop;
568 return (!GetWindowDesktop(window, &window_desktop) || 568 return (!GetWindowDesktop(window, &window_desktop) ||
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 } 656 }
657 XFree(shape_rects); 657 XFree(shape_rects);
658 if (!is_in_shape_rects) 658 if (!is_in_shape_rects)
659 return false; 659 return false;
660 } 660 }
661 return true; 661 return true;
662 } 662 }
663 663
664 664
665 bool PropertyExists(XID window, const std::string& property_name) { 665 bool PropertyExists(XID window, const std::string& property_name) {
666 Atom type = None; 666 XAtom type = None;
667 int format = 0; // size in bits of each item in 'property' 667 int format = 0; // size in bits of each item in 'property'
668 unsigned long num_items = 0; 668 unsigned long num_items = 0;
669 unsigned char* property = NULL; 669 unsigned char* property = NULL;
670 670
671 int result = GetProperty(window, property_name, 1, 671 int result = GetProperty(window, property_name, 1,
672 &type, &format, &num_items, &property); 672 &type, &format, &num_items, &property);
673 if (result != Success) 673 if (result != Success)
674 return false; 674 return false;
675 675
676 XFree(property); 676 XFree(property);
677 return num_items > 0; 677 return num_items > 0;
678 } 678 }
679 679
680 bool GetRawBytesOfProperty(XID window, 680 bool GetRawBytesOfProperty(XID window,
681 Atom property, 681 XAtom property,
682 scoped_refptr<base::RefCountedMemory>* out_data, 682 scoped_refptr<base::RefCountedMemory>* out_data,
683 size_t* out_data_items, 683 size_t* out_data_items,
684 Atom* out_type) { 684 XAtom* out_type) {
685 // Retrieve the data from our window. 685 // Retrieve the data from our window.
686 unsigned long nitems = 0; 686 unsigned long nitems = 0;
687 unsigned long nbytes = 0; 687 unsigned long nbytes = 0;
688 Atom prop_type = None; 688 XAtom prop_type = None;
689 int prop_format = 0; 689 int prop_format = 0;
690 unsigned char* property_data = NULL; 690 unsigned char* property_data = NULL;
691 if (XGetWindowProperty(gfx::GetXDisplay(), window, property, 691 if (XGetWindowProperty(gfx::GetXDisplay(), window, property,
692 0, 0x1FFFFFFF /* MAXINT32 / 4 */, False, 692 0, 0x1FFFFFFF /* MAXINT32 / 4 */, False,
693 AnyPropertyType, &prop_type, &prop_format, 693 AnyPropertyType, &prop_type, &prop_format,
694 &nitems, &nbytes, &property_data) != Success) { 694 &nitems, &nbytes, &property_data) != Success) {
695 return false; 695 return false;
696 } 696 }
697 697
698 if (prop_type == None) 698 if (prop_type == None)
(...skipping 26 matching lines...) Expand all
725 if (out_data_items) 725 if (out_data_items)
726 *out_data_items = nitems; 726 *out_data_items = nitems;
727 727
728 if (out_type) 728 if (out_type)
729 *out_type = prop_type; 729 *out_type = prop_type;
730 730
731 return true; 731 return true;
732 } 732 }
733 733
734 bool GetIntProperty(XID window, const std::string& property_name, int* value) { 734 bool GetIntProperty(XID window, const std::string& property_name, int* value) {
735 Atom type = None; 735 XAtom type = None;
736 int format = 0; // size in bits of each item in 'property' 736 int format = 0; // size in bits of each item in 'property'
737 unsigned long num_items = 0; 737 unsigned long num_items = 0;
738 unsigned char* property = NULL; 738 unsigned char* property = NULL;
739 739
740 int result = GetProperty(window, property_name, 1, 740 int result = GetProperty(window, property_name, 1,
741 &type, &format, &num_items, &property); 741 &type, &format, &num_items, &property);
742 if (result != Success) 742 if (result != Success)
743 return false; 743 return false;
744 744
745 if (format != 32 || num_items != 1) { 745 if (format != 32 || num_items != 1) {
746 XFree(property); 746 XFree(property);
747 return false; 747 return false;
748 } 748 }
749 749
750 *value = static_cast<int>(*(reinterpret_cast<long*>(property))); 750 *value = static_cast<int>(*(reinterpret_cast<long*>(property)));
751 XFree(property); 751 XFree(property);
752 return true; 752 return true;
753 } 753 }
754 754
755 bool GetXIDProperty(XID window, const std::string& property_name, XID* value) { 755 bool GetXIDProperty(XID window, const std::string& property_name, XID* value) {
756 Atom type = None; 756 XAtom type = None;
757 int format = 0; // size in bits of each item in 'property' 757 int format = 0; // size in bits of each item in 'property'
758 unsigned long num_items = 0; 758 unsigned long num_items = 0;
759 unsigned char* property = NULL; 759 unsigned char* property = NULL;
760 760
761 int result = GetProperty(window, property_name, 1, 761 int result = GetProperty(window, property_name, 1,
762 &type, &format, &num_items, &property); 762 &type, &format, &num_items, &property);
763 if (result != Success) 763 if (result != Success)
764 return false; 764 return false;
765 765
766 if (format != 32 || num_items != 1) { 766 if (format != 32 || num_items != 1) {
767 XFree(property); 767 XFree(property);
768 return false; 768 return false;
769 } 769 }
770 770
771 *value = *(reinterpret_cast<XID*>(property)); 771 *value = *(reinterpret_cast<XID*>(property));
772 XFree(property); 772 XFree(property);
773 return true; 773 return true;
774 } 774 }
775 775
776 bool GetIntArrayProperty(XID window, 776 bool GetIntArrayProperty(XID window,
777 const std::string& property_name, 777 const std::string& property_name,
778 std::vector<int>* value) { 778 std::vector<int>* value) {
779 Atom type = None; 779 XAtom type = None;
780 int format = 0; // size in bits of each item in 'property' 780 int format = 0; // size in bits of each item in 'property'
781 unsigned long num_items = 0; 781 unsigned long num_items = 0;
782 unsigned char* properties = NULL; 782 unsigned char* properties = NULL;
783 783
784 int result = GetProperty(window, property_name, 784 int result = GetProperty(window, property_name,
785 (~0L), // (all of them) 785 (~0L), // (all of them)
786 &type, &format, &num_items, &properties); 786 &type, &format, &num_items, &properties);
787 if (result != Success) 787 if (result != Success)
788 return false; 788 return false;
789 789
790 if (format != 32) { 790 if (format != 32) {
791 XFree(properties); 791 XFree(properties);
792 return false; 792 return false;
793 } 793 }
794 794
795 long* int_properties = reinterpret_cast<long*>(properties); 795 long* int_properties = reinterpret_cast<long*>(properties);
796 value->clear(); 796 value->clear();
797 for (unsigned long i = 0; i < num_items; ++i) { 797 for (unsigned long i = 0; i < num_items; ++i) {
798 value->push_back(static_cast<int>(int_properties[i])); 798 value->push_back(static_cast<int>(int_properties[i]));
799 } 799 }
800 XFree(properties); 800 XFree(properties);
801 return true; 801 return true;
802 } 802 }
803 803
804 bool GetAtomArrayProperty(XID window, 804 bool GetAtomArrayProperty(XID window,
805 const std::string& property_name, 805 const std::string& property_name,
806 std::vector<Atom>* value) { 806 std::vector<XAtom>* value) {
807 Atom type = None; 807 XAtom type = None;
808 int format = 0; // size in bits of each item in 'property' 808 int format = 0; // size in bits of each item in 'property'
809 unsigned long num_items = 0; 809 unsigned long num_items = 0;
810 unsigned char* properties = NULL; 810 unsigned char* properties = NULL;
811 811
812 int result = GetProperty(window, property_name, 812 int result = GetProperty(window, property_name,
813 (~0L), // (all of them) 813 (~0L), // (all of them)
814 &type, &format, &num_items, &properties); 814 &type, &format, &num_items, &properties);
815 if (result != Success) 815 if (result != Success)
816 return false; 816 return false;
817 817
818 if (type != XA_ATOM) { 818 if (type != XA_ATOM) {
819 XFree(properties); 819 XFree(properties);
820 return false; 820 return false;
821 } 821 }
822 822
823 Atom* atom_properties = reinterpret_cast<Atom*>(properties); 823 XAtom* atom_properties = reinterpret_cast<XAtom*>(properties);
824 value->clear(); 824 value->clear();
825 value->insert(value->begin(), atom_properties, atom_properties + num_items); 825 value->insert(value->begin(), atom_properties, atom_properties + num_items);
826 XFree(properties); 826 XFree(properties);
827 return true; 827 return true;
828 } 828 }
829 829
830 bool GetStringProperty( 830 bool GetStringProperty(
831 XID window, const std::string& property_name, std::string* value) { 831 XID window, const std::string& property_name, std::string* value) {
832 Atom type = None; 832 XAtom type = None;
833 int format = 0; // size in bits of each item in 'property' 833 int format = 0; // size in bits of each item in 'property'
834 unsigned long num_items = 0; 834 unsigned long num_items = 0;
835 unsigned char* property = NULL; 835 unsigned char* property = NULL;
836 836
837 int result = GetProperty(window, property_name, 1024, 837 int result = GetProperty(window, property_name, 1024,
838 &type, &format, &num_items, &property); 838 &type, &format, &num_items, &property);
839 if (result != Success) 839 if (result != Success)
840 return false; 840 return false;
841 841
842 if (format != 8) { 842 if (format != 8) {
(...skipping 12 matching lines...) Expand all
855 int value) { 855 int value) {
856 std::vector<int> values(1, value); 856 std::vector<int> values(1, value);
857 return SetIntArrayProperty(window, name, type, values); 857 return SetIntArrayProperty(window, name, type, values);
858 } 858 }
859 859
860 bool SetIntArrayProperty(XID window, 860 bool SetIntArrayProperty(XID window,
861 const std::string& name, 861 const std::string& name,
862 const std::string& type, 862 const std::string& type,
863 const std::vector<int>& value) { 863 const std::vector<int>& value) {
864 DCHECK(!value.empty()); 864 DCHECK(!value.empty());
865 Atom name_atom = GetAtom(name.c_str()); 865 XAtom name_atom = GetAtom(name.c_str());
866 Atom type_atom = GetAtom(type.c_str()); 866 XAtom type_atom = GetAtom(type.c_str());
867 867
868 // XChangeProperty() expects values of type 32 to be longs. 868 // XChangeProperty() expects values of type 32 to be longs.
869 scoped_ptr<long[]> data(new long[value.size()]); 869 scoped_ptr<long[]> data(new long[value.size()]);
870 for (size_t i = 0; i < value.size(); ++i) 870 for (size_t i = 0; i < value.size(); ++i)
871 data[i] = value[i]; 871 data[i] = value[i];
872 872
873 gfx::X11ErrorTracker err_tracker; 873 gfx::X11ErrorTracker err_tracker;
874 XChangeProperty(gfx::GetXDisplay(), 874 XChangeProperty(gfx::GetXDisplay(),
875 window, 875 window,
876 name_atom, 876 name_atom,
877 type_atom, 877 type_atom,
878 32, // size in bits of items in 'value' 878 32, // size in bits of items in 'value'
879 PropModeReplace, 879 PropModeReplace,
880 reinterpret_cast<const unsigned char*>(data.get()), 880 reinterpret_cast<const unsigned char*>(data.get()),
881 value.size()); // num items 881 value.size()); // num items
882 return !err_tracker.FoundNewError(); 882 return !err_tracker.FoundNewError();
883 } 883 }
884 884
885 bool SetAtomProperty(XID window, 885 bool SetAtomProperty(XID window,
886 const std::string& name, 886 const std::string& name,
887 const std::string& type, 887 const std::string& type,
888 Atom value) { 888 XAtom value) {
889 std::vector<Atom> values(1, value); 889 std::vector<XAtom> values(1, value);
890 return SetAtomArrayProperty(window, name, type, values); 890 return SetAtomArrayProperty(window, name, type, values);
891 } 891 }
892 892
893 bool SetAtomArrayProperty(XID window, 893 bool SetAtomArrayProperty(XID window,
894 const std::string& name, 894 const std::string& name,
895 const std::string& type, 895 const std::string& type,
896 const std::vector<Atom>& value) { 896 const std::vector<XAtom>& value) {
897 DCHECK(!value.empty()); 897 DCHECK(!value.empty());
898 Atom name_atom = GetAtom(name.c_str()); 898 XAtom name_atom = GetAtom(name.c_str());
899 Atom type_atom = GetAtom(type.c_str()); 899 XAtom type_atom = GetAtom(type.c_str());
900 900
901 // XChangeProperty() expects values of type 32 to be longs. 901 // XChangeProperty() expects values of type 32 to be longs.
902 scoped_ptr<Atom[]> data(new Atom[value.size()]); 902 scoped_ptr<XAtom[]> data(new XAtom[value.size()]);
903 for (size_t i = 0; i < value.size(); ++i) 903 for (size_t i = 0; i < value.size(); ++i)
904 data[i] = value[i]; 904 data[i] = value[i];
905 905
906 gfx::X11ErrorTracker err_tracker; 906 gfx::X11ErrorTracker err_tracker;
907 XChangeProperty(gfx::GetXDisplay(), 907 XChangeProperty(gfx::GetXDisplay(),
908 window, 908 window,
909 name_atom, 909 name_atom,
910 type_atom, 910 type_atom,
911 32, // size in bits of items in 'value' 911 32, // size in bits of items in 'value'
912 PropModeReplace, 912 PropModeReplace,
913 reinterpret_cast<const unsigned char*>(data.get()), 913 reinterpret_cast<const unsigned char*>(data.get()),
914 value.size()); // num items 914 value.size()); // num items
915 return !err_tracker.FoundNewError(); 915 return !err_tracker.FoundNewError();
916 } 916 }
917 917
918 bool SetStringProperty(XID window, 918 bool SetStringProperty(XID window,
919 Atom property, 919 XAtom property,
920 Atom type, 920 XAtom type,
921 const std::string& value) { 921 const std::string& value) {
922 gfx::X11ErrorTracker err_tracker; 922 gfx::X11ErrorTracker err_tracker;
923 XChangeProperty(gfx::GetXDisplay(), 923 XChangeProperty(gfx::GetXDisplay(),
924 window, 924 window,
925 property, 925 property,
926 type, 926 type,
927 8, 927 8,
928 PropModeReplace, 928 PropModeReplace,
929 reinterpret_cast<const unsigned char*>(value.c_str()), 929 reinterpret_cast<const unsigned char*>(value.c_str()),
930 value.size()); 930 value.size());
931 return !err_tracker.FoundNewError(); 931 return !err_tracker.FoundNewError();
932 } 932 }
933 933
934 Atom GetAtom(const char* name) { 934 XAtom GetAtom(const char* name) {
935 // TODO(derat): Cache atoms to avoid round-trips to the server. 935 // TODO(derat): Cache atoms to avoid round-trips to the server.
936 return XInternAtom(gfx::GetXDisplay(), name, false); 936 return XInternAtom(gfx::GetXDisplay(), name, false);
937 } 937 }
938 938
939 void SetWindowClassHint(XDisplay* display, 939 void SetWindowClassHint(XDisplay* display,
940 XID window, 940 XID window,
941 const std::string& res_name, 941 const std::string& res_name,
942 const std::string& res_class) { 942 const std::string& res_class) {
943 XClassHint class_hints; 943 XClassHint class_hints;
944 // const_cast is safe because XSetClassHint does not modify the strings. 944 // const_cast is safe because XSetClassHint does not modify the strings.
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 } 1220 }
1221 1221
1222 void SetDefaultX11ErrorHandlers() { 1222 void SetDefaultX11ErrorHandlers() {
1223 SetX11ErrorHandlers(NULL, NULL); 1223 SetX11ErrorHandlers(NULL, NULL);
1224 } 1224 }
1225 1225
1226 bool IsX11WindowFullScreen(XID window) { 1226 bool IsX11WindowFullScreen(XID window) {
1227 // If _NET_WM_STATE_FULLSCREEN is in _NET_SUPPORTED, use the presence or 1227 // If _NET_WM_STATE_FULLSCREEN is in _NET_SUPPORTED, use the presence or
1228 // absence of _NET_WM_STATE_FULLSCREEN in _NET_WM_STATE to determine 1228 // absence of _NET_WM_STATE_FULLSCREEN in _NET_WM_STATE to determine
1229 // whether we're fullscreen. 1229 // whether we're fullscreen.
1230 Atom fullscreen_atom = GetAtom("_NET_WM_STATE_FULLSCREEN"); 1230 XAtom fullscreen_atom = GetAtom("_NET_WM_STATE_FULLSCREEN");
1231 if (WmSupportsHint(fullscreen_atom)) { 1231 if (WmSupportsHint(fullscreen_atom)) {
1232 std::vector<Atom> atom_properties; 1232 std::vector<XAtom> atom_properties;
1233 if (GetAtomArrayProperty(window, 1233 if (GetAtomArrayProperty(window,
1234 "_NET_WM_STATE", 1234 "_NET_WM_STATE",
1235 &atom_properties)) { 1235 &atom_properties)) {
1236 return std::find(atom_properties.begin(), 1236 return std::find(atom_properties.begin(),
1237 atom_properties.end(), 1237 atom_properties.end(),
1238 fullscreen_atom) != 1238 fullscreen_atom) !=
1239 atom_properties.end(); 1239 atom_properties.end();
1240 } 1240 }
1241 } 1241 }
1242 1242
1243 gfx::Rect window_rect; 1243 gfx::Rect window_rect;
1244 if (!ui::GetWindowRect(window, &window_rect)) 1244 if (!ui::GetWindowRect(window, &window_rect))
1245 return false; 1245 return false;
1246 1246
1247 // We can't use gfx::Screen here because we don't have an aura::Window. So 1247 // We can't use gfx::Screen here because we don't have an aura::Window. So
1248 // instead just look at the size of the default display. 1248 // instead just look at the size of the default display.
1249 // 1249 //
1250 // TODO(erg): Actually doing this correctly would require pulling out xrandr, 1250 // TODO(erg): Actually doing this correctly would require pulling out xrandr,
1251 // which we don't even do in the desktop screen yet. 1251 // which we don't even do in the desktop screen yet.
1252 ::XDisplay* display = gfx::GetXDisplay(); 1252 ::XDisplay* display = gfx::GetXDisplay();
1253 ::Screen* screen = DefaultScreenOfDisplay(display); 1253 ::Screen* screen = DefaultScreenOfDisplay(display);
1254 int width = WidthOfScreen(screen); 1254 int width = WidthOfScreen(screen);
1255 int height = HeightOfScreen(screen); 1255 int height = HeightOfScreen(screen);
1256 return window_rect.size() == gfx::Size(width, height); 1256 return window_rect.size() == gfx::Size(width, height);
1257 } 1257 }
1258 1258
1259 bool WmSupportsHint(Atom atom) { 1259 bool WmSupportsHint(XAtom atom) {
1260 std::vector<Atom> supported_atoms; 1260 std::vector<XAtom> supported_atoms;
1261 if (!GetAtomArrayProperty(GetX11RootWindow(), 1261 if (!GetAtomArrayProperty(GetX11RootWindow(),
1262 "_NET_SUPPORTED", 1262 "_NET_SUPPORTED",
1263 &supported_atoms)) { 1263 &supported_atoms)) {
1264 return false; 1264 return false;
1265 } 1265 }
1266 1266
1267 return std::find(supported_atoms.begin(), supported_atoms.end(), atom) != 1267 return std::find(supported_atoms.begin(), supported_atoms.end(), atom) !=
1268 supported_atoms.end(); 1268 supported_atoms.end();
1269 } 1269 }
1270 1270
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 << "request_code " << static_cast<int>(error_event.request_code) << ", " 1413 << "request_code " << static_cast<int>(error_event.request_code) << ", "
1414 << "minor_code " << static_cast<int>(error_event.minor_code) 1414 << "minor_code " << static_cast<int>(error_event.minor_code)
1415 << " (" << request_str << ")"; 1415 << " (" << request_str << ")";
1416 } 1416 }
1417 1417
1418 // ---------------------------------------------------------------------------- 1418 // ----------------------------------------------------------------------------
1419 // End of x11_util_internal.h 1419 // End of x11_util_internal.h
1420 1420
1421 1421
1422 } // namespace ui 1422 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/x/x11_util.h ('k') | ui/gfx/x/x11_atom_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698