Ignore:
Timestamp:
2014-08-12T17:14:32Z (10 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c3bdc92
Parents:
ce3efa0
Message:

allow compositor and console to coexist side-by-side, use the input server as a poor man's seat arbitrator

  • kernel console notifies both about the release and grab events
  • input server arbitrates the seat selection between kernel console and any number of user space UIs (currently the console server and the compositor server)
  • input port yield and reclaim methods have been removed (they are used only on Ski and Niagara, both already need a more generic mechanism for the kernel/user space cooperation)
  • console and compositor server keep track of the kernel console via the input arbitration
  • move the waiting for a character device from init and terminal widget to getterm
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/compositor/compositor.c

    rce3efa0 r593e023  
    5656#include <loc.h>
    5757
    58 #include <event.h>
    5958#include <io/keycode.h>
    6059#include <io/mode.h>
    6160#include <io/visualizer.h>
    6261#include <io/window.h>
     62#include <io/console.h>
    6363
    6464#include <transform.h>
     
    144144/** Input server proxy */
    145145static input_t *input;
    146 
     146static bool active = false;
     147
     148static int comp_active(input_t *);
     149static int comp_deactive(input_t *);
    147150static int comp_key_press(input_t *, kbd_event_type_t, keycode_t, keymod_t, wchar_t);
    148151static int comp_mouse_move(input_t *, int, int);
     
    151154
    152155static input_ev_ops_t input_ev_ops = {
     156        .active = comp_active,
     157        .deactive = comp_deactive,
    153158        .key = comp_key_press,
    154159        .move = comp_mouse_move,
     
    156161        .button = comp_mouse_button
    157162};
    158 
    159 static void input_disconnect(void);
    160163
    161164static pointer_t *input_pointer(input_t *input)
     
    567570
    568571        /* 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                }
    575580        }
    576581       
     
    10741079}
    10751080
     1081#if 0
     1082static 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
    10761105static void comp_visualizer_disconnect(viewport_t *vp, ipc_callid_t iid, ipc_call_t *icall)
    10771106{
     
    10821111        viewport_destroy(vp);
    10831112       
    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);
    11121119}
    11131120
     
    17801787}
    17811788
     1789static 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
     1797static int comp_deactive(input_t *input)
     1798{
     1799        active = false;
     1800        return EOK;
     1801}
     1802
    17821803static int comp_key_press(input_t *input, kbd_event_type_t type, keycode_t key,
    17831804    keymod_t mods, wchar_t c)
     
    20682089                fibril_mutex_unlock(&viewport_list_mtx);
    20692090        } else if (kconsole_switch) {
    2070                 __SYSCALL0(SYS_DEBUG_CONSOLE);
     2091                if (console_kcon())
     2092                        active = false;
    20712093        } else {
    20722094                window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t));
     
    21372159}
    21382160
    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 {
     2161static void discover_viewports(void)
     2162{
     2163        fibril_mutex_lock(&discovery_mtx);
     2164       
    21462165        /* Create viewports and connect them to visualizers. */
    21472166        category_id_t cat_id;
    21482167        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;
    21532170       
    21542171        service_id_t *svcs;
    21552172        size_t svcs_cnt = 0;
    21562173        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);
    21632178        for (size_t i = 0; i < svcs_cnt; ++i) {
    21642179                bool exists = false;
     
    21792194        fibril_mutex_unlock(&viewport_list_mtx);
    21802195       
    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       
     2199ret:
     2200        fibril_mutex_unlock(&discovery_mtx);
    21842201}
    21852202
    21862203static void category_change_cb(void)
    21872204{
    2188         fibril_mutex_lock(&discovery_mtx);
    21892205        discover_viewports();
    2190         fibril_mutex_unlock(&discovery_mtx);
    21912206}
    21922207
     
    22062221                printf("%s: Unable to register server (%s)\n", NAME, str_error(rc));
    22072222                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));
    22162223        }
    22172224       
     
    22482255                input_disconnect();
    22492256                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();
    22632260       
    22642261        comp_restrict_pointers();
Note: See TracChangeset for help on using the changeset viewer.