Changeset 593e023 in mainline for uspace/srv/hid/compositor/compositor.c
- Timestamp:
- 2014-08-12T17:14:32Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c3bdc92
- Parents:
- ce3efa0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/compositor/compositor.c
rce3efa0 r593e023 56 56 #include <loc.h> 57 57 58 #include <event.h>59 58 #include <io/keycode.h> 60 59 #include <io/mode.h> 61 60 #include <io/visualizer.h> 62 61 #include <io/window.h> 62 #include <io/console.h> 63 63 64 64 #include <transform.h> … … 144 144 /** Input server proxy */ 145 145 static input_t *input; 146 146 static bool active = false; 147 148 static int comp_active(input_t *); 149 static int comp_deactive(input_t *); 147 150 static int comp_key_press(input_t *, kbd_event_type_t, keycode_t, keymod_t, wchar_t); 148 151 static int comp_mouse_move(input_t *, int, int); … … 151 154 152 155 static input_ev_ops_t input_ev_ops = { 156 .active = comp_active, 157 .deactive = comp_deactive, 153 158 .key = comp_key_press, 154 159 .move = comp_mouse_move, … … 156 161 .button = comp_mouse_button 157 162 }; 158 159 static void input_disconnect(void);160 163 161 164 static pointer_t *input_pointer(input_t *input) … … 567 570 568 571 /* Notify visualizers about updated regions. */ 569 list_foreach(viewport_list, link, viewport_t, vp) { 570 sysarg_t x_dmg_vp, y_dmg_vp, w_dmg_vp, h_dmg_vp; 571 surface_get_damaged_region(vp->surface, &x_dmg_vp, &y_dmg_vp, &w_dmg_vp, &h_dmg_vp); 572 surface_reset_damaged_region(vp->surface); 573 visualizer_update_damaged_region( 574 vp->sess, x_dmg_vp, y_dmg_vp, w_dmg_vp, h_dmg_vp, 0, 0); 572 if (active) { 573 list_foreach(viewport_list, link, viewport_t, vp) { 574 sysarg_t x_dmg_vp, y_dmg_vp, w_dmg_vp, h_dmg_vp; 575 surface_get_damaged_region(vp->surface, &x_dmg_vp, &y_dmg_vp, &w_dmg_vp, &h_dmg_vp); 576 surface_reset_damaged_region(vp->surface); 577 visualizer_update_damaged_region(vp->sess, 578 x_dmg_vp, y_dmg_vp, w_dmg_vp, h_dmg_vp, 0, 0); 579 } 575 580 } 576 581 … … 1074 1079 } 1075 1080 1081 #if 0 1082 static void comp_shutdown(void) 1083 { 1084 loc_service_unregister(winreg_id); 1085 input_disconnect(); 1086 1087 /* Close all clients and their windows. */ 1088 fibril_mutex_lock(&window_list_mtx); 1089 list_foreach(window_list, link, window_t, win) { 1090 window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t)); 1091 if (event) { 1092 link_initialize(&event->link); 1093 event->type = WINDOW_CLOSE; 1094 prodcons_produce(&win->queue, &event->link); 1095 } 1096 } 1097 fibril_mutex_unlock(&window_list_mtx); 1098 1099 async_answer_0(iid, EOK); 1100 1101 /* All fibrils of the compositor will terminate soon. */ 1102 } 1103 #endif 1104 1076 1105 static void comp_visualizer_disconnect(viewport_t *vp, ipc_callid_t iid, ipc_call_t *icall) 1077 1106 { … … 1082 1111 viewport_destroy(vp); 1083 1112 1084 /* Terminate compositor if there are no more viewports. */ 1085 if (list_empty(&viewport_list)) { 1086 fibril_mutex_unlock(&viewport_list_mtx); 1087 loc_service_unregister(winreg_id); 1088 input_disconnect(); 1089 1090 /* Close all clients and their windows. */ 1091 fibril_mutex_lock(&window_list_mtx); 1092 list_foreach(window_list, link, window_t, win) { 1093 window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t)); 1094 if (event) { 1095 link_initialize(&event->link); 1096 event->type = WINDOW_CLOSE; 1097 prodcons_produce(&win->queue, &event->link); 1098 } 1099 } 1100 fibril_mutex_unlock(&window_list_mtx); 1101 1102 async_answer_0(iid, EOK); 1103 1104 /* All fibrils of the compositor will terminate soon. */ 1105 } else { 1106 fibril_mutex_unlock(&viewport_list_mtx); 1107 async_answer_0(iid, EOK); 1108 1109 comp_restrict_pointers(); 1110 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 1111 } 1113 fibril_mutex_unlock(&viewport_list_mtx); 1114 1115 async_answer_0(iid, EOK); 1116 1117 comp_restrict_pointers(); 1118 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 1112 1119 } 1113 1120 … … 1780 1787 } 1781 1788 1789 static int comp_active(input_t *input) 1790 { 1791 active = true; 1792 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 1793 1794 return EOK; 1795 } 1796 1797 static int comp_deactive(input_t *input) 1798 { 1799 active = false; 1800 return EOK; 1801 } 1802 1782 1803 static int comp_key_press(input_t *input, kbd_event_type_t type, keycode_t key, 1783 1804 keymod_t mods, wchar_t c) … … 2068 2089 fibril_mutex_unlock(&viewport_list_mtx); 2069 2090 } else if (kconsole_switch) { 2070 __SYSCALL0(SYS_DEBUG_CONSOLE); 2091 if (console_kcon()) 2092 active = false; 2071 2093 } else { 2072 2094 window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t)); … … 2137 2159 } 2138 2160 2139 static void interrupt_received(ipc_callid_t callid, ipc_call_t *call) 2140 { 2141 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 2142 } 2143 2144 static int discover_viewports(void) 2145 { 2161 static void discover_viewports(void) 2162 { 2163 fibril_mutex_lock(&discovery_mtx); 2164 2146 2165 /* Create viewports and connect them to visualizers. */ 2147 2166 category_id_t cat_id; 2148 2167 int rc = loc_category_get_id("visualizer", &cat_id, IPC_FLAG_BLOCKING); 2149 if (rc != EOK) { 2150 printf("%s: Failed to get visualizer category.\n", NAME); 2151 return -1; 2152 } 2168 if (rc != EOK) 2169 goto ret; 2153 2170 2154 2171 service_id_t *svcs; 2155 2172 size_t svcs_cnt = 0; 2156 2173 rc = loc_category_get_svcs(cat_id, &svcs, &svcs_cnt); 2157 if (rc != EOK || svcs_cnt == 0) { 2158 printf("%s: Failed to get visualizer category services.\n", NAME); 2159 return -1; 2160 } 2161 2162 fibril_mutex_lock(&viewport_list_mtx); 2174 if (rc != EOK) 2175 goto ret; 2176 2177 fibril_mutex_lock(&viewport_list_mtx); 2163 2178 for (size_t i = 0; i < svcs_cnt; ++i) { 2164 2179 bool exists = false; … … 2179 2194 fibril_mutex_unlock(&viewport_list_mtx); 2180 2195 2181 /* TODO damage only newly added viewports */ 2182 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 2183 return EOK; 2196 if (!list_empty(&viewport_list)) 2197 input_activate(input); 2198 2199 ret: 2200 fibril_mutex_unlock(&discovery_mtx); 2184 2201 } 2185 2202 2186 2203 static void category_change_cb(void) 2187 2204 { 2188 fibril_mutex_lock(&discovery_mtx);2189 2205 discover_viewports(); 2190 fibril_mutex_unlock(&discovery_mtx);2191 2206 } 2192 2207 … … 2206 2221 printf("%s: Unable to register server (%s)\n", NAME, str_error(rc)); 2207 2222 return -1; 2208 }2209 2210 /* Register interrupt handler to switch back from kconsole. */2211 async_set_interrupt_received(interrupt_received);2212 rc = event_subscribe(EVENT_KCONSOLE, 0);2213 if (rc != EOK) {2214 printf("%s: Failed to register kconsole notifications (%s)\n",2215 NAME, str_error(rc));2216 2223 } 2217 2224 … … 2248 2255 input_disconnect(); 2249 2256 return rc; 2250 } 2251 2252 rc = discover_viewports(); 2253 if (rc != EOK) { 2254 input_disconnect(); 2255 return rc; 2256 } 2257 2258 if (list_empty(&viewport_list)) { 2259 printf("%s: Failed to get viewports.\n", NAME); 2260 input_disconnect(); 2261 return -1; 2262 } 2257 } 2258 2259 discover_viewports(); 2263 2260 2264 2261 comp_restrict_pointers();
Note:
See TracChangeset
for help on using the changeset viewer.