source: mainline/uspace/lib/c/include/io/window.h@ 75751db6

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 75751db6 was 62fbb7e, checked in by Martin Decky <martin@…>, 12 years ago

refactor window placement logic and introduce logical window placement flags

  • The original setup of window position during creation (window_open()) was quite useless, because the window had no surface yet.
  • Now the window position can be optinally set using window_resize() and various logical placement flags are available.
  • A separate window_move() routine could be introduced eventually if needed, but for the initial setup of the window the combination of window position and size works fine.
  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*
2 * Copyright (c) 2012 Petr Koupy
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup libc
30 * @{
31 */
32/** @file
33 */
34
35#ifndef LIBC_IO_WINDOW_H_
36#define LIBC_IO_WINDOW_H_
37
38#include <stdbool.h>
39#include <sys/types.h>
40#include <async.h>
41#include <loc.h>
42#include <io/kbd_event.h>
43#include <io/pos_event.h>
44
45typedef enum {
46 GF_EMPTY = 0,
47 GF_MOVE_X = 1,
48 GF_MOVE_Y = 2,
49 GF_RESIZE_X = 4,
50 GF_RESIZE_Y = 8,
51 GF_SCALE_X = 16,
52 GF_SCALE_Y = 32
53} window_grab_flags_t;
54
55typedef enum {
56 WINDOW_PLACEMENT_ANY = 0,
57 WINDOW_PLACEMENT_CENTER_X = 1,
58 WINDOW_PLACEMENT_CENTER_Y = 2,
59 WINDOW_PLACEMENT_CENTER =
60 WINDOW_PLACEMENT_CENTER_X | WINDOW_PLACEMENT_CENTER_Y,
61 WINDOW_PLACEMENT_LEFT = 4,
62 WINDOW_PLACEMENT_RIGHT = 8,
63 WINDOW_PLACEMENT_TOP = 16,
64 WINDOW_PLACEMENT_BOTTOM = 32,
65 WINDOW_PLACEMENT_ABSOLUTE_X = 64,
66 WINDOW_PLACEMENT_ABSOLUTE_Y = 128,
67 WINDOW_PLACEMENT_ABSOLUTE =
68 WINDOW_PLACEMENT_ABSOLUTE_X | WINDOW_PLACEMENT_ABSOLUTE_Y
69} window_placement_flags_t;
70
71typedef struct {
72 sysarg_t object;
73 sysarg_t slot;
74 sysarg_t argument;
75} signal_event_t;
76
77typedef struct {
78 sysarg_t offset_x;
79 sysarg_t offset_y;
80 sysarg_t width;
81 sysarg_t height;
82 window_placement_flags_t placement_flags;
83} resize_event_t;
84
85typedef enum {
86 ET_KEYBOARD_EVENT,
87 ET_POSITION_EVENT,
88 ET_SIGNAL_EVENT,
89 ET_WINDOW_FOCUS,
90 ET_WINDOW_UNFOCUS,
91 ET_WINDOW_RESIZE,
92 ET_WINDOW_REFRESH,
93 ET_WINDOW_DAMAGE,
94 ET_WINDOW_CLOSE
95} window_event_type_t;
96
97typedef union {
98 kbd_event_t kbd;
99 pos_event_t pos;
100 signal_event_t signal;
101 resize_event_t resize;
102} window_event_data_t;
103
104typedef struct {
105 link_t link;
106 window_event_type_t type;
107 window_event_data_t data;
108} window_event_t;
109
110extern int win_register(async_sess_t *, service_id_t *, service_id_t *);
111
112extern int win_get_event(async_sess_t *, window_event_t *);
113
114extern int win_damage(async_sess_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t);
115extern int win_grab(async_sess_t *, sysarg_t, sysarg_t);
116extern int win_resize(async_sess_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
117 window_placement_flags_t, void *);
118extern int win_close(async_sess_t *);
119extern int win_close_request(async_sess_t *);
120
121#endif
122
123/** @}
124 */
Note: See TracBrowser for help on using the repository browser.