summaryrefslogtreecommitdiff
path: root/present
diff options
context:
space:
mode:
authorRoman Gilg <subdiff@gmail.com>2018-03-13 16:00:43 +0100
committerAdam Jackson <ajax@redhat.com>2018-03-28 14:36:28 -0400
commit3aaaac0be573fb09a206966075d81ebe0510ca23 (patch)
treef3de1871d94e83e34292e67c2fca8466bd84cf6c /present
parent6d813bbd5ea0fc38a8114c08368a7954eeb2ef37 (diff)
present: Refactor present_screen_init
To initialize easily different flip modes, refactor 'present_screen_init'. Signed-off-by: Roman Gilg <subdiff@gmail.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'present')
-rw-r--r--present/present_screen.c46
1 files changed, 33 insertions, 13 deletions
diff --git a/present/present_screen.c b/present/present_screen.c
index 98f701ab8..868eaf85b 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);