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

Side by Side Diff: components/exo/wayland/server.cc

Issue 1645043003: exo: Improve window placement. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/exo/wayland/server.h" 5 #include "components/exo/wayland/server.h"
6 6
7 #include <linux/input.h> 7 #include <linux/input.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <wayland-server-core.h> 10 #include <wayland-server-core.h>
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 631
632 void shell_surface_resize(wl_client* client, 632 void shell_surface_resize(wl_client* client,
633 wl_resource* resource, 633 wl_resource* resource,
634 wl_resource* seat_resource, 634 wl_resource* seat_resource,
635 uint32_t serial, 635 uint32_t serial,
636 uint32_t edges) { 636 uint32_t edges) {
637 NOTIMPLEMENTED(); 637 NOTIMPLEMENTED();
638 } 638 }
639 639
640 void shell_surface_set_toplevel(wl_client* client, wl_resource* resource) { 640 void shell_surface_set_toplevel(wl_client* client, wl_resource* resource) {
641 GetUserDataAs<ShellSurface>(resource)->Init(); 641 ShellSurface* shell_surface = GetUserDataAs<ShellSurface>(resource);
642
643 // Early out if shell surface has already been mapped.
644 if (shell_surface->enabled())
645 return;
lpique 2016/01/28 20:48:32 Note: SetEnabled() basically does this same early
reveman 2016/01/28 21:35:19 Good point. Changed this to unconditionally call S
646
647 shell_surface->SetEnabled(true);
642 } 648 }
643 649
644 void shell_surface_set_transient(wl_client* client, 650 void shell_surface_set_transient(wl_client* client,
645 wl_resource* resource, 651 wl_resource* resource,
646 wl_resource* parent_resource, 652 wl_resource* parent_resource,
647 int x, 653 int x,
648 int y, 654 int y,
649 uint32_t flags) { 655 uint32_t flags) {
650 NOTIMPLEMENTED(); 656 NOTIMPLEMENTED();
651 } 657 }
652 658
653 void shell_surface_set_fullscreen(wl_client* client, 659 void shell_surface_set_fullscreen(wl_client* client,
654 wl_resource* resource, 660 wl_resource* resource,
655 uint32_t method, 661 uint32_t method,
656 uint32_t framerate, 662 uint32_t framerate,
657 wl_resource* output_resource) { 663 wl_resource* output_resource) {
658 GetUserDataAs<ShellSurface>(resource)->Init(); 664 ShellSurface* shell_surface = GetUserDataAs<ShellSurface>(resource);
659 GetUserDataAs<ShellSurface>(resource)->SetFullscreen(true); 665
666 // Early out if shell surface has already been mapped.
667 if (shell_surface->enabled())
668 return;
lpique 2016/01/28 20:48:32 If you remove this new check here or below (as abo
reveman 2016/01/28 21:35:20 Correct. It shouldn't be possible to change the st
669
670 shell_surface->SetEnabled(true);
671 shell_surface->SetFullscreen(true);
660 } 672 }
661 673
662 void shell_surface_set_popup(wl_client* client, 674 void shell_surface_set_popup(wl_client* client,
663 wl_resource* resource, 675 wl_resource* resource,
664 wl_resource* seat_resource, 676 wl_resource* seat_resource,
665 uint32_t serial, 677 uint32_t serial,
666 wl_resource* parent_resource, 678 wl_resource* parent_resource,
667 int32_t x, 679 int32_t x,
668 int32_t y, 680 int32_t y,
669 uint32_t flags) { 681 uint32_t flags) {
670 NOTIMPLEMENTED(); 682 NOTIMPLEMENTED();
671 } 683 }
672 684
673 void shell_surface_set_maximized(wl_client* client, 685 void shell_surface_set_maximized(wl_client* client,
674 wl_resource* resource, 686 wl_resource* resource,
675 wl_resource* output_resource) { 687 wl_resource* output_resource) {
676 GetUserDataAs<ShellSurface>(resource)->Init(); 688 ShellSurface* shell_surface = GetUserDataAs<ShellSurface>(resource);
677 GetUserDataAs<ShellSurface>(resource)->Maximize(); 689
690 // Early out if shell surface has already been mapped.
691 if (shell_surface->enabled())
692 return;
693
694 shell_surface->SetEnabled(true);
695 shell_surface->Maximize();
678 } 696 }
679 697
680 void shell_surface_set_title(wl_client* client, 698 void shell_surface_set_title(wl_client* client,
681 wl_resource* resource, 699 wl_resource* resource,
682 const char* title) { 700 const char* title) {
683 GetUserDataAs<ShellSurface>(resource) 701 GetUserDataAs<ShellSurface>(resource)
684 ->SetTitle(base::string16(base::UTF8ToUTF16(title))); 702 ->SetTitle(base::string16(base::UTF8ToUTF16(title)));
685 } 703 }
686 704
687 void shell_surface_set_class(wl_client* client, 705 void shell_surface_set_class(wl_client* client,
(...skipping 30 matching lines...) Expand all
718 return; 736 return;
719 } 737 }
720 738
721 wl_resource* shell_surface_resource = 739 wl_resource* shell_surface_resource =
722 wl_resource_create(client, &wl_shell_surface_interface, 1, id); 740 wl_resource_create(client, &wl_shell_surface_interface, 1, id);
723 if (!shell_surface_resource) { 741 if (!shell_surface_resource) {
724 wl_resource_post_no_memory(resource); 742 wl_resource_post_no_memory(resource);
725 return; 743 return;
726 } 744 }
727 745
746 // Shell surfaces are initially disabled and needs to be explicitly mapped
747 // before they are enabled and can become visible.
748 shell_surface->SetEnabled(false);
749
728 shell_surface->set_surface_destroyed_callback(base::Bind( 750 shell_surface->set_surface_destroyed_callback(base::Bind(
729 &wl_resource_destroy, base::Unretained(shell_surface_resource))); 751 &wl_resource_destroy, base::Unretained(shell_surface_resource)));
730 752
731 shell_surface->set_configure_callback( 753 shell_surface->set_configure_callback(
732 base::Bind(&HandleShellSurfaceConfigureCallback, 754 base::Bind(&HandleShellSurfaceConfigureCallback,
733 base::Unretained(shell_surface_resource))); 755 base::Unretained(shell_surface_resource)));
734 756
735 SetImplementation(shell_surface_resource, &shell_surface_implementation, 757 SetImplementation(shell_surface_resource, &shell_surface_implementation,
736 std::move(shell_surface)); 758 std::move(shell_surface));
737 } 759 }
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 return; 967 return;
946 } 968 }
947 969
948 wl_resource* xdg_surface_resource = 970 wl_resource* xdg_surface_resource =
949 wl_resource_create(client, &xdg_surface_interface, 1, id); 971 wl_resource_create(client, &xdg_surface_interface, 1, id);
950 if (!xdg_surface_resource) { 972 if (!xdg_surface_resource) {
951 wl_resource_post_no_memory(resource); 973 wl_resource_post_no_memory(resource);
952 return; 974 return;
953 } 975 }
954 976
955 // An XdgSurface is a toplevel shell surface.
956 shell_surface->Init();
957
958 shell_surface->set_close_callback(base::Bind( 977 shell_surface->set_close_callback(base::Bind(
959 &xdg_surface_send_close, base::Unretained(xdg_surface_resource))); 978 &xdg_surface_send_close, base::Unretained(xdg_surface_resource)));
960 979
961 shell_surface->set_configure_callback( 980 shell_surface->set_configure_callback(
962 base::Bind(&HandleXdgSurfaceConfigureCallback, 981 base::Bind(&HandleXdgSurfaceConfigureCallback,
963 base::Unretained(xdg_surface_resource))); 982 base::Unretained(xdg_surface_resource)));
964 983
965 SetImplementation(xdg_surface_resource, &xdg_surface_implementation, 984 SetImplementation(xdg_surface_resource, &xdg_surface_implementation,
966 std::move(shell_surface)); 985 std::move(shell_surface));
967 } 986 }
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 DCHECK(event_loop); 1558 DCHECK(event_loop);
1540 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); 1559 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds());
1541 } 1560 }
1542 1561
1543 void Server::Flush() { 1562 void Server::Flush() {
1544 wl_display_flush_clients(wl_display_.get()); 1563 wl_display_flush_clients(wl_display_.get());
1545 } 1564 }
1546 1565
1547 } // namespace wayland 1566 } // namespace wayland
1548 } // namespace exo 1567 } // namespace exo
OLDNEW
« components/exo/shell_surface.cc ('K') | « components/exo/touch_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698