# TabletState in ChromeOS
[TabletState](https://source.chromium.org/chromium/chromium/src/+/main:chromeos/ui/base/tablet_state.h;l=19;drc=1edc842daded4276598c39b69dbfedde9d885635) is a singleton class that holds the tablet mode state in chromeos.
For ChromeOS, we now have two platform: lacros and ash. TabletState is synced between Lacros and Ash, but they are saved at the different location.
Let's see where the state is stored and how it is initialized.
## Where is tablet state stored?
TabletState is a class to get tablet mode, but it actually does not hold the state itself.
[TabletState::get](https://source.chromium.org/chromium/chromium/src/+/main:chromeos/ui/base/tablet_state.cc;l=41;drc=7172fffc3c545134d5c88af8ab07b04fcb1d628e) methos is used to get the tablet state.
```cpp=
display::TabletState TabletState::state() const {
return display::Screen::GetScreen()->GetTabletState();
}
```
The state is obtained via display::Screen.
[GetTabletState](https://source.chromium.org/chromium/chromium/src/+/main:ui/display/screen.h;l=202;drc=bc2f8af26216040d50791a6a36efc46b8788750f) is a virtual class and overridden by [ScreenAsh](https://source.chromium.org/chromium/chromium/src/+/main:ash/display/screen_ash.cc;l=215;drc=7172fffc3c545134d5c88af8ab07b04fcb1d628e) and [ScreenOzone](https://source.chromium.org/chromium/chromium/src/+/main:ui/aura/screen_ozone.cc;l=149;drc=7172fffc3c545134d5c88af8ab07b04fcb1d628e).
[Display::Screen](https://source.chromium.org/chromium/chromium/src/+/main:ui/display/screen.h;l=44;drc=7172fffc3c545134d5c88af8ab07b04fcb1d628e) is a utility class to get various info about the screen such as its size, display and cursor position.
This class is not a singleton. The screen is for each workspace, each display, so its not a unique instance among one ChromeOS.
For Ash, the state is in [DisplayManager](https://source.chromium.org/chromium/chromium/src/+/main:ui/display/manager/display_manager.cc;l=2380;drc=7172fffc3c545134d5c88af8ab07b04fcb1d628e).
[DisplayManager](https://source.chromium.org/chromium/chromium/src/+/main:ui/display/manager/display_manager.h;l=59;drc=1a0aa1392ad020be7b0261fe7d86c8976dbaea5e) is a class to maintain the current display copnfigurations.
This class is not a singletgon, and created per screen.
For Lacros, the state is in [PlatformScreen](https://source.chromium.org/chromium/chromium/src/+/main:ui/ozone/public/platform_screen.cc;l=59;drc=7172fffc3c545134d5c88af8ab07b04fcb1d628e). The PlatformScreen for Lacros is [WaylandScreen](https://source.chromium.org/chromium/chromium/src/+/main:ui/ozone/platform/wayland/host/wayland_screen.cc;l=562;drc=7172fffc3c545134d5c88af8ab07b04fcb1d628e).
## Initialization
TabletState is for ChromeOS and both Lacros and Ash holds its state separately.
Initialization is done at the different location between lacros and ash.
### Ash
In Ash, it is initialized in [TabletModeController](https://source.chromium.org/chromium/chromium/src/+/main:ash/wm/tablet_mode/tablet_mode_controller.cc;l=404;drc=7172fffc3c545134d5c88af8ab07b04fcb1d628e) and TabletModeController is an instance in [ash::Shell](https://source.chromium.org/chromium/chromium/src/+/main:ash/shell.cc;l=1208;drc=7172fffc3c545134d5c88af8ab07b04fcb1d628e).
[ash::Shell](https://source.chromium.org/chromium/chromium/src/+/main:ash/shell.h;l=290;drc=81053984d491dd5c54dbc827585b249cc166f59f) is a singleton object that presents the Shell API.
### Lacros
In Lacros, TabletState is initialized in [ChromeBrowserMainExtraPartsViewsLacros::PreProfileInit](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/chrome_browser_main_extra_parts_views_lacros.cc;l=18;drc=7172fffc3c545134d5c88af8ab07b04fcb1d628e).
It's initialized before the profile initialization along with ImmersiveContext and SnapControllerLacros which are also the window management controller.
This extra part is registered in ChromeBrowserMain and called from [ChromeBrowserMain::PreProfileInit](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/chrome_browser_main.cc;l=1223;drc=7172fffc3c545134d5c88af8ab07b04fcb1d628e).