[PATCH xserver v3 10/24] present: Refactor present_screen_init
Roman Gilg
subdiff at gmail.com
Tue Mar 13 15:00:43 UTC 2018
To initialize easily different flip modes, refactor
'present_screen_init'.
Signed-off-by: Roman Gilg <subdiff at gmail.com>
---
present/present_screen.c | 46 +++++++++++++++++++++++++++++++++-------------
1 file changed, 33 insertions(+), 13 deletions(-)
diff --git a/present/present_screen.c b/present/present_screen.c
index 98f701a..868eaf8 100644
--- a/present/present_screen.c
+++ b/present/present_screen.c
@@ -170,32 +170,52 @@ present_clip_notify(WindowPtr window, int dx, int dy)
wrap(screen_priv, screen, ClipNotify, present_clip_notify);
}
+static Bool
+present_screen_register_priv_keys(void)
+{
+ if (!dixRegisterPrivateKey(&present_screen_private_key, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&present_window_private_key, PRIVATE_WINDOW, 0))
+ return FALSE;
+
+ return TRUE;
+}
+
+static present_screen_priv_ptr
+present_screen_priv_init(ScreenPtr screen)
+{
+ present_screen_priv_ptr screen_priv;
+
+ screen_priv = calloc(1, sizeof (present_screen_priv_rec));
+ if (!screen_priv)
+ return NULL;
+
+ wrap(screen_priv, screen, CloseScreen, present_close_screen);
+ wrap(screen_priv, screen, DestroyWindow, present_destroy_window);
+ wrap(screen_priv, screen, ConfigNotify, present_config_notify);
+ wrap(screen_priv, screen, ClipNotify, present_clip_notify);
+
+ dixSetPrivate(&screen->devPrivates, &present_screen_private_key, screen_priv);
+
+ return screen_priv;
+}
+
/*
* Initialize a screen for use with present
*/
int
present_screen_init(ScreenPtr screen, present_screen_info_ptr info)
{
- if (!dixRegisterPrivateKey(&present_screen_private_key, PRIVATE_SCREEN, 0))
- return FALSE;
-
- if (!dixRegisterPrivateKey(&present_window_private_key, PRIVATE_WINDOW, 0))
+ if (!present_screen_register_priv_keys())
return FALSE;
if (!present_screen_priv(screen)) {
- present_screen_priv_ptr screen_priv = calloc(1, sizeof (present_screen_priv_rec));
+ present_screen_priv_ptr screen_priv = present_screen_priv_init(screen);
if (!screen_priv)
return FALSE;
- wrap(screen_priv, screen, CloseScreen, present_close_screen);
- wrap(screen_priv, screen, DestroyWindow, present_destroy_window);
- wrap(screen_priv, screen, ConfigNotify, present_config_notify);
- wrap(screen_priv, screen, ClipNotify, present_clip_notify);
-
screen_priv->info = info;
-
- dixSetPrivate(&screen->devPrivates, &present_screen_private_key, screen_priv);
-
present_scmd_init_mode_hooks(screen_priv);
present_fake_screen_init(screen);
--
2.7.4
More information about the xorg-devel
mailing list